[PATCH v2 00/25] mtd: nand: refactor the NAND subsystem (part 1)

Boris Brezillon boris.brezillon at free-electrons.com
Tue Dec 1 03:02:57 PST 2015


Hello,

This huge series aims at clarifying the relationship between the mtd and
nand_chip structures and hiding NAND framework internals to NAND
controller drivers.

The first part of the series provide an mtd_to_nand() helper to hide the
way mtd and nand_chip are linked together.

The second part of the series embeds the mtd structure into the nand_chip
one so that NAND controller drivers don't have to bother allocating the
MTD device and linking it with the NAND chip.

The last part of the series hides accesses to the chip->priv field behind
two helper functions.

This allows removal of some of the boilerplate code done in all NAND
controller drivers, but most importantly, it unifies a bit the way NAND
chip structures are instantiated (even though we still have two different
kinds of drivers: those embedding the nand_chip struct into their private
nand chip representation, and those allocating two different structures
and linking them together with the chip->priv field).

As said in the title, this refactoring is only the first step. I plan to
rework the NAND controller / NAND chip separation for pretty much the same
reasons: clarifying the separation between the two concepts, and getting
rid of more boilerplate code in NAND controller drivers.

Stay tuned ;-).

Best Regards,

Boris

Changes since v1:
- dropped already applied patches
- fixed some typos
- manually fixed some modifications omitted by the coccinelle scripts
- manually reworked modifactions done by coccinelle scripts to improve
  readability and fix coding style issues

Boris Brezillon (25):
  ARM: nand: make use of mtd_to_nand() where appropriate
  blackfin: nand: make use of mtd_to_nand() where appropriate
  cris: nand: make use of mtd_to_nand() where appropriate
  mips: nand: make use of mtd_to_nand() where appropriate
  sh: nand: make use of mtd_to_nand() where appropriate
  mtd: nand: make use of mtd_to_nand() in NAND core code
  mtd: nand: make use of mtd_to_nand() in NAND drivers
  staging: mt29f_spinand: make use of mtd_to_nand()
  mtd: nand: embed an mtd_info structure into nand_chip
  mtd: nand: add nand_to_mtd() helper
  coccinelle: nand: detect and correct drivers embedding an mtd_info
    object
  mtd: nand: use the mtd instance embedded in struct nand_chip
  mtd: nand: update the documentation to reflect framework changes
  staging: mt29f_spinand: use the mtd instance embedded in struct
    nand_chip
  cris: nand: use the mtd instance embedded in struct nand_chip
  mtd: nand: update mtd_to_nand()
  mtd: nand: remove useless mtd->priv = chip assignments
  cris: nand: remove useless mtd->priv = chip assignments
  staging: mt29f_spinand: remove useless mtd->priv = chip assignment
  mtd: nand: simplify nand_dt_init() usage
  mtd: nand: kill the chip->flash_node field
  mtd: nand: add helpers to access ->priv
  ARM: make use of nand_set/get_controller_data() helpers
  mtd: nand: make use of nand_set/get_controller_data() helpers
  staging: mt29f_spinand: make use of nand_set/get_controller_data()
    helpers

 Documentation/DocBook/mtdnand.tmpl             |  31 +++---
 arch/arm/mach-ep93xx/snappercl15.c             |   4 +-
 arch/arm/mach-ep93xx/ts72xx.c                  |   4 +-
 arch/arm/mach-imx/mach-qong.c                  |   2 +-
 arch/arm/mach-ixp4xx/ixdp425-setup.c           |   6 +-
 arch/arm/mach-omap1/board-nand.c               |   2 +-
 arch/arm/mach-orion5x/ts78xx-setup.c           |   6 +-
 arch/arm/mach-pxa/balloon3.c                   |   2 +-
 arch/arm/mach-pxa/em-x270.c                    |   2 +-
 arch/arm/mach-pxa/palmtx.c                     |   2 +-
 arch/blackfin/mach-bf537/boards/stamp.c        |   2 +-
 arch/blackfin/mach-bf561/boards/acvilon.c      |   2 +-
 arch/cris/arch-v32/drivers/mach-a3/nandflash.c |   8 +-
 arch/cris/arch-v32/drivers/mach-fs/nandflash.c |   8 +-
 arch/mips/alchemy/devboards/db1200.c           |   2 +-
 arch/mips/alchemy/devboards/db1300.c           |   2 +-
 arch/mips/alchemy/devboards/db1550.c           |   2 +-
 arch/mips/pnx833x/common/platform.c            |   2 +-
 arch/mips/rb532/devices.c                      |   2 +-
 arch/sh/boards/mach-migor/setup.c              |   2 +-
 drivers/mtd/nand/ams-delta.c                   |  26 ++---
 drivers/mtd/nand/atmel_nand.c                  | 118 ++++++++++----------
 drivers/mtd/nand/au1550nd.c                    |  40 +++----
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |   1 -
 drivers/mtd/nand/bcm47xxnflash/main.c          |   9 +-
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  34 +++---
 drivers/mtd/nand/bf5xx_nand.c                  |  25 ++---
 drivers/mtd/nand/brcmnand/brcmnand.c           |  54 +++++----
 drivers/mtd/nand/cafe_nand.c                   |  51 +++++----
 drivers/mtd/nand/cmx270_nand.c                 |  20 ++--
 drivers/mtd/nand/cs553x_nand.c                 |  30 +++--
 drivers/mtd/nand/davinci_nand.c                |  37 ++++---
 drivers/mtd/nand/denali.c                      |  67 ++++++-----
 drivers/mtd/nand/denali.h                      |   1 -
 drivers/mtd/nand/diskonchip.c                  | 148 ++++++++++++-------------
 drivers/mtd/nand/docg4.c                       |  91 ++++++++-------
 drivers/mtd/nand/fsl_elbc_nand.c               |  61 +++++-----
 drivers/mtd/nand/fsl_ifc_nand.c                |  71 ++++++------
 drivers/mtd/nand/fsl_upm.c                     |  31 +++---
 drivers/mtd/nand/fsmc_nand.c                   |  69 ++++++------
 drivers/mtd/nand/gpio.c                        |  19 ++--
 drivers/mtd/nand/gpmi-nand/gpmi-lib.c          |   2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c         |  67 ++++++-----
 drivers/mtd/nand/gpmi-nand/gpmi-nand.h         |   1 -
 drivers/mtd/nand/hisi504_nand.c                |  48 ++++----
 drivers/mtd/nand/jz4740_nand.c                 |  14 +--
 drivers/mtd/nand/lpc32xx_mlc.c                 |  32 +++---
 drivers/mtd/nand/lpc32xx_slc.c                 |  42 ++++---
 drivers/mtd/nand/mpc5121_nfc.c                 |  52 +++++----
 drivers/mtd/nand/mxc_nand.c                    |  76 +++++++------
 drivers/mtd/nand/nand_base.c                   | 102 +++++++++--------
 drivers/mtd/nand/nand_bbt.c                    |  32 +++---
 drivers/mtd/nand/nand_bch.c                    |   4 +-
 drivers/mtd/nand/nand_ecc.c                    |   4 +-
 drivers/mtd/nand/nandsim.c                     |  35 +++---
 drivers/mtd/nand/ndfc.c                        |  53 ++++-----
 drivers/mtd/nand/nuc900_nand.c                 |  25 ++---
 drivers/mtd/nand/omap2.c                       | 109 ++++++++++--------
 drivers/mtd/nand/orion_nand.c                  |  13 +--
 drivers/mtd/nand/pasemi_nand.c                 |  21 ++--
 drivers/mtd/nand/plat_nand.c                   |  16 +--
 drivers/mtd/nand/pxa3xx_nand.c                 |  70 ++++++------
 drivers/mtd/nand/r852.c                        |  41 +++----
 drivers/mtd/nand/r852.h                        |   1 -
 drivers/mtd/nand/s3c2410.c                     |  32 +++---
 drivers/mtd/nand/sh_flctl.c                    |   9 +-
 drivers/mtd/nand/sharpsl.c                     |  23 ++--
 drivers/mtd/nand/sm_common.c                   |   2 +-
 drivers/mtd/nand/socrates_nand.c               |  24 ++--
 drivers/mtd/nand/sunxi_nand.c                  |  40 ++++---
 drivers/mtd/nand/tmio_nand.c                   |  13 ++-
 drivers/mtd/nand/txx9ndfmc.c                   |  25 ++---
 drivers/mtd/nand/vf610_nfc.c                   |   9 +-
 drivers/mtd/nand/xway_nand.c                   |   4 +-
 drivers/staging/mt29f_spinand/mt29f_spinand.c  |  19 ++--
 include/linux/mtd/nand.h                       |  26 ++++-
 include/linux/mtd/sh_flctl.h                   |   3 +-
 scripts/coccinelle/api/nand-priv-no-mtd.cocci  |  91 +++++++++++++++
 78 files changed, 1179 insertions(+), 1097 deletions(-)
 create mode 100644 scripts/coccinelle/api/nand-priv-no-mtd.cocci

-- 
2.1.4




More information about the linux-arm-kernel mailing list