Commit 478d51f0 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

mtd: nand: fsl_upm: use the mtd instance embedded in struct nand_chip

struct nand_chip now embeds an mtd device. Make use of this mtd instance.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 5e9fb93d
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
struct fsl_upm_nand { struct fsl_upm_nand {
struct device *dev; struct device *dev;
struct mtd_info mtd;
struct nand_chip chip; struct nand_chip chip;
int last_ctrl; int last_ctrl;
struct mtd_partition *parts; struct mtd_partition *parts;
...@@ -49,7 +48,8 @@ struct fsl_upm_nand { ...@@ -49,7 +48,8 @@ struct fsl_upm_nand {
static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo) 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) static int fun_chip_ready(struct mtd_info *mtd)
...@@ -66,9 +66,10 @@ 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) static void fun_wait_rnb(struct fsl_upm_nand *fun)
{ {
if (fun->rnb_gpio[fun->mchip_number] >= 0) { if (fun->rnb_gpio[fun->mchip_number] >= 0) {
struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int cnt = 1000000; int cnt = 1000000;
while (--cnt && !fun_chip_ready(&fun->mtd)) while (--cnt && !fun_chip_ready(mtd))
cpu_relax(); cpu_relax();
if (!cnt) if (!cnt)
dev_err(fun->dev, "tired waiting for RNB\n"); dev_err(fun->dev, "tired waiting for RNB\n");
...@@ -157,6 +158,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -157,6 +158,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
const struct device_node *upm_np, const struct device_node *upm_np,
const struct resource *io_res) const struct resource *io_res)
{ {
struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int ret; int ret;
struct device_node *flash_np; struct device_node *flash_np;
...@@ -174,30 +176,30 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -174,30 +176,30 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
if (fun->rnb_gpio[0] >= 0) if (fun->rnb_gpio[0] >= 0)
fun->chip.dev_ready = fun_chip_ready; fun->chip.dev_ready = fun_chip_ready;
fun->mtd.priv = &fun->chip; mtd->priv = &fun->chip;
fun->mtd.dev.parent = fun->dev; mtd->dev.parent = fun->dev;
flash_np = of_get_next_child(upm_np, NULL); flash_np = of_get_next_child(upm_np, NULL);
if (!flash_np) if (!flash_np)
return -ENODEV; return -ENODEV;
nand_set_flash_node(&fun->chip, flash_np); nand_set_flash_node(&fun->chip, flash_np);
fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start,
flash_np->name); flash_np->name);
if (!fun->mtd.name) { if (!mtd->name) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
ret = nand_scan(&fun->mtd, fun->mchip_count); ret = nand_scan(mtd, fun->mchip_count);
if (ret) if (ret)
goto err; goto err;
ret = mtd_device_register(&fun->mtd, NULL, 0); ret = mtd_device_register(mtd, NULL, 0);
err: err:
of_node_put(flash_np); of_node_put(flash_np);
if (ret) if (ret)
kfree(fun->mtd.name); kfree(mtd->name);
return ret; return ret;
} }
...@@ -321,10 +323,11 @@ static int fun_probe(struct platform_device *ofdev) ...@@ -321,10 +323,11 @@ static int fun_probe(struct platform_device *ofdev)
static int fun_remove(struct platform_device *ofdev) static int fun_remove(struct platform_device *ofdev)
{ {
struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev); struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev);
struct mtd_info *mtd = nand_to_mtd(&fun->chip);
int i; int i;
nand_release(&fun->mtd); nand_release(mtd);
kfree(fun->mtd.name); kfree(mtd->name);
for (i = 0; i < fun->mchip_count; i++) { for (i = 0; i < fun->mchip_count; i++) {
if (fun->rnb_gpio[i] < 0) if (fun->rnb_gpio[i] < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment