From 4bd4ebcc540c35d4477b098cf26394f976551464 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Tue, 1 Dec 2015 12:03:04 +0100 Subject: mtd: nand: make use of mtd_to_nand() in NAND drivers mtd_to_nand() was recently introduced to avoid direct accesses to the mtd->priv field. Update all NAND drivers to use it. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/mtd/nand/cmx270_nand.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/mtd/nand/cmx270_nand.c') diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c index 66ec95e..43bded6 100644 --- a/drivers/mtd/nand/cmx270_nand.c +++ b/drivers/mtd/nand/cmx270_nand.c @@ -53,7 +53,7 @@ static struct mtd_partition partition_info[] = { static u_char cmx270_read_byte(struct mtd_info *mtd) { - struct nand_chip *this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd); return (readl(this->IO_ADDR_R) >> 16); } @@ -61,7 +61,7 @@ static u_char cmx270_read_byte(struct mtd_info *mtd) static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { int i; - struct nand_chip *this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd); for (i=0; iIO_ADDR_W); @@ -70,7 +70,7 @@ static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len) static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len) { int i; - struct nand_chip *this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd); for (i=0; iIO_ADDR_R) >> 16; @@ -94,7 +94,7 @@ static void nand_cs_off(void) static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, unsigned int ctrl) { - struct nand_chip* this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd); unsigned int nandaddr = (unsigned int)this->IO_ADDR_W; dsb(); -- cgit v1.1 From 2afd14f9270e4161a1f2528e75ff517c2d23d2f8 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 08:59:56 +0100 Subject: 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 [Brian: dropped a defunct comment] Signed-off-by: Brian Norris --- drivers/mtd/nand/cmx270_nand.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/mtd/nand/cmx270_nand.c') 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); -- cgit v1.1 From 37f5a54646da0760306ab8570115e20d0ed615f5 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 10 Dec 2015 09:00:34 +0100 Subject: mtd: nand: remove useless mtd->priv = chip assignments mtd_to_nand() now uses the container_of() approach to transform an mtd_info pointer into a nand_chip one. Drop useless mtd->priv assignments from NAND controller drivers. Signed-off-by: Boris Brezillon Signed-off-by: Brian Norris --- drivers/mtd/nand/cmx270_nand.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/mtd/nand/cmx270_nand.c') diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c index 00fd0e9..6f97ebb 100644 --- a/drivers/mtd/nand/cmx270_nand.c +++ b/drivers/mtd/nand/cmx270_nand.c @@ -177,7 +177,6 @@ static int __init cmx270_init(void) /* Link the private data with the MTD structure */ cmx270_nand_mtd->owner = THIS_MODULE; - cmx270_nand_mtd->priv = this; /* insert callbacks */ this->IO_ADDR_R = cmx270_nand_io; -- cgit v1.1