Commit 8cd65d1a authored by Boris BREZILLON's avatar Boris BREZILLON Committed by Brian Norris

mtd: nand: cs553x: 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 e787dfd1
...@@ -197,14 +197,13 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) ...@@ -197,14 +197,13 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
} }
/* Allocate memory for MTD device structure and private data */ /* Allocate memory for MTD device structure and private data */
new_mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
if (!new_mtd) { if (!this) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
/* Get pointer to private data */ new_mtd = nand_to_mtd(this);
this = (struct nand_chip *)(&new_mtd[1]);
/* Link the private data with the MTD structure */ /* Link the private data with the MTD structure */
new_mtd->priv = this; new_mtd->priv = this;
...@@ -257,7 +256,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) ...@@ -257,7 +256,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
out_ior: out_ior:
iounmap(this->IO_ADDR_R); iounmap(this->IO_ADDR_R);
out_mtd: out_mtd:
kfree(new_mtd); kfree(this);
out: out:
return err; return err;
} }
...@@ -337,19 +336,19 @@ static void __exit cs553x_cleanup(void) ...@@ -337,19 +336,19 @@ static void __exit cs553x_cleanup(void)
if (!mtd) if (!mtd)
continue; continue;
this = mtd_to_nand(cs553x_mtd[i]); this = mtd_to_nand(mtd);
mmio_base = this->IO_ADDR_R; mmio_base = this->IO_ADDR_R;
/* Release resources, unregister device */ /* Release resources, unregister device */
nand_release(cs553x_mtd[i]); nand_release(mtd);
kfree(cs553x_mtd[i]->name); kfree(mtd->name);
cs553x_mtd[i] = NULL; cs553x_mtd[i] = NULL;
/* unmap physical address */ /* unmap physical address */
iounmap(mmio_base); iounmap(mmio_base);
/* Free the MTD device structure */ /* Free the MTD device structure */
kfree(mtd); kfree(this);
} }
} }
......
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