diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2011-05-29 13:32:33 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-11 08:02:10 -0400 |
commit | d26c87d64eff271146b40b66c7de8cfeaf956707 (patch) | |
tree | 7ca79171866e124522212cd92256016db6b8fecf | |
parent | c7975330154af17aecc167b33ca866b6b3d98918 (diff) |
mtd: prepare to convert of_mtd_parse_partitions to partition parser
Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_part_parser_data struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
-rw-r--r-- | drivers/mtd/mtdpart.c | 8 | ||||
-rw-r--r-- | drivers/mtd/ofpart.c | 27 | ||||
-rw-r--r-- | include/linux/mtd/partitions.h | 5 |
3 files changed, 35 insertions, 5 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 34d582c2bdf3..9e8ee054135a 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -729,7 +729,11 @@ EXPORT_SYMBOL_GPL(deregister_mtd_parser); | |||
729 | * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you | 729 | * Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you |
730 | * are changing this array! | 730 | * are changing this array! |
731 | */ | 731 | */ |
732 | static const char *default_mtd_part_types[] = {"cmdlinepart", NULL}; | 732 | static const char *default_mtd_part_types[] = { |
733 | "cmdlinepart", | ||
734 | "ofpart", | ||
735 | NULL | ||
736 | }; | ||
733 | 737 | ||
734 | /** | 738 | /** |
735 | * parse_mtd_partitions - parse MTD partitions | 739 | * parse_mtd_partitions - parse MTD partitions |
@@ -741,7 +745,7 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL}; | |||
741 | * This function tries to find partition on MTD device @master. It uses MTD | 745 | * This function tries to find partition on MTD device @master. It uses MTD |
742 | * partition parsers, specified in @types. However, if @types is %NULL, then | 746 | * partition parsers, specified in @types. However, if @types is %NULL, then |
743 | * the default list of parsers is used. The default list contains only the | 747 | * the default list of parsers is used. The default list contains only the |
744 | * "cmdlinepart" parser ATM. | 748 | * "cmdlinepart" and "ofpart" parsers ATM. |
745 | * | 749 | * |
746 | * This function may return: | 750 | * This function may return: |
747 | * o a negative error code in case of failure | 751 | * o a negative error code in case of failure |
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index a996718fa6b0..7c2c926e0bd7 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c | |||
@@ -20,7 +20,17 @@ | |||
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | 22 | ||
23 | int __devinit of_mtd_parse_partitions(struct device *dev, | 23 | static int parse_ofpart_partitions(struct mtd_info *master, |
24 | struct mtd_partition **pparts, | ||
25 | struct mtd_part_parser_data *data) | ||
26 | { | ||
27 | if (!data || !data->of_node) | ||
28 | return 0; | ||
29 | |||
30 | return of_mtd_parse_partitions(NULL, data->of_node, pparts); | ||
31 | } | ||
32 | |||
33 | int of_mtd_parse_partitions(struct device *dev, | ||
24 | struct device_node *node, | 34 | struct device_node *node, |
25 | struct mtd_partition **pparts) | 35 | struct mtd_partition **pparts) |
26 | { | 36 | { |
@@ -69,7 +79,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev, | |||
69 | 79 | ||
70 | if (!i) { | 80 | if (!i) { |
71 | of_node_put(pp); | 81 | of_node_put(pp); |
72 | dev_err(dev, "No valid partition found on %s\n", node->full_name); | 82 | pr_err("No valid partition found on %s\n", node->full_name); |
73 | kfree(*pparts); | 83 | kfree(*pparts); |
74 | *pparts = NULL; | 84 | *pparts = NULL; |
75 | return -EINVAL; | 85 | return -EINVAL; |
@@ -79,4 +89,17 @@ int __devinit of_mtd_parse_partitions(struct device *dev, | |||
79 | } | 89 | } |
80 | EXPORT_SYMBOL(of_mtd_parse_partitions); | 90 | EXPORT_SYMBOL(of_mtd_parse_partitions); |
81 | 91 | ||
92 | static struct mtd_part_parser ofpart_parser = { | ||
93 | .owner = THIS_MODULE, | ||
94 | .parse_fn = parse_ofpart_partitions, | ||
95 | .name = "ofpart", | ||
96 | }; | ||
97 | |||
98 | static int __init ofpart_parser_init(void) | ||
99 | { | ||
100 | return register_mtd_parser(&ofpart_parser); | ||
101 | } | ||
102 | |||
103 | module_init(ofpart_parser_init); | ||
104 | |||
82 | MODULE_LICENSE("GPL"); | 105 | MODULE_LICENSE("GPL"); |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 5fdb963a5035..ec60fd14670c 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
@@ -51,13 +51,16 @@ struct mtd_partition { | |||
51 | 51 | ||
52 | 52 | ||
53 | struct mtd_info; | 53 | struct mtd_info; |
54 | struct device_node; | ||
54 | 55 | ||
55 | /** | 56 | /** |
56 | * struct mtd_part_parser_data - used to pass data to MTD partition parsers. | 57 | * struct mtd_part_parser_data - used to pass data to MTD partition parsers. |
57 | * @origin: for RedBoot, start address of MTD device | 58 | * @origin: for RedBoot, start address of MTD device |
59 | * @of_node: for OF parsers, device node containing partitioning information | ||
58 | */ | 60 | */ |
59 | struct mtd_part_parser_data { | 61 | struct mtd_part_parser_data { |
60 | unsigned long origin; | 62 | unsigned long origin; |
63 | struct device_node *of_node; | ||
61 | }; | 64 | }; |
62 | 65 | ||
63 | 66 | ||
@@ -85,7 +88,7 @@ struct device; | |||
85 | struct device_node; | 88 | struct device_node; |
86 | 89 | ||
87 | #ifdef CONFIG_MTD_OF_PARTS | 90 | #ifdef CONFIG_MTD_OF_PARTS |
88 | int __devinit of_mtd_parse_partitions(struct device *dev, | 91 | int of_mtd_parse_partitions(struct device *dev, |
89 | struct device_node *node, | 92 | struct device_node *node, |
90 | struct mtd_partition **pparts); | 93 | struct mtd_partition **pparts); |
91 | #else | 94 | #else |