diff options
| author | Varadarajan Narayanan <[email protected]> | 2025-05-13 14:47:07 +0530 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-05-29 18:35:49 -0600 |
| commit | 9a2010941f56929cb28432cc3f4b37a944f55b8e (patch) | |
| tree | e3a4657ce0ac193329eebd2185181e4c01a44e8e /drivers | |
| parent | 43fd4bcefd4ea5e586e201a0908018d1e8395c82 (diff) | |
scsi: Implement get_blk() function
Add a function to obtain the block device for SCSI.
Signed-off-by: Varadarajan Narayanan <[email protected]>
Acked-by: Casey Connolly <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/scsi/scsi-uclass.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c index 1ee8236c05c..3eb6069649f 100644 --- a/drivers/scsi/scsi-uclass.c +++ b/drivers/scsi/scsi-uclass.c @@ -10,7 +10,9 @@ #define LOG_CATEGORY UCLASS_SCSI +#include <blk.h> #include <dm.h> +#include <part.h> #include <scsi.h> int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb) @@ -23,6 +25,34 @@ int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb) return ops->exec(dev, pccb); } +int scsi_get_blk_by_uuid(const char *uuid, + 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++) { + ret = blk_get_desc(UCLASS_SCSI, i, &blk); + if (ret) + continue; + + ret = part_get_info_by_uuid(blk, uuid, 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); |
