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 diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
21 index fef1d1b..e46b4e9 100644
22 --- a/drivers/mtd/maps/physmap_of.c
23 +++ b/drivers/mtd/maps/physmap_of.c
24 @@ -112,9 +112,47 @@ static struct mtd_info *obsolete_probe(struct platform_device *dev,
25 static const char * const part_probe_types_def[] = {
26 "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
28 +static const char * const *of_get_probes(struct device_node *dp)
36 + cp = of_get_property(dp, "linux,part-probe", &cplen);
38 + return part_probe_types_def;
41 + for (l = 0; l != cplen; l++)
45 + res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
59 +static void of_free_probes(const char * const *probes)
61 + if (probes != part_probe_types_def)
65 static const struct of_device_id of_flash_match[];
66 static int of_flash_probe(struct platform_device *dev)
68 + const char * const *part_probe_types;
69 const struct of_device_id *match;
70 struct device_node *dp = dev->dev.of_node;
72 @@ -273,8 +311,14 @@ static int of_flash_probe(struct platform_device *dev)
76 - mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
77 + part_probe_types = of_get_probes(dp);
78 + if (!part_probe_types) {
82 + mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
84 + of_free_probes(part_probe_types);