Commit 098771158813fb391dd6c1c8b907599db91fb0c7
Committed by
David Woodhouse
1 parent
a17f7ca510
Exists in
master
and in
4 other branches
mtd: davinci_nand: convert to mtd_device_register()
Convert to mtd_device_register() and remove the check for mtd_has_partitions() 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 21 additions and 30 deletions Side-by-side Diff
drivers/mtd/nand/davinci_nand.c
... | ... | @@ -530,6 +530,8 @@ |
530 | 530 | int ret; |
531 | 531 | uint32_t val; |
532 | 532 | nand_ecc_modes_t ecc_mode; |
533 | + struct mtd_partition *mtd_parts = NULL; | |
534 | + int mtd_parts_nb = 0; | |
533 | 535 | |
534 | 536 | /* insist on board-specific configuration */ |
535 | 537 | if (!pdata) |
536 | 538 | |
537 | 539 | |
538 | 540 | |
539 | 541 | |
... | ... | @@ -749,41 +751,33 @@ |
749 | 751 | if (ret < 0) |
750 | 752 | goto err_scan; |
751 | 753 | |
752 | - if (mtd_has_partitions()) { | |
753 | - struct mtd_partition *mtd_parts = NULL; | |
754 | - int mtd_parts_nb = 0; | |
754 | + if (mtd_has_cmdlinepart()) { | |
755 | + static const char *probes[] __initconst = { | |
756 | + "cmdlinepart", NULL | |
757 | + }; | |
755 | 758 | |
756 | - if (mtd_has_cmdlinepart()) { | |
757 | - static const char *probes[] __initconst = | |
758 | - { "cmdlinepart", NULL }; | |
759 | + mtd_parts_nb = parse_mtd_partitions(&info->mtd, probes, | |
760 | + &mtd_parts, 0); | |
761 | + } | |
759 | 762 | |
760 | - mtd_parts_nb = parse_mtd_partitions(&info->mtd, probes, | |
761 | - &mtd_parts, 0); | |
762 | - } | |
763 | + if (mtd_parts_nb <= 0) { | |
764 | + mtd_parts = pdata->parts; | |
765 | + mtd_parts_nb = pdata->nr_parts; | |
766 | + } | |
763 | 767 | |
764 | - if (mtd_parts_nb <= 0) { | |
765 | - mtd_parts = pdata->parts; | |
766 | - mtd_parts_nb = pdata->nr_parts; | |
767 | - } | |
768 | - | |
769 | - /* Register any partitions */ | |
770 | - if (mtd_parts_nb > 0) { | |
771 | - ret = add_mtd_partitions(&info->mtd, | |
772 | - mtd_parts, mtd_parts_nb); | |
773 | - if (ret == 0) | |
774 | - info->partitioned = true; | |
775 | - } | |
776 | - | |
777 | - } else if (pdata->nr_parts) { | |
778 | - dev_warn(&pdev->dev, "ignoring %d default partitions on %s\n", | |
779 | - pdata->nr_parts, info->mtd.name); | |
768 | + /* Register any partitions */ | |
769 | + if (mtd_parts_nb > 0) { | |
770 | + ret = mtd_device_register(&info->mtd, mtd_parts, | |
771 | + mtd_parts_nb); | |
772 | + if (ret == 0) | |
773 | + info->partitioned = true; | |
780 | 774 | } |
781 | 775 | |
782 | 776 | /* If there's no partition info, just package the whole chip |
783 | 777 | * as a single MTD device. |
784 | 778 | */ |
785 | 779 | if (!info->partitioned) |
786 | - ret = add_mtd_device(&info->mtd) ? -ENODEV : 0; | |
780 | + ret = mtd_device_register(&info->mtd, NULL, 0) ? -ENODEV : 0; | |
787 | 781 | |
788 | 782 | if (ret < 0) |
789 | 783 | goto err_scan; |
... | ... | @@ -824,10 +818,7 @@ |
824 | 818 | struct davinci_nand_info *info = platform_get_drvdata(pdev); |
825 | 819 | int status; |
826 | 820 | |
827 | - if (mtd_has_partitions() && info->partitioned) | |
828 | - status = del_mtd_partitions(&info->mtd); | |
829 | - else | |
830 | - status = del_mtd_device(&info->mtd); | |
821 | + status = mtd_device_unregister(&info->mtd); | |
831 | 822 | |
832 | 823 | spin_lock_irq(&davinci_nand_lock); |
833 | 824 | if (info->chip.ecc.mode == NAND_ECC_HW_SYNDROME) |