diff options
Diffstat (limited to 'drivers/mtd/nand/fsl_upm.c')
-rw-r--r-- | drivers/mtd/nand/fsl_upm.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c index d326369980c4..cafd12de7276 100644 --- a/drivers/mtd/nand/fsl_upm.c +++ b/drivers/mtd/nand/fsl_upm.c @@ -31,7 +31,6 @@ struct fsl_upm_nand { struct device *dev; - struct mtd_info mtd; struct nand_chip chip; int last_ctrl; struct mtd_partition *parts; @@ -49,7 +48,8 @@ struct fsl_upm_nand { static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo) { - return container_of(mtdinfo, struct fsl_upm_nand, mtd); + return container_of(mtd_to_nand(mtdinfo), struct fsl_upm_nand, + chip); } static int fun_chip_ready(struct mtd_info *mtd) @@ -66,9 +66,10 @@ static int fun_chip_ready(struct mtd_info *mtd) static void fun_wait_rnb(struct fsl_upm_nand *fun) { if (fun->rnb_gpio[fun->mchip_number] >= 0) { + struct mtd_info *mtd = nand_to_mtd(&fun->chip); int cnt = 1000000; - while (--cnt && !fun_chip_ready(&fun->mtd)) + while (--cnt && !fun_chip_ready(mtd)) cpu_relax(); if (!cnt) dev_err(fun->dev, "tired waiting for RNB\n"); @@ -79,7 +80,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun) static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); u32 mar; @@ -109,7 +110,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) static void fun_select_chip(struct mtd_info *mtd, int mchip_nr) { - struct nand_chip *chip = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); if (mchip_nr == -1) { @@ -157,9 +158,9 @@ static int fun_chip_init(struct fsl_upm_nand *fun, const struct device_node *upm_np, const struct resource *io_res) { + struct mtd_info *mtd = nand_to_mtd(&fun->chip); int ret; struct device_node *flash_np; - struct mtd_part_parser_data ppdata; fun->chip.IO_ADDR_R = fun->io_base; fun->chip.IO_ADDR_W = fun->io_base; @@ -175,30 +176,29 @@ static int fun_chip_init(struct fsl_upm_nand *fun, if (fun->rnb_gpio[0] >= 0) fun->chip.dev_ready = fun_chip_ready; - fun->mtd.priv = &fun->chip; - fun->mtd.dev.parent = fun->dev; + mtd->dev.parent = fun->dev; flash_np = of_get_next_child(upm_np, NULL); if (!flash_np) return -ENODEV; - fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, - flash_np->name); - if (!fun->mtd.name) { + nand_set_flash_node(&fun->chip, flash_np); + mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, + flash_np->name); + if (!mtd->name) { ret = -ENOMEM; goto err; } - ret = nand_scan(&fun->mtd, fun->mchip_count); + ret = nand_scan(mtd, fun->mchip_count); if (ret) goto err; - ppdata.of_node = flash_np; - ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0); + ret = mtd_device_register(mtd, NULL, 0); err: of_node_put(flash_np); if (ret) - kfree(fun->mtd.name); + kfree(mtd->name); return ret; } @@ -322,10 +322,11 @@ err1: static int fun_remove(struct platform_device *ofdev) { struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev); + struct mtd_info *mtd = nand_to_mtd(&fun->chip); int i; - nand_release(&fun->mtd); - kfree(fun->mtd.name); + nand_release(mtd); + kfree(mtd->name); for (i = 0; i < fun->mchip_count; i++) { if (fun->rnb_gpio[i] < 0) |