Skip to content

Commit 984e6d8

Browse files
jamieilesDavid Woodhouse
authored andcommitted
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>
1 parent 11b73c8 commit 984e6d8

3 files changed

Lines changed: 13 additions & 55 deletions

File tree

‎drivers/mtd/maps/physmap.c‎

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ struct physmap_flash_info {
2727
struct mtd_info *mtd[MAX_RESOURCES];
2828
struct mtd_info *cmtd;
2929
struct map_info map[MAX_RESOURCES];
30-
#ifdef CONFIG_MTD_PARTITIONS
3130
int nr_parts;
3231
struct mtd_partition *parts;
33-
#endif
3432
};
3533

3634
static int physmap_flash_remove(struct platform_device *dev)
@@ -47,18 +45,9 @@ static int physmap_flash_remove(struct platform_device *dev)
4745
physmap_data = dev->dev.platform_data;
4846

4947
if (info->cmtd) {
50-
#ifdef CONFIG_MTD_PARTITIONS
51-
if (info->nr_parts || physmap_data->nr_parts) {
52-
del_mtd_partitions(info->cmtd);
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
48+
mtd_device_unregister(info->cmtd);
49+
if (info->nr_parts)
50+
kfree(info->parts);
6251
if (info->cmtd != info->mtd[0])
6352
mtd_concat_destroy(info->cmtd);
6453
}
@@ -76,9 +65,7 @@ static const char *rom_probe_types[] = {
7665
"qinfo_probe",
7766
"map_rom",
7867
NULL };
79-
#ifdef CONFIG_MTD_PARTITIONS
8068
static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
81-
#endif
8269

8370
static int physmap_flash_probe(struct platform_device *dev)
8471
{
@@ -164,24 +151,23 @@ static int physmap_flash_probe(struct platform_device *dev)
164151
if (err)
165152
goto err_out;
166153

167-
#ifdef CONFIG_MTD_PARTITIONS
168154
err = parse_mtd_partitions(info->cmtd, part_probe_types,
169-
&info->parts, 0);
155+
&info->parts, 0);
170156
if (err > 0) {
171-
add_mtd_partitions(info->cmtd, info->parts, err);
157+
mtd_device_register(info->cmtd, info->parts, err);
172158
info->nr_parts = err;
173159
return 0;
174160
}
175161

176162
if (physmap_data->nr_parts) {
177163
printk(KERN_NOTICE "Using physmap partition information\n");
178-
add_mtd_partitions(info->cmtd, physmap_data->parts,
179-
physmap_data->nr_parts);
164+
mtd_device_register(info->cmtd, physmap_data->parts,
165+
physmap_data->nr_parts);
180166
return 0;
181167
}
182-
#endif
183168

184-
add_mtd_device(info->cmtd);
169+
mtd_device_register(info->cmtd, NULL, 0);
170+
185171
return 0;
186172

187173
err_out:
@@ -245,14 +231,12 @@ void physmap_configure(unsigned long addr, unsigned long size,
245231
physmap_flash_data.set_vpp = set_vpp;
246232
}
247233

248-
#ifdef CONFIG_MTD_PARTITIONS
249234
void physmap_set_partitions(struct mtd_partition *parts, int num_parts)
250235
{
251236
physmap_flash_data.nr_parts = num_parts;
252237
physmap_flash_data.parts = parts;
253238
}
254239
#endif
255-
#endif
256240

257241
static int __init physmap_init(void)
258242
{

‎drivers/mtd/maps/physmap_of.c‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ struct of_flash_list {
3434

3535
struct of_flash {
3636
struct mtd_info *cmtd;
37-
#ifdef CONFIG_MTD_PARTITIONS
3837
struct mtd_partition *parts;
39-
#endif
4038
int list_size; /* number of elements in of_flash_list */
4139
struct of_flash_list list[0];
4240
};
4341

44-
#ifdef CONFIG_MTD_PARTITIONS
4542
#define OF_FLASH_PARTS(info) ((info)->parts)
46-
4743
static int parse_obsolete_partitions(struct platform_device *dev,
4844
struct of_flash *info,
4945
struct device_node *dp)
@@ -89,10 +85,6 @@ static int parse_obsolete_partitions(struct platform_device *dev,
8985

9086
return nr_parts;
9187
}
92-
#else /* MTD_PARTITIONS */
93-
#define OF_FLASH_PARTS(info) (0)
94-
#define parse_partitions(info, dev) (0)
95-
#endif /* MTD_PARTITIONS */
9688

9789
static int of_flash_remove(struct platform_device *dev)
9890
{
@@ -105,17 +97,14 @@ static int of_flash_remove(struct platform_device *dev)
10597
dev_set_drvdata(&dev->dev, NULL);
10698

10799
if (info->cmtd != info->list[0].mtd) {
108-
del_mtd_device(info->cmtd);
100+
mtd_device_unregister(info->cmtd);
109101
mtd_concat_destroy(info->cmtd);
110102
}
111103

112104
if (info->cmtd) {
113-
if (OF_FLASH_PARTS(info)) {
114-
del_mtd_partitions(info->cmtd);
105+
if (OF_FLASH_PARTS(info))
115106
kfree(OF_FLASH_PARTS(info));
116-
} else {
117-
del_mtd_device(info->cmtd);
118-
}
107+
mtd_device_unregister(info->cmtd);
119108
}
120109

121110
for (i = 0; i < info->list_size; i++) {
@@ -172,7 +161,6 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
172161
}
173162
}
174163

175-
#ifdef CONFIG_MTD_PARTITIONS
176164
/* When partitions are set we look for a linux,part-probe property which
177165
specifies the list of partition probers to use. If none is given then the
178166
default is use. These take precedence over other device tree
@@ -212,14 +200,11 @@ static void __devinit of_free_probes(const char **probes)
212200
if (probes != part_probe_types_def)
213201
kfree(probes);
214202
}
215-
#endif
216203

217204
static struct of_device_id of_flash_match[];
218205
static int __devinit of_flash_probe(struct platform_device *dev)
219206
{
220-
#ifdef CONFIG_MTD_PARTITIONS
221207
const char **part_probe_types;
222-
#endif
223208
const struct of_device_id *match;
224209
struct device_node *dp = dev->dev.of_node;
225210
struct resource res;
@@ -346,7 +331,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
346331
if (err)
347332
goto err_out;
348333

349-
#ifdef CONFIG_MTD_PARTITIONS
350334
part_probe_types = of_get_probes(dp);
351335
err = parse_mtd_partitions(info->cmtd, part_probe_types,
352336
&info->parts, 0);
@@ -356,25 +340,19 @@ static int __devinit of_flash_probe(struct platform_device *dev)
356340
}
357341
of_free_probes(part_probe_types);
358342

359-
#ifdef CONFIG_MTD_OF_PARTS
360343
if (err == 0) {
361344
err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts);
362345
if (err < 0)
363346
goto err_out;
364347
}
365-
#endif
366348

367349
if (err == 0) {
368350
err = parse_obsolete_partitions(dev, info, dp);
369351
if (err < 0)
370352
goto err_out;
371353
}
372354

373-
if (err > 0)
374-
add_mtd_partitions(info->cmtd, info->parts, err);
375-
else
376-
#endif
377-
add_mtd_device(info->cmtd);
355+
mtd_device_register(info->cmtd, info->parts, err);
378356

379357
kfree(mtd_list);
380358

‎include/linux/mtd/physmap.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ struct physmap_flash_data {
3535
void physmap_configure(unsigned long addr, unsigned long size,
3636
int bankwidth, void (*set_vpp)(struct map_info *, int) );
3737

38-
#ifdef CONFIG_MTD_PARTITIONS
39-
4038
/*
4139
* Machines that wish to do flash partition may want to call this function in
4240
* their setup routine.
@@ -48,6 +46,4 @@ void physmap_configure(unsigned long addr, unsigned long size,
4846
*/
4947
void physmap_set_partitions(struct mtd_partition *parts, int num_parts);
5048

51-
#endif /* defined(CONFIG_MTD_PARTITIONS) */
52-
5349
#endif /* __LINUX_MTD_PHYSMAP__ */

0 commit comments

Comments
 (0)