U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
To: u-boot@lists.denx.de, Sumit Garg <sumit.garg@kernel.org>,
	u-boot-qcom@groups.io
Cc: Tom Rini <trini@konsulko.com>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	 Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Rasmus Villemoes <ravi@prevas.dk>, Simon Glass <sjg@chromium.org>,
	Javier Tia <floss@jetm.me>,
	Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
	Varadarajan Narayanan <quic_varada@quicinc.com>,
	Javier Martinez Canillas <javierm@redhat.com>,
	Richard Genoud <richard.genoud@bootlin.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	David Lechner <dlechner@baylibre.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Michael Walle <mwalle@kernel.org>,
	Sumit Garg <sumit.garg@oss.qualcomm.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Aswin Murugan <aswin.murugan@oss.qualcomm.com>,
	Jerome Forissier <jerome.forissier@arm.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>,
	Simon Glass <simon.glass@canonical.com>
Subject: [PATCH v4 2/8] scsi: Add partition lookup by type GUID for SCSI devices
Date: Tue, 28 Apr 2026 13:01:44 +0530	[thread overview]
Message-ID: <20260428-type-v4-2-b7051dc45a88@oss.qualcomm.com> (raw)
In-Reply-To: <20260428-type-v4-0-b7051dc45a88@oss.qualcomm.com>

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.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- Kept only scsi_get_blk_by_type_guid related changes
- Removed scsi_get_blk_by_uuid changes

Changes in v3:
- No changes

Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
---
 drivers/scsi/scsi-uclass.c | 23 +++++++++++++++++++++++
 include/scsi.h             | 11 +++++++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index 39b4c7476d4..cea6d771f7c 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -47,6 +47,29 @@ int scsi_get_blk_by_uuid(const char *uuid,
 	return -ENODEV;
 }
 
+int scsi_get_blk_by_type_guid(const char *type_guid,
+			      struct blk_desc **blk_desc_ptr,
+			      struct disk_partition *part_info_ptr)
+{
+	struct blk_desc *blk;
+	int i, ret, max;
+
+	max = blk_find_max_devnum(UCLASS_SCSI) + 1;
+	for (i = 0; i < max; i++) {
+		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 -ENODEV;
+}
+
 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 2520a8b8fe6..83aaf0a70f6 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -366,6 +366,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
+ * Return: 0 if OK, -ve on error
+ */
+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


  parent reply	other threads:[~2026-04-28  7:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  7:31 [PATCH v4 0/8] Add partition type GUID support for environment Balaji Selvanathan
2026-04-28  7:31 ` [PATCH v4 1/8] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
2026-05-07 13:42   ` Quentin Schulz
2026-04-28  7:31 ` Balaji Selvanathan [this message]
2026-05-01  2:12   ` [PATCH v4 2/8] scsi: Add partition lookup by type GUID for SCSI devices Simon Glass
2026-04-28  7:31 ` [PATCH v4 3/8] scsi: Optimize scsi_get_blk_by_uuid() loop iteration Balaji Selvanathan
2026-04-28  7:31 ` [PATCH v4 4/8] env: scsi: Fix ENV_SCSI_HW_PARTITION default value type Balaji Selvanathan
2026-04-28  7:31 ` [PATCH v4 5/8] env: scsi: Add partition type GUID support and choice-based selection Balaji Selvanathan
2026-04-28  7:31 ` [PATCH v4 6/8] env: scsi: Implement partition type GUID lookup Balaji Selvanathan
2026-04-28  7:31 ` [PATCH v4 7/8] configs: Enable partition type GUID for QCS9100/QCM6490/QCS615 boards Balaji Selvanathan
2026-05-01  8:02   ` Sumit Garg
2026-04-28  7:31 ` [PATCH v4 8/8] test: dm: Add partition type GUID lookup test Balaji Selvanathan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260428-type-v4-2-b7051dc45a88@oss.qualcomm.com \
    --to=balaji.selvanathan@oss.qualcomm.com \
    --cc=ansuelsmth@gmail.com \
    --cc=aswin.murugan@oss.qualcomm.com \
    --cc=casey.connolly@linaro.org \
    --cc=dlechner@baylibre.com \
    --cc=floss@jetm.me \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jan.kiszka@siemens.com \
    --cc=javierm@redhat.com \
    --cc=jerome.forissier@arm.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=mkorpershoek@kernel.org \
    --cc=mwalle@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quentin.schulz@cherry.de \
    --cc=quic_varada@quicinc.com \
    --cc=ravi@prevas.dk \
    --cc=richard.genoud@bootlin.com \
    --cc=simon.glass@canonical.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@kernel.org \
    --cc=sumit.garg@oss.qualcomm.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox