mtd: plat_nand.c: use mtd_device_parse_register
Replace custom invocations of parse_mtd_partitions and mtd_device_register with common mtd_device_parse_register call. This would bring: standard handling of all errors, fallback to default partitions, etc. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
c9dd375f55
commit
009c840770
@ -21,8 +21,6 @@ struct plat_nand_data {
|
||||
struct nand_chip chip;
|
||||
struct mtd_info mtd;
|
||||
void __iomem *io_base;
|
||||
int nr_parts;
|
||||
struct mtd_partition *parts;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -100,21 +98,9 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (pdata->chip.part_probe_types) {
|
||||
err = parse_mtd_partitions(&data->mtd,
|
||||
pdata->chip.part_probe_types,
|
||||
&data->parts, 0);
|
||||
if (err > 0) {
|
||||
mtd_device_register(&data->mtd, data->parts, err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (pdata->chip.partitions) {
|
||||
data->parts = pdata->chip.partitions;
|
||||
err = mtd_device_register(&data->mtd, data->parts,
|
||||
pdata->chip.nr_partitions);
|
||||
} else
|
||||
err = mtd_device_register(&data->mtd, NULL, 0);
|
||||
err = mtd_device_parse_register(&data->mtd,
|
||||
pdata->chip.part_probe_types, 0,
|
||||
pdata->chip.partitions, pdata->chip.nr_partitions);
|
||||
|
||||
if (!err)
|
||||
return err;
|
||||
@ -144,8 +130,6 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
||||
nand_release(&data->mtd);
|
||||
if (data->parts && data->parts != pdata->chip.partitions)
|
||||
kfree(data->parts);
|
||||
if (pdata->ctrl.remove)
|
||||
pdata->ctrl.remove(pdev);
|
||||
iounmap(data->io_base);
|
||||
|
Loading…
x
Reference in New Issue
Block a user