[PATCH 2/2] of: partition: Use mtd partitioning for of_fixup instead of the cdev variant
Uwe Kleine-König
uwe at kleine-koenig.org
Fri Mar 8 01:15:09 PST 2024
From: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
It was already noticed in commit 9d42c77f126e ("devfs: take into account
for the partitions check that mtd is different") that the partitioning
info is stored differently for mtd devices. Instead of only getting the
partion size from the right spot, use the right data completely.
Fixes: 9d42c77f126e ("devfs: take into account for the partitions check that mtd is different")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
drivers/of/partition.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index d11e1d1690f9..598ac5240d79 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -267,18 +267,32 @@ int of_fixup_partitions(struct device_node *np, struct cdev *cdev)
if (ret)
return ret;
- list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
- loff_t partoffset;
+ if (cdev->mtd) {
+ struct mtd_info *mtdpart;
+ list_for_each_entry(mtdpart, &cdev->mtd->partitions, partitions_entry) {
+ const char *name = mtdpart->name;
+
+ if (mtdpart->parent) {
+ const char *parentname = dev_name(&mtdpart->parent->dev);
+ size_t parentnamelen = strlen(parentname);
+
+ if (!strncmp(parentname, name, parentnamelen) && name[parentnamelen] == '.')
+ name += parentnamelen + 1;
+ }
+
+ ret = of_fixup_one_partition(partnode, mtdpart->master_offset, mtdpart->size, name, partcdev->flags);
+ if (ret)
+ return ret;
+ }
+ return 0;
+ }
+
+ list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
if (!(partcdev->flags & DEVFS_PARTITION_FROM_OF))
continue;
- if (partcdev->mtd)
- partoffset = partcdev->mtd->master_offset;
- else
- partoffset = partcdev->offset;
-
- ret = of_fixup_one_partition(partnode, partoffset, partcdev->size, partcdev->partname, partcdev->flags);
+ ret = of_fixup_one_partition(partnode, partcdev->offset, partcdev->size, partcdev->partname, partcdev->flags);
if (ret)
return ret;
}
--
2.43.0
More information about the barebox
mailing list