From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: mfe@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] mci: use partition table index for Linux mmcblkdev fixup
Date: Thu, 18 Dec 2025 10:46:35 +0100 [thread overview]
Message-ID: <20251218094645.49668-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-12-18 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 9:46 Ahmad Fatoum [this message]
2025-12-18 9:56 ` Sascha Hauer
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=20251218094645.49668-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mfe@pengutronix.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