1 From 6b54054c4053215fe4add195c67daca9a466ba92 Mon Sep 17 00:00:00 2001
2 From: "ying.zhang" <ying.zhang22455@nxp.com>
3 Date: Fri, 23 Dec 2016 22:21:22 +0800
4 Subject: [PATCH] mtd: extend physmap_of to let the device tree specify the
7 This is to support custom partitioning schemes for embedded PPC. To use
8 define your own mtd_part_parser and then add something like:
9 linux,part-probe = "my_probe", "cmdlinepart";
10 To the board's dts file.
12 If linux,part-probe is not specified then this behaves the same as before.
14 Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
15 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
17 drivers/mtd/maps/physmap_of.c | 46 ++++++++++++++++++++++++++++++++++++++++-
18 1 file changed, 45 insertions(+), 1 deletion(-)
20 --- a/drivers/mtd/maps/physmap_of.c
21 +++ b/drivers/mtd/maps/physmap_of.c
22 @@ -112,9 +112,47 @@ static struct mtd_info *obsolete_probe(s
23 static const char * const part_probe_types_def[] = {
24 "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
26 +static const char * const *of_get_probes(struct device_node *dp)
34 + cp = of_get_property(dp, "linux,part-probe", &cplen);
36 + return part_probe_types_def;
39 + for (l = 0; l != cplen; l++)
43 + res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
57 +static void of_free_probes(const char * const *probes)
59 + if (probes != part_probe_types_def)
63 static const struct of_device_id of_flash_match[];
64 static int of_flash_probe(struct platform_device *dev)
66 + const char * const *part_probe_types;
67 const struct of_device_id *match;
68 struct device_node *dp = dev->dev.of_node;
70 @@ -273,8 +311,14 @@ static int of_flash_probe(struct platfor
74 - mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
75 + part_probe_types = of_get_probes(dp);
76 + if (!part_probe_types) {
80 + mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
82 + of_free_probes(part_probe_types);