1 From 3e7056c3a369e9ef9ca804bc626b60ef6b62ee27 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 2/3] 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 | 46 +-------------------------
15 drivers/mtd/mtdpart.c | 45 +++++++++++++++++++++++++
16 3 files changed, 62 insertions(+), 45 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 @@ -112,47 +112,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);
80 -static void of_free_probes(const char * const *probes)
82 - if (probes != part_probe_types_def)
86 static const struct of_device_id of_flash_match[];
87 static int of_flash_probe(struct platform_device *dev)
89 - const char * const *part_probe_types;
90 const struct of_device_id *match;
91 struct device_node *dp = dev->dev.of_node;
93 @@ -311,14 +273,8 @@ static int of_flash_probe(struct platfor
97 - part_probe_types = of_get_probes(dp);
98 - if (!part_probe_types) {
102 - mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
103 + mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
105 - of_free_probes(part_probe_types);
109 --- a/drivers/mtd/mtdpart.c
110 +++ b/drivers/mtd/mtdpart.c
112 #include <linux/kmod.h>
113 #include <linux/mtd/mtd.h>
114 #include <linux/mtd/partitions.h>
115 +#include <linux/of.h>
116 #include <linux/err.h>
117 #include <linux/kconfig.h>
119 @@ -721,6 +722,42 @@ void deregister_mtd_parser(struct mtd_pa
120 EXPORT_SYMBOL_GPL(deregister_mtd_parser);
123 + * Parses the linux,part-probe device tree property.
124 + * When a non null value is returned it has to be freed with kfree() by
127 +static const char * const *of_get_probes(struct device_node *dp)
132 + unsigned int count;
135 + cp = of_get_property(dp, "linux,part-probe", &cplen);
140 + for (l = 0; l != cplen; l++)
144 + res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
148 + while (cplen > 0) {
150 + l = strlen(cp) + 1;
159 * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
160 * are changing this array!
162 @@ -756,6 +793,13 @@ int parse_mtd_partitions(struct mtd_info
164 struct mtd_part_parser *parser;
166 + const char *const *types_of = NULL;
168 + if (data && data->of_node) {
169 + types_of = of_get_probes(data->of_node);
170 + if (types_of != NULL)
175 types = default_mtd_part_types;
176 @@ -785,6 +829,7 @@ int parse_mtd_partitions(struct mtd_info