Commit 2afd14f9 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

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: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
[Brian: dropped a defunct comment]
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 8cd65d1a
...@@ -160,10 +160,8 @@ static int __init cmx270_init(void) ...@@ -160,10 +160,8 @@ static int __init cmx270_init(void)
gpio_direction_input(GPIO_NAND_RB); gpio_direction_input(GPIO_NAND_RB);
/* Allocate memory for MTD device structure and private data */ /* Allocate memory for MTD device structure and private data */
cmx270_nand_mtd = kzalloc(sizeof(struct mtd_info) + this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
sizeof(struct nand_chip), if (!this) {
GFP_KERNEL);
if (!cmx270_nand_mtd) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_kzalloc; goto err_kzalloc;
} }
...@@ -175,8 +173,7 @@ static int __init cmx270_init(void) ...@@ -175,8 +173,7 @@ static int __init cmx270_init(void)
goto err_ioremap; goto err_ioremap;
} }
/* Get pointer to private data */ cmx270_nand_mtd = nand_to_mtd(this);
this = (struct nand_chip *)(&cmx270_nand_mtd[1]);
/* Link the private data with the MTD structure */ /* Link the private data with the MTD structure */
cmx270_nand_mtd->owner = THIS_MODULE; cmx270_nand_mtd->owner = THIS_MODULE;
...@@ -216,7 +213,7 @@ static int __init cmx270_init(void) ...@@ -216,7 +213,7 @@ static int __init cmx270_init(void)
err_scan: err_scan:
iounmap(cmx270_nand_io); iounmap(cmx270_nand_io);
err_ioremap: err_ioremap:
kfree(cmx270_nand_mtd); kfree(this);
err_kzalloc: err_kzalloc:
gpio_free(GPIO_NAND_RB); gpio_free(GPIO_NAND_RB);
err_gpio_request: err_gpio_request:
...@@ -240,8 +237,7 @@ static void __exit cmx270_cleanup(void) ...@@ -240,8 +237,7 @@ static void __exit cmx270_cleanup(void)
iounmap(cmx270_nand_io); iounmap(cmx270_nand_io);
/* Free the MTD device structure */ kfree(mtd_to_nand(cmx270_nand_mtd));
kfree (cmx270_nand_mtd);
} }
module_exit(cmx270_cleanup); module_exit(cmx270_cleanup);
......
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