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

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jan 12 15:59:19 PST 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b0c423c7b630ecfff1e12f7bd7c3c7f0556bebb1
Commit:     b0c423c7b630ecfff1e12f7bd7c3c7f0556bebb1
Parent:     a5cfb4db89bc73e9d35b8a348133fa0b4b99d81e
Author:     Boris BREZILLON <boris.brezillon at free-electrons.com>
AuthorDate: Thu Dec 10 09:00:00 2015 +0100
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Dec 18 10:54:41 2015 -0800

    mtd: nand: diskonchip: 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: Boris Brezillon <boris.brezillon at free-electrons.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/diskonchip.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 5f7bcc8..fff7a4a 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -1556,15 +1556,15 @@ static int __init doc_probe(unsigned long physadr)
 
 	printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr);
 
-	len = sizeof(struct mtd_info) +
-	    sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr));
-	mtd = kzalloc(len, GFP_KERNEL);
-	if (!mtd) {
+	len = sizeof(struct nand_chip) + sizeof(struct doc_priv) +
+	      (2 * sizeof(struct nand_bbt_descr));
+	nand = kzalloc(len, GFP_KERNEL);
+	if (!nand) {
 		ret = -ENOMEM;
 		goto fail;
 	}
 
-	nand			= (struct nand_chip *) (mtd + 1);
+	mtd			= nand_to_mtd(nand);
 	doc			= (struct doc_priv *) (nand + 1);
 	nand->bbt_td		= (struct nand_bbt_descr *) (doc + 1);
 	nand->bbt_md		= nand->bbt_td + 1;
@@ -1615,7 +1615,7 @@ static int __init doc_probe(unsigned long physadr)
 		   haven't yet added it.  This is handled without incident by
 		   mtd_device_unregister, as far as I can tell. */
 		nand_release(mtd);
-		kfree(mtd);
+		kfree(nand);
 		goto fail;
 	}
 
@@ -1650,7 +1650,7 @@ static void release_nanddoc(void)
 		nand_release(mtd);
 		iounmap(doc->virtadr);
 		release_mem_region(doc->physadr, DOC_IOREMAP_LEN);
-		kfree(mtd);
+		kfree(nand);
 	}
 }
 



More information about the linux-mtd-cvs mailing list