Commit 5d073796 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

mtd: nand: docg4: 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 b0c423c7
...@@ -1305,14 +1305,14 @@ static int __init probe_docg4(struct platform_device *pdev) ...@@ -1305,14 +1305,14 @@ static int __init probe_docg4(struct platform_device *pdev)
return -EIO; return -EIO;
} }
len = sizeof(struct mtd_info) + sizeof(struct nand_chip) + len = sizeof(struct nand_chip) + sizeof(struct docg4_priv);
sizeof(struct docg4_priv); nand = kzalloc(len, GFP_KERNEL);
mtd = kzalloc(len, GFP_KERNEL); if (nand == NULL) {
if (mtd == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto fail; goto fail_unmap;
} }
nand = (struct nand_chip *) (mtd + 1);
mtd = nand_to_mtd(nand);
doc = (struct docg4_priv *) (nand + 1); doc = (struct docg4_priv *) (nand + 1);
mtd->priv = nand; mtd->priv = nand;
nand->priv = doc; nand->priv = doc;
...@@ -1354,16 +1354,17 @@ static int __init probe_docg4(struct platform_device *pdev) ...@@ -1354,16 +1354,17 @@ static int __init probe_docg4(struct platform_device *pdev)
return 0; return 0;
fail: fail:
iounmap(virtadr); if (nand) {
if (mtd) {
/* re-declarations avoid compiler warning */ /* re-declarations avoid compiler warning */
struct nand_chip *nand = mtd_to_nand(mtd);
struct docg4_priv *doc = nand->priv; struct docg4_priv *doc = nand->priv;
nand_release(mtd); /* deletes partitions and mtd devices */ nand_release(mtd); /* deletes partitions and mtd devices */
free_bch(doc->bch); free_bch(doc->bch);
kfree(mtd); kfree(nand);
} }
fail_unmap:
iounmap(virtadr);
return retval; return retval;
} }
...@@ -1372,7 +1373,7 @@ static int __exit cleanup_docg4(struct platform_device *pdev) ...@@ -1372,7 +1373,7 @@ static int __exit cleanup_docg4(struct platform_device *pdev)
struct docg4_priv *doc = platform_get_drvdata(pdev); struct docg4_priv *doc = platform_get_drvdata(pdev);
nand_release(doc->mtd); nand_release(doc->mtd);
free_bch(doc->bch); free_bch(doc->bch);
kfree(doc->mtd); kfree(mtd_to_nand(doc->mtd));
iounmap(doc->virtadr); iounmap(doc->virtadr);
return 0; return 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