Message ID | 20220707163607.20729-1-zajec5@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/2] mtd: core: simplify (a bit) code find partition-matching dynamic OF node | expand |
On 7.07.2022 18:36, Rafał Miłecki wrote: > From: Rafał Miłecki <rafal@milecki.pl> > > Don't limit this feature to the "nvmem-cells". There are more cases to > this. > 1. Dynamic partitions may need to be handled with parsers > This applies to "fixed-partitions" parser and all custom ones. > 2. Dynamic partitions can be handled with specific drivers > Consider "u-boot,env" as specified in the u-boot,env.yaml. > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl> This code needs more work, please drop this patchset for now.
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index dc9b33990895..79c447fe30b4 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -573,15 +573,15 @@ static void mtd_check_of_node(struct mtd_info *mtd) /* Search if a partition is defined with the same name */ for_each_child_of_node(partitions, mtd_dn) { - offset = 0; - /* Skip partition with no/wrong prefix */ - if (!of_node_name_prefix(mtd_dn, "partition-")) + if (!of_node_name_prefix(mtd_dn, prefix)) continue; /* Label have priority. Check that first */ - if (of_property_read_string(mtd_dn, "label", &pname)) { - of_property_read_string(mtd_dn, "name", &pname); + if (!of_property_read_string(mtd_dn, "label", &pname)) { + offset = 0; + } else { + pname = mtd_dn->name; offset = prefix_len; }