mtd: nand: cmx270: 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=2afd14f9270e4161a1f2528e75ff517c2d23d2f8
Commit: 2afd14f9270e4161a1f2528e75ff517c2d23d2f8
Parent: 8cd65d1a63d272a20bcd51b459b0550da53a80e5
Author: Boris BREZILLON <boris.brezillon at free-electrons.com>
AuthorDate: Thu Dec 10 08:59:56 2015 +0100
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Dec 18 10:53:44 2015 -0800
mtd: nand: cmx270: 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>
[Brian: dropped a defunct comment]
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/nand/cmx270_nand.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
index 43bded6..00fd0e9 100644
--- a/drivers/mtd/nand/cmx270_nand.c
+++ b/drivers/mtd/nand/cmx270_nand.c
@@ -160,10 +160,8 @@ static int __init cmx270_init(void)
gpio_direction_input(GPIO_NAND_RB);
/* Allocate memory for MTD device structure and private data */
- cmx270_nand_mtd = kzalloc(sizeof(struct mtd_info) +
- sizeof(struct nand_chip),
- GFP_KERNEL);
- if (!cmx270_nand_mtd) {
+ this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
+ if (!this) {
ret = -ENOMEM;
goto err_kzalloc;
}
@@ -175,8 +173,7 @@ static int __init cmx270_init(void)
goto err_ioremap;
}
- /* Get pointer to private data */
- this = (struct nand_chip *)(&cmx270_nand_mtd[1]);
+ cmx270_nand_mtd = nand_to_mtd(this);
/* Link the private data with the MTD structure */
cmx270_nand_mtd->owner = THIS_MODULE;
@@ -216,7 +213,7 @@ static int __init cmx270_init(void)
err_scan:
iounmap(cmx270_nand_io);
err_ioremap:
- kfree(cmx270_nand_mtd);
+ kfree(this);
err_kzalloc:
gpio_free(GPIO_NAND_RB);
err_gpio_request:
@@ -240,8 +237,7 @@ static void __exit cmx270_cleanup(void)
iounmap(cmx270_nand_io);
- /* Free the MTD device structure */
- kfree (cmx270_nand_mtd);
+ kfree(mtd_to_nand(cmx270_nand_mtd));
}
module_exit(cmx270_cleanup);
More information about the linux-mtd-cvs
mailing list