Commit 095dd5003f531514170fd1645ab31ed88b56aaf5

Authored by Jamie Iles
Committed by David Woodhouse
1 parent 902766bfdf

mtd: plat-ram: 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>

Showing 1 changed file with 9 additions and 15 deletions Side-by-side Diff

drivers/mtd/maps/plat-ram.c
... ... @@ -94,14 +94,11 @@
94 94 return 0;
95 95  
96 96 if (info->mtd) {
97   -#ifdef CONFIG_MTD_PARTITIONS
  97 + mtd_device_unregister(info->mtd);
98 98 if (info->partitions) {
99   - del_mtd_partitions(info->mtd);
100 99 if (info->free_partitions)
101 100 kfree(info->partitions);
102 101 }
103   -#endif
104   - del_mtd_device(info->mtd);
105 102 map_destroy(info->mtd);
106 103 }
107 104  
... ... @@ -231,7 +228,6 @@
231 228 /* check to see if there are any available partitions, or wether
232 229 * to add this device whole */
233 230  
234   -#ifdef CONFIG_MTD_PARTITIONS
235 231 if (!pdata->nr_partitions) {
236 232 /* try to probe using the supplied probe type */
237 233 if (pdata->probes) {
238 234  
239 235  
... ... @@ -239,23 +235,21 @@
239 235 &info->partitions, 0);
240 236 info->free_partitions = 1;
241 237 if (err > 0)
242   - err = add_mtd_partitions(info->mtd,
  238 + err = mtd_device_register(info->mtd,
243 239 info->partitions, err);
244 240 }
245 241 }
246 242 /* use the static mapping */
247 243 else
248   - err = add_mtd_partitions(info->mtd, pdata->partitions,
249   - pdata->nr_partitions);
250   -#endif /* CONFIG_MTD_PARTITIONS */
251   -
252   - if (add_mtd_device(info->mtd)) {
253   - dev_err(&pdev->dev, "add_mtd_device() failed\n");
254   - err = -ENOMEM;
255   - }
256   -
  244 + err = mtd_device_register(info->mtd, pdata->partitions,
  245 + pdata->nr_partitions);
257 246 if (!err)
258 247 dev_info(&pdev->dev, "registered mtd device\n");
  248 +
  249 + /* add the whole device. */
  250 + err = mtd_device_register(info->mtd, NULL, 0);
  251 + if (err)
  252 + dev_err(&pdev->dev, "failed to register the entire device\n");
259 253  
260 254 return err;
261 255