1 From 173b0add0cff6558f950c0cb1eacfb729d482711 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 17 May 2015 18:48:38 +0200
4 Subject: [PATCH 4/8] mtd: part: add generic parsing of linux,part-probe
6 This moves the linux,part-probe device tree parsing code from
7 physmap_of.c to mtdpart.c. Now all drivers can use this feature by just
8 providing a reference to their device tree node in struct
11 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
13 Documentation/devicetree/bindings/mtd/nand.txt | 16 ++++++++++
14 drivers/mtd/maps/physmap_of.c | 40 +-----------------------
15 drivers/mtd/mtdpart.c | 43 ++++++++++++++++++++++++++
16 3 files changed, 60 insertions(+), 39 deletions(-)
18 --- a/Documentation/devicetree/bindings/mtd/nand.txt
19 +++ b/Documentation/devicetree/bindings/mtd/nand.txt
21 - nand-ecc-step-size: integer representing the number of data bytes
22 that are covered by a single ECC step.
24 +- linux,part-probe: list of name as strings of the partition parser
25 + which should be used to parse the partition table.
26 + They will be tried in the specified ordering and
27 + the next one will be used if the previous one
30 + Example: linux,part-probe = "cmdlinepart", "ofpart";
32 + This is also the default value, which will be used
33 + if this attribute is not specified. It could be
34 + that the flash driver in use overwrote the default
35 + value and uses some other default.
37 + Possible values are: bcm47xxpart, afs, ar7part,
38 + ofoldpart, ofpart, bcm63xxpart, RedBoot, cmdlinepart
40 The ECC strength and ECC step size properties define the correction capability
41 of a controller. Together, they say a controller can correct "{strength} bit
42 errors per {size} bytes".
43 --- a/drivers/mtd/maps/physmap_of.c
44 +++ b/drivers/mtd/maps/physmap_of.c
45 @@ -114,45 +114,9 @@ static struct mtd_info *obsolete_probe(s
46 static const char * const part_probe_types_def[] = {
47 "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL };
49 -static const char * const *of_get_probes(struct device_node *dp)
57 - cp = of_get_property(dp, "linux,part-probe", &cplen);
59 - return part_probe_types_def;
62 - for (l = 0; l != cplen; l++)
66 - res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
78 -static void of_free_probes(const char * const *probes)
80 - if (probes != part_probe_types_def)
84 static struct of_device_id of_flash_match[];
85 static int of_flash_probe(struct platform_device *dev)
87 - const char * const *part_probe_types;
88 const struct of_device_id *match;
89 struct device_node *dp = dev->dev.of_node;
91 @@ -302,10 +266,8 @@ static int of_flash_probe(struct platfor
95 - part_probe_types = of_get_probes(dp);
96 - mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
97 + mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
99 - of_free_probes(part_probe_types);
103 --- a/drivers/mtd/mtdpart.c
104 +++ b/drivers/mtd/mtdpart.c
106 #include <linux/kmod.h>
107 #include <linux/mtd/mtd.h>
108 #include <linux/mtd/partitions.h>
109 +#include <linux/of.h>
110 #include <linux/err.h>
113 @@ -702,6 +703,40 @@ void deregister_mtd_parser(struct mtd_pa
114 EXPORT_SYMBOL_GPL(deregister_mtd_parser);
117 + * Parses the linux,part-probe device tree property.
118 + * When a non null value is returned it has to be freed with kfree() by
121 +static const char * const *of_get_probes(struct device_node *dp)
126 + unsigned int count;
129 + cp = of_get_property(dp, "linux,part-probe", &cplen);
134 + for (l = 0; l != cplen; l++)
138 + res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
140 + while (cplen > 0) {
142 + l = strlen(cp) + 1;
151 * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
152 * are changing this array!
154 @@ -737,6 +772,13 @@ int parse_mtd_partitions(struct mtd_info
156 struct mtd_part_parser *parser;
158 + const char *const *types_of = NULL;
160 + if (data && data->of_node) {
161 + types_of = of_get_probes(data->of_node);
162 + if (types_of != NULL)
167 types = default_mtd_part_types;
168 @@ -755,6 +797,7 @@ int parse_mtd_partitions(struct mtd_info