[PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices

Balaji Selvanathan balaji.selvanathan at oss.qualcomm.com
Fri Jan 9 08:13:19 CET 2026


Hi Varada,

On 1/8/2026 3:07 PM, Varadarajan Narayanan wrote:
> On Thu, Jan 08, 2026 at 12:19:45PM +0530, Balaji Selvanathan wrote:
>> Introduce scsi_get_blk_by_type_guid() function to enable SCSI
>> partition discovery using partition type GUID. This function scans
>> all available SCSI devices and searches for a partition matching the
>> specified type GUID.
>>
>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>
>> ---
>>   drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++++
>>   include/scsi.h             | 11 +++++++++++
>>   2 files changed, 39 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
>> index 3eb6069649f..42a6b5233c2 100644
>> --- a/drivers/scsi/scsi-uclass.c
>> +++ b/drivers/scsi/scsi-uclass.c
>> @@ -53,6 +53,34 @@ int scsi_get_blk_by_uuid(const char *uuid,
>>   	return -1;
>>   }
>>
>> +int scsi_get_blk_by_type_guid(const char *type_guid,
>> +			      struct blk_desc **blk_desc_ptr,
>> +			      struct disk_partition *part_info_ptr)
>> +{
>> +	static int is_scsi_scanned;
>> +	struct blk_desc *blk;
>> +	int i, ret;
>> +
>> +	if (!is_scsi_scanned) {
>> +		scsi_scan(false /* no verbose */);
>> +		is_scsi_scanned = 1;
>> +	}
>> +
>> +	for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
> 	max = blk_find_max_devnum(UCLASS_SCSI) + 1;
> 	for (i = 0; i < max; i++) {
>
> Else, i believe blk_find_max_devnum() will get invoked multiple times.
>
> -Varada

Thanks for the feedback. Addressed this.

Regards,

Balaji

>
>> +		ret = blk_get_desc(UCLASS_SCSI, i, &blk);
>> +		if (ret)
>> +			continue;
>> +
>> +		ret = part_get_info_by_type_guid(blk, type_guid, part_info_ptr);
>> +		if (ret > 0) {
>> +			*blk_desc_ptr = blk;
>> +			return 0;
>> +		}
>> +	}
>> +
>> +	return -1;
>> +}
>> +
>>   int scsi_bus_reset(struct udevice *dev)
>>   {
>>   	struct scsi_ops *ops = scsi_get_ops(dev);
>> diff --git a/include/scsi.h b/include/scsi.h
>> index 8d6c5116419..e0b2f869057 100644
>> --- a/include/scsi.h
>> +++ b/include/scsi.h
>> @@ -361,6 +361,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
>>   int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
>>   			 struct disk_partition *part_info_ptr);
>>
>> +
>> +/**
>> + * scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID.
>> + *
>> + * @type_guid:		Type GUID of the partition for fetching its info
>> + * @blk_desc_ptr:	Provides the blk descriptor
>> + * @part_info_ptr:	Provides partition info
>> + */
>> +int scsi_get_blk_by_type_guid(const char *type_guid, struct blk_desc **blk_desc_ptr,
>> +			      struct disk_partition *part_info_ptr);
>> +
>>   #define SCSI_IDENTIFY					0xC0  /* not used */
>>
>>   /* Hardware errors  */
>> --
>> 2.34.1
>>


More information about the U-Boot mailing list