diff options
author | Jamie Iles <jamie@jamieiles.com> | 2011-05-23 05:22:59 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2011-05-24 21:21:33 -0400 |
commit | 98b3979b92143656a2361eb5bdc14f5b50b95bce (patch) | |
tree | 906a94b8ca352b0df2ae3e33a1a6808f100f6153 /drivers/mtd | |
parent | 436c06da0482d7fb4843d3e546196b66433c56e6 (diff) |
mtd: sst25l: convert to mtd_device_register()
Convert to mtd_device_register() and remove the check for
mtd_has_partitions() as we always have partitioning enabled now.
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index ac1d2442e101..1e2c430aaad2 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c | |||
@@ -381,6 +381,8 @@ static int __devinit sst25l_probe(struct spi_device *spi) | |||
381 | struct sst25l_flash *flash; | 381 | struct sst25l_flash *flash; |
382 | struct flash_platform_data *data; | 382 | struct flash_platform_data *data; |
383 | int ret, i; | 383 | int ret, i; |
384 | struct mtd_partition *parts = NULL; | ||
385 | int nr_parts = 0; | ||
384 | 386 | ||
385 | flash_info = sst25l_match_device(spi); | 387 | flash_info = sst25l_match_device(spi); |
386 | if (!flash_info) | 388 | if (!flash_info) |
@@ -420,46 +422,37 @@ static int __devinit sst25l_probe(struct spi_device *spi) | |||
420 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, | 422 | flash->mtd.erasesize, flash->mtd.erasesize / 1024, |
421 | flash->mtd.numeraseregions); | 423 | flash->mtd.numeraseregions); |
422 | 424 | ||
423 | if (mtd_has_partitions()) { | ||
424 | struct mtd_partition *parts = NULL; | ||
425 | int nr_parts = 0; | ||
426 | 425 | ||
427 | if (mtd_has_cmdlinepart()) { | 426 | if (mtd_has_cmdlinepart()) { |
428 | static const char *part_probes[] = | 427 | static const char *part_probes[] = {"cmdlinepart", NULL}; |
429 | {"cmdlinepart", NULL}; | ||
430 | 428 | ||
431 | nr_parts = parse_mtd_partitions(&flash->mtd, | 429 | nr_parts = parse_mtd_partitions(&flash->mtd, |
432 | part_probes, | 430 | part_probes, |
433 | &parts, 0); | 431 | &parts, 0); |
434 | } | 432 | } |
435 | 433 | ||
436 | if (nr_parts <= 0 && data && data->parts) { | 434 | if (nr_parts <= 0 && data && data->parts) { |
437 | parts = data->parts; | 435 | parts = data->parts; |
438 | nr_parts = data->nr_parts; | 436 | nr_parts = data->nr_parts; |
439 | } | 437 | } |
440 | 438 | ||
441 | if (nr_parts > 0) { | 439 | if (nr_parts > 0) { |
442 | for (i = 0; i < nr_parts; i++) { | 440 | for (i = 0; i < nr_parts; i++) { |
443 | DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " | 441 | DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " |
444 | "{.name = %s, .offset = 0x%llx, " | 442 | "{.name = %s, .offset = 0x%llx, " |
445 | ".size = 0x%llx (%lldKiB) }\n", | 443 | ".size = 0x%llx (%lldKiB) }\n", |
446 | i, parts[i].name, | 444 | i, parts[i].name, |
447 | (long long)parts[i].offset, | 445 | (long long)parts[i].offset, |
448 | (long long)parts[i].size, | 446 | (long long)parts[i].size, |
449 | (long long)(parts[i].size >> 10)); | 447 | (long long)(parts[i].size >> 10)); |
450 | } | ||
451 | |||
452 | flash->partitioned = 1; | ||
453 | return add_mtd_partitions(&flash->mtd, | ||
454 | parts, nr_parts); | ||
455 | } | 448 | } |
456 | 449 | ||
457 | } else if (data && data->nr_parts) { | 450 | flash->partitioned = 1; |
458 | dev_warn(&spi->dev, "ignoring %d default partitions on %s\n", | 451 | return mtd_device_register(&flash->mtd, parts, |
459 | data->nr_parts, data->name); | 452 | nr_parts); |
460 | } | 453 | } |
461 | 454 | ||
462 | ret = add_mtd_device(&flash->mtd); | 455 | ret = mtd_device_register(&flash->mtd, NULL, 0); |
463 | if (ret == 1) { | 456 | if (ret == 1) { |
464 | kfree(flash); | 457 | kfree(flash); |
465 | dev_set_drvdata(&spi->dev, NULL); | 458 | dev_set_drvdata(&spi->dev, NULL); |
@@ -474,10 +467,7 @@ static int __devexit sst25l_remove(struct spi_device *spi) | |||
474 | struct sst25l_flash *flash = dev_get_drvdata(&spi->dev); | 467 | struct sst25l_flash *flash = dev_get_drvdata(&spi->dev); |
475 | int ret; | 468 | int ret; |
476 | 469 | ||
477 | if (mtd_has_partitions() && flash->partitioned) | 470 | ret = mtd_device_unregister(&flash->mtd); |
478 | ret = del_mtd_partitions(&flash->mtd); | ||
479 | else | ||
480 | ret = del_mtd_device(&flash->mtd); | ||
481 | if (ret == 0) | 471 | if (ret == 0) |
482 | kfree(flash); | 472 | kfree(flash); |
483 | return ret; | 473 | return ret; |