mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: use partition table index for Linux mmcblkdev fixup
@ 2025-12-18  9:46 Ahmad Fatoum
  2025-12-18  9:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-12-18  9:46 UTC (permalink / raw)
  To: barebox; +Cc: mfe, Ahmad Fatoum

If we have invalid PTEs, there will be gaps in the partition numbering
both in barebox and in Linux, but if we only iterate through the
partition list, we will not account for this.

Use the new cdev::partition_table_index to fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/mci-core.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 82864d710417..37d864b3d02f 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2657,20 +2657,13 @@ static void mci_parse_cid(struct mci *mci)
 	dev_add_param_uint32_fixed(dev, "cid_month", mci->cid.month, "%0u");
 }
 
-static bool cdev_partname_equal(const struct cdev *a,
-				const struct cdev *b)
-{
-	return a->partname && b->partname &&
-		!strcmp(a->partname, b->partname);
-}
-
 static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 				     const struct cdev *partcdev)
 
 {
 	struct mci_part *mci_part = container_of(blk, struct mci_part, blk);
-	struct cdev *cdevm = partcdev->master, *cdev;
-	int id, partnum;
+	struct cdev *cdevm = partcdev->master;
+	int id;
 
 	if (mci_part->area_type != MMC_BLK_DATA_AREA_MAIN)
 		return NULL;
@@ -2682,21 +2675,11 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 	if (id < 0)
 		return NULL;
 
-	partnum = 1; /* linux partitions are 1 based */
-	list_for_each_entry(cdev, &cdevm->partitions, partition_entry) {
+	if (!(partcdev->flags & DEVFS_PARTITION_FROM_TABLE))
+		return NULL;
 
-		/*
-		 * Partname is not guaranteed but this partition cdev is listed
-		 * in the partitions list so we need to count it instead of
-		 * skipping it.
-		 */
-		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("/dev/mmcblk%dp%d", id, partnum);
-		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
-			partnum++;
-	}
-
-	return NULL;
+	return basprintf("/dev/mmcblk%dp%d", id,
+			 partcdev->partition_table_index + 1);
 }
 
 static struct block_device_ops mci_ops = {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mci: use partition table index for Linux mmcblkdev fixup
  2025-12-18  9:46 [PATCH] mci: use partition table index for Linux mmcblkdev fixup Ahmad Fatoum
@ 2025-12-18  9:56 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-12-18  9:56 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: mfe


On Thu, 18 Dec 2025 10:46:35 +0100, Ahmad Fatoum wrote:
> If we have invalid PTEs, there will be gaps in the partition numbering
> both in barebox and in Linux, but if we only iterate through the
> partition list, we will not account for this.
> 
> Use the new cdev::partition_table_index to fix this.
> 
> 
> [...]

Applied, thanks!

[1/1] mci: use partition table index for Linux mmcblkdev fixup
      https://git.pengutronix.de/cgit/barebox/commit/?id=928a71e0d678 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-18  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18  9:46 [PATCH] mci: use partition table index for Linux mmcblkdev fixup Ahmad Fatoum
2025-12-18  9:56 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox