diff options
Diffstat (limited to 'drivers/mtd/devices/sst25l.c')
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 68 |
1 files changed, 29 insertions, 39 deletions
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index c163e619abc9..1e2c430aaad2 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c | |||
@@ -66,7 +66,7 @@ struct flash_info { | |||
66 | 66 | ||
67 | #define to_sst25l_flash(x) container_of(x, struct sst25l_flash, mtd) | 67 | #define to_sst25l_flash(x) container_of(x, struct sst25l_flash, mtd) |
68 | 68 | ||
69 | static struct flash_info __initdata sst25l_flash_info[] = { | 69 | static struct flash_info __devinitdata sst25l_flash_info[] = { |
70 | {"sst25lf020a", 0xbf43, 256, 1024, 4096}, | 70 | {"sst25lf020a", 0xbf43, 256, 1024, 4096}, |
71 | {"sst25lf040a", 0xbf44, 256, 2048, 4096}, | 71 | {"sst25lf040a", 0xbf44, 256, 2048, 4096}, |
72 | }; | 72 | }; |
@@ -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); |
@@ -469,15 +462,12 @@ static int __devinit sst25l_probe(struct spi_device *spi) | |||
469 | return 0; | 462 | return 0; |
470 | } | 463 | } |
471 | 464 | ||
472 | static int __exit sst25l_remove(struct spi_device *spi) | 465 | static int __devexit sst25l_remove(struct spi_device *spi) |
473 | { | 466 | { |
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; |
@@ -490,7 +480,7 @@ static struct spi_driver sst25l_driver = { | |||
490 | .owner = THIS_MODULE, | 480 | .owner = THIS_MODULE, |
491 | }, | 481 | }, |
492 | .probe = sst25l_probe, | 482 | .probe = sst25l_probe, |
493 | .remove = __exit_p(sst25l_remove), | 483 | .remove = __devexit_p(sst25l_remove), |
494 | }; | 484 | }; |
495 | 485 | ||
496 | static int __init sst25l_init(void) | 486 | static int __init sst25l_init(void) |