mirror of https://gitee.com/openkylin/linux.git
mtd: ixp4xx.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
200b8777ce
commit
bc413f11dd
|
@ -145,7 +145,6 @@ static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
|
||||||
struct ixp4xx_flash_info {
|
struct ixp4xx_flash_info {
|
||||||
struct mtd_info *mtd;
|
struct mtd_info *mtd;
|
||||||
struct map_info map;
|
struct map_info map;
|
||||||
struct mtd_partition *partitions;
|
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -168,8 +167,6 @@ static int ixp4xx_flash_remove(struct platform_device *dev)
|
||||||
if (info->map.virt)
|
if (info->map.virt)
|
||||||
iounmap(info->map.virt);
|
iounmap(info->map.virt);
|
||||||
|
|
||||||
kfree(info->partitions);
|
|
||||||
|
|
||||||
if (info->res) {
|
if (info->res) {
|
||||||
release_resource(info->res);
|
release_resource(info->res);
|
||||||
kfree(info->res);
|
kfree(info->res);
|
||||||
|
@ -185,8 +182,6 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
struct flash_platform_data *plat = dev->dev.platform_data;
|
struct flash_platform_data *plat = dev->dev.platform_data;
|
||||||
struct ixp4xx_flash_info *info;
|
struct ixp4xx_flash_info *info;
|
||||||
const char *part_type = NULL;
|
|
||||||
int nr_parts = 0;
|
|
||||||
int err = -1;
|
int err = -1;
|
||||||
|
|
||||||
if (!plat)
|
if (!plat)
|
||||||
|
@ -252,28 +247,12 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
|
||||||
/* Use the fast version */
|
/* Use the fast version */
|
||||||
info->map.write = ixp4xx_write16;
|
info->map.write = ixp4xx_write16;
|
||||||
|
|
||||||
nr_parts = parse_mtd_partitions(info->mtd, probes, &info->partitions,
|
err = mtd_device_parse_register(info->mtd, probes, dev->resource->start,
|
||||||
dev->resource->start);
|
plat->parts, plat->nr_parts);
|
||||||
if (nr_parts > 0) {
|
if (err) {
|
||||||
part_type = "dynamic";
|
|
||||||
} else {
|
|
||||||
info->partitions = plat->parts;
|
|
||||||
nr_parts = plat->nr_parts;
|
|
||||||
part_type = "static";
|
|
||||||
}
|
|
||||||
if (nr_parts == 0)
|
|
||||||
printk(KERN_NOTICE "IXP4xx flash: no partition info "
|
|
||||||
"available, registering whole flash\n");
|
|
||||||
else
|
|
||||||
printk(KERN_NOTICE "IXP4xx flash: using %s partition "
|
|
||||||
"definition\n", part_type);
|
|
||||||
|
|
||||||
err = mtd_device_register(info->mtd, info->partitions, nr_parts);
|
|
||||||
if (err)
|
|
||||||
printk(KERN_ERR "Could not parse partitions\n");
|
printk(KERN_ERR "Could not parse partitions\n");
|
||||||
|
|
||||||
if (err)
|
|
||||||
goto Error;
|
goto Error;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue