mtd: fsmc_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. Linus Walleij: fixed compilation breakage Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
committed by
Artem Bityutskiy
parent
6cb03c9cb5
commit
0d04eda143
@@ -146,7 +146,7 @@ static struct mtd_partition partition_info_16KB_blk[] = {
|
|||||||
{
|
{
|
||||||
.name = "Root File System",
|
.name = "Root File System",
|
||||||
.offset = 0x460000,
|
.offset = 0x460000,
|
||||||
.size = 0,
|
.size = MTDPART_SIZ_FULL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ static struct mtd_partition partition_info_128KB_blk[] = {
|
|||||||
{
|
{
|
||||||
.name = "Root File System",
|
.name = "Root File System",
|
||||||
.offset = 0x800000,
|
.offset = 0x800000,
|
||||||
.size = 0,
|
.size = MTDPART_SIZ_FULL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -184,8 +184,6 @@ static struct mtd_partition partition_info_128KB_blk[] = {
|
|||||||
* @pid: Part ID on the AMBA PrimeCell format
|
* @pid: Part ID on the AMBA PrimeCell format
|
||||||
* @mtd: MTD info for a NAND flash.
|
* @mtd: MTD info for a NAND flash.
|
||||||
* @nand: Chip related info for a NAND flash.
|
* @nand: Chip related info for a NAND flash.
|
||||||
* @partitions: Partition info for a NAND Flash.
|
|
||||||
* @nr_partitions: Total number of partition of a NAND flash.
|
|
||||||
*
|
*
|
||||||
* @ecc_place: ECC placing locations in oobfree type format.
|
* @ecc_place: ECC placing locations in oobfree type format.
|
||||||
* @bank: Bank number for probed device.
|
* @bank: Bank number for probed device.
|
||||||
@@ -200,8 +198,6 @@ struct fsmc_nand_data {
|
|||||||
u32 pid;
|
u32 pid;
|
||||||
struct mtd_info mtd;
|
struct mtd_info mtd;
|
||||||
struct nand_chip nand;
|
struct nand_chip nand;
|
||||||
struct mtd_partition *partitions;
|
|
||||||
unsigned int nr_partitions;
|
|
||||||
|
|
||||||
struct fsmc_eccplace *ecc_place;
|
struct fsmc_eccplace *ecc_place;
|
||||||
unsigned int bank;
|
unsigned int bank;
|
||||||
@@ -717,57 +713,13 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
|
|||||||
* Check for partition info passed
|
* Check for partition info passed
|
||||||
*/
|
*/
|
||||||
host->mtd.name = "nand";
|
host->mtd.name = "nand";
|
||||||
host->nr_partitions = parse_mtd_partitions(&host->mtd, NULL,
|
ret = mtd_device_parse_register(&host->mtd, NULL, 0,
|
||||||
&host->partitions, 0);
|
host->mtd.size <= 0x04000000 ?
|
||||||
if (host->nr_partitions <= 0) {
|
partition_info_16KB_blk :
|
||||||
/*
|
partition_info_128KB_blk,
|
||||||
* Check if partition info passed via command line
|
host->mtd.size <= 0x04000000 ?
|
||||||
*/
|
ARRAY_SIZE(partition_info_16KB_blk) :
|
||||||
if (pdata->partitions) {
|
ARRAY_SIZE(partition_info_128KB_blk));
|
||||||
host->partitions = pdata->partitions;
|
|
||||||
host->nr_partitions = pdata->nr_partitions;
|
|
||||||
} else {
|
|
||||||
struct mtd_partition *partition;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Select the default partitions info */
|
|
||||||
switch (host->mtd.size) {
|
|
||||||
case 0x01000000:
|
|
||||||
case 0x02000000:
|
|
||||||
case 0x04000000:
|
|
||||||
host->partitions = partition_info_16KB_blk;
|
|
||||||
host->nr_partitions =
|
|
||||||
sizeof(partition_info_16KB_blk) /
|
|
||||||
sizeof(struct mtd_partition);
|
|
||||||
break;
|
|
||||||
case 0x08000000:
|
|
||||||
case 0x10000000:
|
|
||||||
case 0x20000000:
|
|
||||||
case 0x40000000:
|
|
||||||
host->partitions = partition_info_128KB_blk;
|
|
||||||
host->nr_partitions =
|
|
||||||
sizeof(partition_info_128KB_blk) /
|
|
||||||
sizeof(struct mtd_partition);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -ENXIO;
|
|
||||||
pr_err("Unsupported NAND size\n");
|
|
||||||
goto err_probe;
|
|
||||||
}
|
|
||||||
|
|
||||||
partition = host->partitions;
|
|
||||||
for (i = 0; i < host->nr_partitions; i++, partition++) {
|
|
||||||
if (partition->size == 0) {
|
|
||||||
partition->size = host->mtd.size -
|
|
||||||
partition->offset;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = mtd_device_register(&host->mtd, host->partitions,
|
|
||||||
host->nr_partitions);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_probe;
|
goto err_probe;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user