From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 12/25] mtd: nand: use the mtd instance embedded in struct nand_chip
Date: Tue, 1 Dec 2015 14:21:21 -0800 [thread overview]
Message-ID: <20151201222121.GC64635@google.com> (raw)
In-Reply-To: <1448967802-25796-13-git-send-email-boris.brezillon@free-electrons.com>
On Tue, Dec 01, 2015 at 12:03:09PM +0100, Boris Brezillon wrote:
> struct nand_chip now embeds an mtd device. Patch all drivers to make use
> of this mtd instance instead of using the instance embedded in their
> private struct or dynamically allocated.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Cc: Julia Lawall <Julia.Lawall@lip6.fr>
> ---
> Most of those changes were generated with the coccinelle script added
> in commit c671312 "coccinelle: nand: detect and correct drivers embedding
> an mtd_info object"
> ---
> drivers/mtd/nand/ams-delta.c | 13 ++--
> drivers/mtd/nand/atmel_nand.c | 13 ++--
> drivers/mtd/nand/au1550nd.c | 19 ++---
> drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h | 1 -
> drivers/mtd/nand/bcm47xxnflash/main.c | 8 ++-
> drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c | 2 +-
> drivers/mtd/nand/bf5xx_nand.c | 12 ++--
> drivers/mtd/nand/brcmnand/brcmnand.c | 13 ++--
> drivers/mtd/nand/cafe_nand.c | 8 +--
> drivers/mtd/nand/cmx270_nand.c | 11 ++-
> drivers/mtd/nand/cs553x_nand.c | 13 ++--
> drivers/mtd/nand/davinci_nand.c | 30 ++++----
> drivers/mtd/nand/denali.c | 68 ++++++++++--------
> drivers/mtd/nand/denali.h | 1 -
> drivers/mtd/nand/diskonchip.c | 11 ++-
> drivers/mtd/nand/docg4.c | 16 ++---
^^ some errors here too
> drivers/mtd/nand/fsl_elbc_nand.c | 26 ++++---
> drivers/mtd/nand/fsl_ifc_nand.c | 28 ++++----
> drivers/mtd/nand/fsl_upm.c | 28 ++++----
> drivers/mtd/nand/fsmc_nand.c | 56 ++++++++-------
> drivers/mtd/nand/gpio.c | 20 +++---
> drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 2 +-
> drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 20 +++---
> drivers/mtd/nand/gpmi-nand/gpmi-nand.h | 1 -
> drivers/mtd/nand/hisi504_nand.c | 13 ++--
> drivers/mtd/nand/jz4740_nand.c | 9 ++-
> drivers/mtd/nand/lpc32xx_mlc.c | 7 +-
> drivers/mtd/nand/lpc32xx_slc.c | 7 +-
> drivers/mtd/nand/mpc5121_nfc.c | 3 +-
> drivers/mtd/nand/mxc_nand.c | 5 +-
> drivers/mtd/nand/nandsim.c | 12 ++--
> drivers/mtd/nand/ndfc.c | 24 ++++---
> drivers/mtd/nand/nuc900_nand.c | 24 +++----
> drivers/mtd/nand/omap2.c | 98 +++++++++++++++-----------
> drivers/mtd/nand/orion_nand.c | 4 +-
> drivers/mtd/nand/pasemi_nand.c | 12 ++--
> drivers/mtd/nand/plat_nand.c | 15 ++--
> drivers/mtd/nand/pxa3xx_nand.c | 33 ++++-----
> drivers/mtd/nand/r852.c | 34 ++++-----
> drivers/mtd/nand/r852.h | 1 -
> drivers/mtd/nand/s3c2410.c | 23 +++---
> drivers/mtd/nand/sh_flctl.c | 8 +--
> drivers/mtd/nand/sharpsl.c | 22 +++---
> drivers/mtd/nand/socrates_nand.c | 5 +-
> drivers/mtd/nand/sunxi_nand.c | 13 ++--
> drivers/mtd/nand/tmio_nand.c | 10 +--
> drivers/mtd/nand/txx9ndfmc.c | 3 +-
> drivers/mtd/nand/vf610_nfc.c | 8 ++-
> include/linux/mtd/sh_flctl.h | 3 +-
> 49 files changed, 426 insertions(+), 390 deletions(-)
>
...
> diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
> index da93d7f..f8d5e27 100644
> --- a/drivers/mtd/nand/docg4.c
> +++ b/drivers/mtd/nand/docg4.c
> @@ -1305,14 +1305,13 @@ static int __init probe_docg4(struct platform_device *pdev)
> return -EIO;
> }
>
> - len = sizeof(struct mtd_info) + sizeof(struct nand_chip) +
> - sizeof(struct docg4_priv);
> - mtd = kzalloc(len, GFP_KERNEL);
> - if (mtd == NULL) {
> + len = sizeof(struct nand_chip) + sizeof(struct docg4_priv);
> + nand = kzalloc(len, GFP_KERNEL);
> + if (nand == NULL) {
> retval = -ENOMEM;
> goto fail;
> }
> - nand = (struct nand_chip *) (mtd + 1);
> + mtd = nand_to_mtd(nand);
> doc = (struct docg4_priv *) (nand + 1);
> mtd->priv = nand;
> nand->priv = doc;
> @@ -1355,13 +1354,12 @@ static int __init probe_docg4(struct platform_device *pdev)
>
> fail:
> iounmap(virtadr);
> - if (mtd) {
> + if (nand) {
> /* re-declarations avoid compiler warning */
> - struct nand_chip *nand = mtd_to_nand(mtd);
> struct docg4_priv *doc = nand->priv;
> nand_release(mtd); /* deletes partitions and mtd devices */
drivers/mtd/nand/docg4.c: In function ?probe_docg4?:
drivers/mtd/nand/docg4.c:1359:15: warning: ?mtd? may be used uninitialized in this function [-Wmaybe-uninitialized]
nand_release(mtd); /* deletes partitions and mtd devices */
^
> free_bch(doc->bch);
> - kfree(mtd);
> + kfree(nand);
> }
>
> return retval;
> @@ -1372,7 +1370,7 @@ static int __exit cleanup_docg4(struct platform_device *pdev)
> struct docg4_priv *doc = platform_get_drvdata(pdev);
> nand_release(doc->mtd);
> free_bch(doc->bch);
> - kfree(doc->mtd);
> + kfree(mtd_to_nand(doc->mtd));
> iounmap(doc->virtadr);
> return 0;
> }
Brian
next prev parent reply other threads:[~2015-12-01 22:21 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-01 11:02 [PATCH v2 00/25] mtd: nand: refactor the NAND subsystem (part 1) Boris Brezillon
2015-12-01 11:02 ` [PATCH v2 01/25] ARM: nand: make use of mtd_to_nand() where appropriate Boris Brezillon
2015-12-01 11:02 ` [PATCH v2 02/25] blackfin: " Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 03/25] cris: " Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 04/25] mips: " Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 05/25] sh: " Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 06/25] mtd: nand: make use of mtd_to_nand() in NAND core code Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 08/25] staging: mt29f_spinand: make use of mtd_to_nand() Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 09/25] mtd: nand: embed an mtd_info structure into nand_chip Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 10/25] mtd: nand: add nand_to_mtd() helper Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 11/25] coccinelle: nand: detect and correct drivers embedding an mtd_info object Boris Brezillon
2015-12-01 11:17 ` Julia Lawall
2015-12-01 12:27 ` Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 12/25] mtd: nand: use the mtd instance embedded in struct nand_chip Boris Brezillon
2015-12-01 12:28 ` kbuild test robot
2015-12-01 22:15 ` Brian Norris
2015-12-01 22:21 ` Brian Norris [this message]
2015-12-01 11:03 ` [PATCH v2 13/25] mtd: nand: update the documentation to reflect framework changes Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 14/25] staging: mt29f_spinand: use the mtd instance embedded in struct nand_chip Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 15/25] cris: nand: " Boris Brezillon
2015-12-08 8:35 ` Jesper Nilsson
2015-12-01 11:03 ` [PATCH v2 16/25] mtd: nand: update mtd_to_nand() Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 17/25] mtd: nand: remove useless mtd->priv = chip assignments Boris Brezillon
2015-12-01 22:17 ` Brian Norris
2015-12-02 8:53 ` Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 18/25] cris: " Boris Brezillon
2015-12-08 8:32 ` Jesper Nilsson
2015-12-01 11:03 ` [PATCH v2 19/25] staging: mt29f_spinand: remove useless mtd->priv = chip assignment Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 20/25] mtd: nand: simplify nand_dt_init() usage Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 21/25] mtd: nand: kill the chip->flash_node field Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 22/25] mtd: nand: add helpers to access ->priv Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 23/25] ARM: make use of nand_set/get_controller_data() helpers Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 24/25] mtd: nand: " Boris Brezillon
2015-12-01 11:03 ` [PATCH v2 25/25] staging: mt29f_spinand: " Boris Brezillon
2015-12-01 13:03 ` [PATCH v3 12/25] mtd: nand: use the mtd instance embedded in struct nand_chip Boris Brezillon
2015-12-02 8:50 ` [PATCH v3 bis " Boris Brezillon
2015-12-09 0:17 ` Brian Norris
2015-12-09 8:32 ` Boris Brezillon
2015-12-02 8:51 ` [PATCH v3 17/25] mtd: nand: remove useless mtd->priv = chip assignments Boris Brezillon
2015-12-09 0:36 ` [PATCH v2 00/25] mtd: nand: refactor the NAND subsystem (part 1) Brian Norris
2015-12-09 8:15 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151201222121.GC64635@google.com \
--to=computersforpeace@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).