]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/mtd/ofpart.c
2 * Flash partitions described by the OF (or flattened) device tree
4 * Copyright © 2006 MontaVista Software Inc.
5 * Author: Vitaly Wool <vwool@ru.mvista.com>
7 * Revised to handle newer style flash binding by:
8 * Copyright © 2007 David Gibson, IBM Corporation.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
16 #include <linux/module.h>
17 #include <linux/init.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/slab.h>
21 #include <linux/mtd/partitions.h>
23 int __devinit
of_mtd_parse_partitions(struct device
*dev
,
24 struct device_node
*node
,
25 struct mtd_partition
**pparts
)
28 struct device_node
*pp
;
31 /* First count the subnodes */
34 while ((pp
= of_get_next_child(node
, pp
)))
40 *pparts
= kzalloc(nr_parts
* sizeof(**pparts
), GFP_KERNEL
);
46 while ((pp
= of_get_next_child(node
, pp
))) {
50 reg
= of_get_property(pp
, "reg", &len
);
56 (*pparts
)[i
].offset
= be32_to_cpu(reg
[0]);
57 (*pparts
)[i
].size
= be32_to_cpu(reg
[1]);
59 partname
= of_get_property(pp
, "label", &len
);
61 partname
= of_get_property(pp
, "name", &len
);
62 (*pparts
)[i
].name
= (char *)partname
;
64 if (of_get_property(pp
, "read-only", &len
))
65 (*pparts
)[i
].mask_flags
= MTD_WRITEABLE
;
72 dev_err(dev
, "No valid partition found on %s\n", node
->full_name
);
80 EXPORT_SYMBOL(of_mtd_parse_partitions
);
82 MODULE_LICENSE("GPL");