aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Iles <jamie@jamieiles.com>2011-05-23 05:22:45 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-05-24 21:15:37 -0400
commit984e6d8ec5abe0487e4c3c22d233cd6ba8695cda (patch)
treecc9152e7b1e2a1598fd68f4dcac34da5c4f1035c
parent11b73c8b10e58ae90c12e51be5531007e86a9c66 (diff)
mtd: physmap: convert to mtd_device_register()
Convert to mtd_device_register() and remove the CONFIG_MTD_PARTITIONS preprocessor conditionals as partitioning is always available. Signed-off-by: Jamie Iles <jamie@jamieiles.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/maps/physmap.c34
-rw-r--r--drivers/mtd/maps/physmap_of.c30
-rw-r--r--include/linux/mtd/physmap.h4
3 files changed, 13 insertions, 55 deletions
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 7522df4f71f1..d2059261ca8b 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -27,10 +27,8 @@ struct physmap_flash_info {
27 struct mtd_info *mtd[MAX_RESOURCES]; 27 struct mtd_info *mtd[MAX_RESOURCES];
28 struct mtd_info *cmtd; 28 struct mtd_info *cmtd;
29 struct map_info map[MAX_RESOURCES]; 29 struct map_info map[MAX_RESOURCES];
30#ifdef CONFIG_MTD_PARTITIONS
31 int nr_parts; 30 int nr_parts;
32 struct mtd_partition *parts; 31 struct mtd_partition *parts;
33#endif
34}; 32};
35 33
36static int physmap_flash_remove(struct platform_device *dev) 34static int physmap_flash_remove(struct platform_device *dev)
@@ -47,18 +45,9 @@ static int physmap_flash_remove(struct platform_device *dev)
47 physmap_data = dev->dev.platform_data; 45 physmap_data = dev->dev.platform_data;
48 46
49 if (info->cmtd) { 47 if (info->cmtd) {
50#ifdef CONFIG_MTD_PARTITIONS 48 mtd_device_unregister(info->cmtd);
51 if (info->nr_parts || physmap_data->nr_parts) { 49 if (info->nr_parts)
52 del_mtd_partitions(info->cmtd); 50 kfree(info->parts);
53
54 if (info->nr_parts)
55 kfree(info->parts);
56 } else {
57 del_mtd_device(info->cmtd);
58 }
59#else
60 del_mtd_device(info->cmtd);
61#endif
62 if (info->cmtd != info->mtd[0]) 51 if (info->cmtd != info->mtd[0])
63 mtd_concat_destroy(info->cmtd); 52 mtd_concat_destroy(info->cmtd);
64 } 53 }
@@ -76,9 +65,7 @@ static const char *rom_probe_types[] = {
76 "qinfo_probe", 65 "qinfo_probe",
77 "map_rom", 66 "map_rom",
78 NULL }; 67 NULL };
79#ifdef CONFIG_MTD_PARTITIONS
80static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL }; 68static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
81#endif
82 69
83static int physmap_flash_probe(struct platform_device *dev) 70static int physmap_flash_probe(struct platform_device *dev)
84{ 71{
@@ -164,24 +151,23 @@ static int physmap_flash_probe(struct platform_device *dev)
164 if (err) 151 if (err)
165 goto err_out; 152 goto err_out;
166 153
167#ifdef CONFIG_MTD_PARTITIONS
168 err = parse_mtd_partitions(info->cmtd, part_probe_types, 154 err = parse_mtd_partitions(info->cmtd, part_probe_types,
169 &info->parts, 0); 155 &info->parts, 0);
170 if (err > 0) { 156 if (err > 0) {
171 add_mtd_partitions(info->cmtd, info->parts, err); 157 mtd_device_register(info->cmtd, info->parts, err);
172 info->nr_parts = err; 158 info->nr_parts = err;
173 return 0; 159 return 0;
174 } 160 }
175 161
176 if (physmap_data->nr_parts) { 162 if (physmap_data->nr_parts) {
177 printk(KERN_NOTICE "Using physmap partition information\n"); 163 printk(KERN_NOTICE "Using physmap partition information\n");
178 add_mtd_partitions(info->cmtd, physmap_data->parts, 164 mtd_device_register(info->cmtd, physmap_data->parts,
179 physmap_data->nr_parts); 165 physmap_data->nr_parts);
180 return 0; 166 return 0;
181 } 167 }
182#endif
183 168
184 add_mtd_device(info->cmtd); 169 mtd_device_register(info->cmtd, NULL, 0);
170
185 return 0; 171 return 0;
186 172
187err_out: 173err_out:
@@ -245,14 +231,12 @@ void physmap_configure(unsigned long addr, unsigned long size,
245 physmap_flash_data.set_vpp = set_vpp; 231 physmap_flash_data.set_vpp = set_vpp;
246} 232}
247 233
248#ifdef CONFIG_MTD_PARTITIONS
249void physmap_set_partitions(struct mtd_partition *parts, int num_parts) 234void physmap_set_partitions(struct mtd_partition *parts, int num_parts)
250{ 235{
251 physmap_flash_data.nr_parts = num_parts; 236 physmap_flash_data.nr_parts = num_parts;
252 physmap_flash_data.parts = parts; 237 physmap_flash_data.parts = parts;
253} 238}
254#endif 239#endif
255#endif
256 240
257static int __init physmap_init(void) 241static int __init physmap_init(void)
258{ 242{
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index c1d33464aee8..d251d1db129b 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -34,16 +34,12 @@ struct of_flash_list {
34 34
35struct of_flash { 35struct of_flash {
36 struct mtd_info *cmtd; 36 struct mtd_info *cmtd;
37#ifdef CONFIG_MTD_PARTITIONS
38 struct mtd_partition *parts; 37 struct mtd_partition *parts;
39#endif
40 int list_size; /* number of elements in of_flash_list */ 38 int list_size; /* number of elements in of_flash_list */
41 struct of_flash_list list[0]; 39 struct of_flash_list list[0];
42}; 40};
43 41
44#ifdef CONFIG_MTD_PARTITIONS
45#define OF_FLASH_PARTS(info) ((info)->parts) 42#define OF_FLASH_PARTS(info) ((info)->parts)
46
47static int parse_obsolete_partitions(struct platform_device *dev, 43static int parse_obsolete_partitions(struct platform_device *dev,
48 struct of_flash *info, 44 struct of_flash *info,
49 struct device_node *dp) 45 struct device_node *dp)
@@ -89,10 +85,6 @@ static int parse_obsolete_partitions(struct platform_device *dev,
89 85
90 return nr_parts; 86 return nr_parts;
91} 87}
92#else /* MTD_PARTITIONS */
93#define OF_FLASH_PARTS(info) (0)
94#define parse_partitions(info, dev) (0)
95#endif /* MTD_PARTITIONS */
96 88
97static int of_flash_remove(struct platform_device *dev) 89static int of_flash_remove(struct platform_device *dev)
98{ 90{
@@ -105,17 +97,14 @@ static int of_flash_remove(struct platform_device *dev)
105 dev_set_drvdata(&dev->dev, NULL); 97 dev_set_drvdata(&dev->dev, NULL);
106 98
107 if (info->cmtd != info->list[0].mtd) { 99 if (info->cmtd != info->list[0].mtd) {
108 del_mtd_device(info->cmtd); 100 mtd_device_unregister(info->cmtd);
109 mtd_concat_destroy(info->cmtd); 101 mtd_concat_destroy(info->cmtd);
110 } 102 }
111 103
112 if (info->cmtd) { 104 if (info->cmtd) {
113 if (OF_FLASH_PARTS(info)) { 105 if (OF_FLASH_PARTS(info))
114 del_mtd_partitions(info->cmtd);
115 kfree(OF_FLASH_PARTS(info)); 106 kfree(OF_FLASH_PARTS(info));
116 } else { 107 mtd_device_unregister(info->cmtd);
117 del_mtd_device(info->cmtd);
118 }
119 } 108 }
120 109
121 for (i = 0; i < info->list_size; i++) { 110 for (i = 0; i < info->list_size; i++) {
@@ -172,7 +161,6 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
172 } 161 }
173} 162}
174 163
175#ifdef CONFIG_MTD_PARTITIONS
176/* When partitions are set we look for a linux,part-probe property which 164/* When partitions are set we look for a linux,part-probe property which
177 specifies the list of partition probers to use. If none is given then the 165 specifies the list of partition probers to use. If none is given then the
178 default is use. These take precedence over other device tree 166 default is use. These take precedence over other device tree
@@ -212,14 +200,11 @@ static void __devinit of_free_probes(const char **probes)
212 if (probes != part_probe_types_def) 200 if (probes != part_probe_types_def)
213 kfree(probes); 201 kfree(probes);
214} 202}
215#endif
216 203
217static struct of_device_id of_flash_match[]; 204static struct of_device_id of_flash_match[];
218static int __devinit of_flash_probe(struct platform_device *dev) 205static int __devinit of_flash_probe(struct platform_device *dev)
219{ 206{
220#ifdef CONFIG_MTD_PARTITIONS
221 const char **part_probe_types; 207 const char **part_probe_types;
222#endif
223 const struct of_device_id *match; 208 const struct of_device_id *match;
224 struct device_node *dp = dev->dev.of_node; 209 struct device_node *dp = dev->dev.of_node;
225 struct resource res; 210 struct resource res;
@@ -346,7 +331,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
346 if (err) 331 if (err)
347 goto err_out; 332 goto err_out;
348 333
349#ifdef CONFIG_MTD_PARTITIONS
350 part_probe_types = of_get_probes(dp); 334 part_probe_types = of_get_probes(dp);
351 err = parse_mtd_partitions(info->cmtd, part_probe_types, 335 err = parse_mtd_partitions(info->cmtd, part_probe_types,
352 &info->parts, 0); 336 &info->parts, 0);
@@ -356,13 +340,11 @@ static int __devinit of_flash_probe(struct platform_device *dev)
356 } 340 }
357 of_free_probes(part_probe_types); 341 of_free_probes(part_probe_types);
358 342
359#ifdef CONFIG_MTD_OF_PARTS
360 if (err == 0) { 343 if (err == 0) {
361 err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts); 344 err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts);
362 if (err < 0) 345 if (err < 0)
363 goto err_out; 346 goto err_out;
364 } 347 }
365#endif
366 348
367 if (err == 0) { 349 if (err == 0) {
368 err = parse_obsolete_partitions(dev, info, dp); 350 err = parse_obsolete_partitions(dev, info, dp);
@@ -370,11 +352,7 @@ static int __devinit of_flash_probe(struct platform_device *dev)
370 goto err_out; 352 goto err_out;
371 } 353 }
372 354
373 if (err > 0) 355 mtd_device_register(info->cmtd, info->parts, err);
374 add_mtd_partitions(info->cmtd, info->parts, err);
375 else
376#endif
377 add_mtd_device(info->cmtd);
378 356
379 kfree(mtd_list); 357 kfree(mtd_list);
380 358
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
index bcfd9f777454..e963b86e296b 100644
--- a/include/linux/mtd/physmap.h
+++ b/include/linux/mtd/physmap.h
@@ -35,8 +35,6 @@ struct physmap_flash_data {
35void physmap_configure(unsigned long addr, unsigned long size, 35void physmap_configure(unsigned long addr, unsigned long size,
36 int bankwidth, void (*set_vpp)(struct map_info *, int) ); 36 int bankwidth, void (*set_vpp)(struct map_info *, int) );
37 37
38#ifdef CONFIG_MTD_PARTITIONS
39
40/* 38/*
41 * Machines that wish to do flash partition may want to call this function in 39 * Machines that wish to do flash partition may want to call this function in
42 * their setup routine. 40 * their setup routine.
@@ -48,6 +46,4 @@ void physmap_configure(unsigned long addr, unsigned long size,
48 */ 46 */
49void physmap_set_partitions(struct mtd_partition *parts, int num_parts); 47void physmap_set_partitions(struct mtd_partition *parts, int num_parts);
50 48
51#endif /* defined(CONFIG_MTD_PARTITIONS) */
52
53#endif /* __LINUX_MTD_PHYSMAP__ */ 49#endif /* __LINUX_MTD_PHYSMAP__ */