public inbox for u-boot@lists.denx.de
 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>,
	"Javier Tia" <javier.tia@linaro.org>,
	"Varadarajan Narayanan" <quic_varada@quicinc.com>,
	"Rasmus Villemoes" <ravi@prevas.dk>,
	"Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"João Marcos Costa" <joaomarcos.costa@bootlin.com>,
	"Tien Fong Chee" <tien.fong.chee@altera.com>,
	"Richard Genoud" <richard.genoud@bootlin.com>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Casey Connolly" <casey.connolly@linaro.org>,
	"Simon Glass" <simon.glass@canonical.com>,
	"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>,
	"Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>,
	"Simon Glass" <sjg@chromium.org>,
	"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
	"Jerome Forissier" <jerome.forissier@arm.com>,
	"Balaji Selvanathan" <balaji.selvanathan@oss.qualcomm.com>
Subject: [PATCH v3 1/5] disk: Add partition lookup by type GUID functionality
Date: Sun, 19 Apr 2026 15:54:03 +0530	[thread overview]
Message-ID: <20260419-type-v3-1-ec49acd6870e@oss.qualcomm.com> (raw)
In-Reply-To: <20260419-type-v3-0-ec49acd6870e@oss.qualcomm.com>

Introduce part_get_info_by_type_guid() function to enable partition
lookup using partition type GUID. This complements the existing UUID
lookup functionality and provides more flexible partition discovery
mechanisms.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v3:
- Addressed minor corrections in part_get_info_by_type_guid function

Changes in v2:
- No changes
---
 disk/part.c    | 37 +++++++++++++++++++++++++++++++++++++
 include/part.h | 21 +++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 4923dc44593..4cb3204ac6e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -731,6 +731,43 @@ int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 	return -ENOENT;
 }
 
+int part_get_info_by_type_guid(struct blk_desc *desc, const char *type_guid,
+			       struct disk_partition *info)
+{
+	struct part_driver *part_drv;
+	int ret;
+	int i;
+
+	if (!CONFIG_IS_ENABLED(PARTITION_TYPE_GUID))
+		return -ENOENT;
+
+	part_drv = part_driver_lookup_type(desc);
+	if (!part_drv)
+		return -ENOENT;
+
+	for (i = 1; i <= part_drv->max_entries; i++) {
+		ret = part_driver_get_info(part_drv, desc, i, info);
+		if (ret) {
+			/* -ENOSYS means no ->get_info method. */
+			if (ret == -ENOSYS)
+				return ret;
+			/*
+			 * Partition with this index can't be obtained, but
+			 * further partitions might be, so keep checking.
+			 */
+			continue;
+		}
+
+		if (!strncasecmp(type_guid, disk_partition_type_guid(info),
+				 UUID_STR_LEN)) {
+			/* matched */
+			return i;
+		}
+	}
+
+	return -ENOENT;
+}
+
 /**
  * Get partition info from device number and partition name.
  *
diff --git a/include/part.h b/include/part.h
index 15daacd7faa..32614bd085b 100644
--- a/include/part.h
+++ b/include/part.h
@@ -327,6 +327,20 @@ int part_get_info_by_name(struct blk_desc *desc, const char *name,
 int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 			  struct disk_partition *info);
 
+/**
+ * part_get_info_by_type_guid() - Search for a partition by type GUID
+ *                                among all available registered partitions
+ *
+ * @desc:	block device descriptor
+ * @type_guid:	the specified partition type GUID
+ * @info:	the disk partition info
+ *
+ * Return: the partition number on match (starting on 1), -ENOENT on no match,
+ * otherwise error
+ */
+int part_get_info_by_type_guid(struct blk_desc *desc, const char *type_guid,
+			       struct disk_partition *info);
+
 /**
  * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number
  *					    and part name, or dev number and
@@ -404,6 +418,13 @@ static inline int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 	return -ENOENT;
 }
 
+static inline int part_get_info_by_type_guid(struct blk_desc *desc,
+					     const char *type_guid,
+					     struct disk_partition *info)
+{
+	return -ENOENT;
+}
+
 static inline int
 part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 				     const char *dev_part_str,

-- 
2.34.1


  reply	other threads:[~2026-04-19 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 10:24 [PATCH v3 0/5] Add partition type GUID support for environment Balaji Selvanathan
2026-04-19 10:24 ` Balaji Selvanathan [this message]
2026-04-19 10:24 ` [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 5/5] 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=20260419-type-v3-1-ec49acd6870e@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=ilias.apalodimas@linaro.org \
    --cc=jan.kiszka@siemens.com \
    --cc=javier.tia@linaro.org \
    --cc=javierm@redhat.com \
    --cc=jerome.forissier@arm.com \
    --cc=joaomarcos.costa@bootlin.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=miquel.raynal@bootlin.com \
    --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=tien.fong.chee@altera.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=varadarajan.narayanan@oss.qualcomm.com \
    /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