aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps/physmap_of.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>2010-03-09 14:27:56 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-05-13 19:32:30 -0400
commit9d5da3a9b849cf42fc165e90b1d39e2fd1e199a8 (patch)
treef1d66bb84b510f8ba53e232e9b5d9499a1bd20a3 /drivers/mtd/maps/physmap_of.c
parent2bfefa4c9632fb09bfe3277cf7b690818b147654 (diff)
mtd: extend physmap_of to let the device tree specify the parition probe
This is to support custom partitioning schemes for embedded PPC. To use define your own mtd_part_parser and then add something like: linux,part-probe = "my_probe", "cmdlinepart"; To the board's dts file. If linux,part-probe is not specified then this behaves the same as before. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/maps/physmap_of.c')
-rw-r--r--drivers/mtd/maps/physmap_of.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index bbdd21941905..36dbcee1ac29 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -173,12 +173,53 @@ static struct mtd_info * __devinit obsolete_probe(struct of_device *dev,
173 } 173 }
174} 174}
175 175
176#ifdef CONFIG_MTD_PARTITIONS
177/* When partitions are set we look for a linux,part-probe property which
178 specifies the list of partition probers to use. If none is given then the
179 default is use. These take precedence over other device tree
180 information. */
181static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot", NULL };
182static const char ** __devinit of_get_probes(struct device_node *dp)
183{
184 const char *cp;
185 int cplen;
186 unsigned int l;
187 unsigned int count;
188 const char **res;
189
190 cp = of_get_property(dp, "linux,part-probe", &cplen);
191 if (cp == NULL)
192 return part_probe_types_def;
193
194 count = 0;
195 for (l = 0; l != cplen; l++)
196 if (cp[l] == 0)
197 count++;
198
199 res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
200 count = 0;
201 while (cplen > 0) {
202 res[count] = cp;
203 l = strlen(cp) + 1;
204 cp += l;
205 cplen -= l;
206 count++;
207 }
208 return res;
209}
210
211static void __devinit of_free_probes(const char **probes)
212{
213 if (probes != part_probe_types_def)
214 kfree(probes);
215}
216#endif
217
176static int __devinit of_flash_probe(struct of_device *dev, 218static int __devinit of_flash_probe(struct of_device *dev,
177 const struct of_device_id *match) 219 const struct of_device_id *match)
178{ 220{
179#ifdef CONFIG_MTD_PARTITIONS 221#ifdef CONFIG_MTD_PARTITIONS
180 static const char *part_probe_types[] 222 const char **part_probe_types;
181 = { "cmdlinepart", "RedBoot", NULL };
182#endif 223#endif
183 struct device_node *dp = dev->node; 224 struct device_node *dp = dev->node;
184 struct resource res; 225 struct resource res;
@@ -307,12 +348,14 @@ static int __devinit of_flash_probe(struct of_device *dev,
307 goto err_out; 348 goto err_out;
308 349
309#ifdef CONFIG_MTD_PARTITIONS 350#ifdef CONFIG_MTD_PARTITIONS
310 /* First look for RedBoot table or partitions on the command 351 part_probe_types = of_get_probes(dp);
311 * line, these take precedence over device tree information */
312 err = parse_mtd_partitions(info->cmtd, part_probe_types, 352 err = parse_mtd_partitions(info->cmtd, part_probe_types,
313 &info->parts, 0); 353 &info->parts, 0);
314 if (err < 0) 354 if (err < 0) {
355 of_free_probes(part_probe_types);
315 return err; 356 return err;
357 }
358 of_free_probes(part_probe_types);
316 359
317#ifdef CONFIG_MTD_OF_PARTS 360#ifdef CONFIG_MTD_OF_PARTS
318 if (err == 0) { 361 if (err == 0) {