Commit ed10f165 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

mtd: nand: nandsim: 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 a008deb1
...@@ -2236,13 +2236,13 @@ static int __init ns_init_module(void) ...@@ -2236,13 +2236,13 @@ static int __init ns_init_module(void)
} }
/* Allocate and initialize mtd_info, nand_chip and nandsim structures */ /* Allocate and initialize mtd_info, nand_chip and nandsim structures */
nsmtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) chip = kzalloc(sizeof(struct nand_chip) + sizeof(struct nandsim),
+ sizeof(struct nandsim), GFP_KERNEL); GFP_KERNEL);
if (!nsmtd) { if (!chip) {
NS_ERR("unable to allocate core structures.\n"); NS_ERR("unable to allocate core structures.\n");
return -ENOMEM; return -ENOMEM;
} }
chip = (struct nand_chip *)(nsmtd + 1); nsmtd = nand_to_mtd(chip);
nsmtd->priv = (void *)chip; nsmtd->priv = (void *)chip;
nand = (struct nandsim *)(chip + 1); nand = (struct nandsim *)(chip + 1);
chip->priv = (void *)nand; chip->priv = (void *)nand;
...@@ -2392,7 +2392,7 @@ static int __init ns_init_module(void) ...@@ -2392,7 +2392,7 @@ static int __init ns_init_module(void)
for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i) for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
kfree(nand->partitions[i].name); kfree(nand->partitions[i].name);
error: error:
kfree(nsmtd); kfree(chip);
free_lists(); free_lists();
return retval; return retval;
...@@ -2413,7 +2413,7 @@ static void __exit ns_cleanup_module(void) ...@@ -2413,7 +2413,7 @@ static void __exit ns_cleanup_module(void)
nand_release(nsmtd); /* Unregister driver */ nand_release(nsmtd); /* Unregister driver */
for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i) for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
kfree(ns->partitions[i].name); kfree(ns->partitions[i].name);
kfree(nsmtd); /* Free other structures */ kfree(mtd_to_nand(nsmtd)); /* Free other structures */
free_lists(); free_lists();
} }
......
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