mtd: rawnand: Stop passing mtd_info to drivers
Subsystems (31)
v2 cover mtd: rawnand: Stop passing mtd_info to drivers
Hello,
This is the first set of patches aiming at cleaning the raw NAND API.
This one focuses on inconsistencies we have in the API + the nand_chip and nand_ecc_ctrl interfaces. Some functions/hooks are passed a nand_chip object, some are passed an mtd_info object and some are passed both.
Since mtd_info can be extracted from nand_chip, we can simply always pass a nand_chip and make things consistent. Hopefully with these changes merged we'll stop seeing new drivers reproducing the same mistake (passing both mtd_info and nand_chip or using mtd_info where nand_chip is more appropriate).
For those who want to see what's in the pipe, here is a branch [1] containing all the cleanups I plan to merge.
Not much has changed in this v2. I just rebased on top of nand/next, fixed typos, added A-b/R-b tags, and that's all.
Regards,
Boris
[1]https://github.com/bbrezillon/linux-0day/commits/nand/api-cleanup
Boris Brezillon (23):
mtd: rawnand: plat_nand: Pass a nand_chip object to all
platform_nand_ctrl hooks
mtd: rawnand: Pass a nand_chip object to nand_scan()
mtd: rawnand: Pass a nand_chip object to nand_release()
mtd: rawnand: Pass a nand_chip object to nand_wait_ready()
mtd: rawnand: Pass a nand_chip object to ecc->hwctl()
mtd: rawnand: Pass a nand_chip object to ecc->calculate()
mtd: rawnand: Pass a nand_chip object to ecc->correct()
mtd: rawnand: Pass a nand_chip object to ecc->read_xxx() hooks
mtd: rawnand: Pass a nand_chip object to ecc->write_xxx() hooks
mtd: rawnand: Pass a nand_chip object to chip->read_xxx() hooks
mtd: rawnand: Pass a nand_chip object to chip->write_xxx() hooks
mtd: rawnand: Pass a nand_chip object to chip->select_chip()
mtd: rawnand: Pass a nand_chip object to chip->block_xxx() hooks
mtd: rawnand: Pass a nand_chip object to chip->cmd_ctrl()
mtd: rawnand: Pass a nand_chip object to chip->dev_ready()
mtd: rawnand: Pass a nand_chip object to chip->cmdfunc()
mtd: rawnand: Pass a nand_chip object to chip->waitfunc()
mtd: rawnand: Pass a nand_chip object to chip->erase()
mtd: rawnand: Pass a nand_chip object to chip->{get,set}_features()
mtd: rawnand: Pass a nand_chip object to chip->setup_read_retry()
mtd: rawnand: Pass a nand_chip object to chip->setup_data_interface()
mtd: rawnand: Pass a nand_chip object to all nand_xxx_bbt() helpers
mtd: rawnand: Pass a nand_chip object nand_erase_nand()
Documentation/driver-api/mtdnand.rst | 4 +- arch/arm/mach-ep93xx/snappercl15.c | 7 +- arch/arm/mach-ep93xx/ts72xx.c | 7 +- arch/arm/mach-imx/mach-qong.c | 11 +- arch/arm/mach-ixp4xx/ixdp425-setup.c | 3 +- arch/arm/mach-omap1/board-fsample.c | 2 +- arch/arm/mach-omap1/board-h2.c | 2 +- arch/arm/mach-omap1/board-h3.c | 2 +- arch/arm/mach-omap1/board-nand.c | 3 +- arch/arm/mach-omap1/board-perseus2.c | 2 +- arch/arm/mach-omap1/common.h | 2 +- arch/arm/mach-orion5x/ts78xx-setup.c | 18 +- arch/arm/mach-pxa/balloon3.c | 8 +- arch/arm/mach-pxa/em-x270.c | 5 +- arch/arm/mach-pxa/palmtx.c | 5 +- arch/mips/alchemy/devboards/db1200.c | 5 +- arch/mips/alchemy/devboards/db1300.c | 5 +- arch/mips/alchemy/devboards/db1550.c | 5 +- arch/mips/netlogic/xlr/platform-flash.c | 4 +- arch/mips/pnx833x/common/platform.c | 3 +- arch/mips/rb532/devices.c | 5 +- arch/sh/boards/mach-migor/setup.c | 6 +- drivers/mtd/nand/raw/ams-delta.c | 24 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 74 ++- drivers/mtd/nand/raw/au1550nd.c | 70 ++- drivers/mtd/nand/raw/bcm47xxnflash/main.c | 2 +- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 38 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 78 +-- drivers/mtd/nand/raw/cafe_nand.c | 56 +-- drivers/mtd/nand/raw/cmx270_nand.c | 20 +- drivers/mtd/nand/raw/cs553x_nand.c | 33 +- drivers/mtd/nand/raw/davinci_nand.c | 59 +-- drivers/mtd/nand/raw/denali.c | 87 ++-- drivers/mtd/nand/raw/diskonchip.c | 116 ++--- drivers/mtd/nand/raw/docg4.c | 83 ++-- drivers/mtd/nand/raw/fsl_elbc_nand.c | 52 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 46 +- drivers/mtd/nand/raw/fsl_upm.c | 34 +- drivers/mtd/nand/raw/fsmc_nand.c | 42 +- drivers/mtd/nand/raw/gpio.c | 13 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 3 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 99 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 2 +- drivers/mtd/nand/raw/hisi504_nand.c | 44 +- drivers/mtd/nand/raw/jz4740_nand.c | 39 +- drivers/mtd/nand/raw/jz4780_nand.c | 30 +- drivers/mtd/nand/raw/lpc32xx_mlc.c | 47 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 67 ++- drivers/mtd/nand/raw/marvell_nand.c | 74 ++- drivers/mtd/nand/raw/mpc5121_nfc.c | 40 +- drivers/mtd/nand/raw/mtk_nand.c | 81 ++- drivers/mtd/nand/raw/mxc_nand.c | 85 ++-- drivers/mtd/nand/raw/nand_base.c | 606 ++++++++++------------- drivers/mtd/nand/raw/nand_bbt.c | 21 +- drivers/mtd/nand/raw/nand_bch.c | 10 +- drivers/mtd/nand/raw/nand_ecc.c | 14 +- drivers/mtd/nand/raw/nand_hynix.c | 12 +- drivers/mtd/nand/raw/nand_micron.c | 16 +- drivers/mtd/nand/raw/nand_toshiba.c | 10 +- drivers/mtd/nand/raw/nandsim.c | 28 +- drivers/mtd/nand/raw/ndfc.c | 25 +- drivers/mtd/nand/raw/nuc900_nand.c | 27 +- drivers/mtd/nand/raw/omap2.c | 148 +++--- drivers/mtd/nand/raw/orion_nand.c | 14 +- drivers/mtd/nand/raw/oxnas_nand.c | 19 +- drivers/mtd/nand/raw/pasemi_nand.c | 19 +- drivers/mtd/nand/raw/plat_nand.c | 6 +- drivers/mtd/nand/raw/qcom_nandc.c | 52 +- drivers/mtd/nand/raw/r852.c | 54 +- drivers/mtd/nand/raw/s3c2410.c | 72 +-- drivers/mtd/nand/raw/sh_flctl.c | 40 +- drivers/mtd/nand/raw/sharpsl.c | 24 +- drivers/mtd/nand/raw/sm_common.c | 5 +- drivers/mtd/nand/raw/socrates_nand.c | 32 +- drivers/mtd/nand/raw/sunxi_nand.c | 82 ++- drivers/mtd/nand/raw/tango_nand.c | 67 ++- drivers/mtd/nand/raw/tegra_nand.c | 36 +- drivers/mtd/nand/raw/tmio_nand.c | 53 +- drivers/mtd/nand/raw/txx9ndfmc.c | 38 +- drivers/mtd/nand/raw/vf610_nfc.c | 43 +- drivers/mtd/nand/raw/xway_nand.c | 27 +- drivers/staging/mt29f_spinand/mt29f_spinand.c | 33 +- include/linux/mtd/nand_bch.h | 11 +- include/linux/mtd/nand_ecc.h | 8 +- include/linux/mtd/rawnand.h | 142 +++--- 85 files changed, 1617 insertions(+), 1829 deletions(-)
Signature · 1 line
2.14.1
PATCH v2 1/23 mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks
Let's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
In order to do that, we first need to update the platform_nand_ctrl hooks to take a nand_chip object instead of an mtd_info.
We add temporary plat_nand_xxx() wrappers to the do the mtd -> chip conversion, but those will be dropped when patching nand_chip hooks to take a nand_chip object.
---
Changes in v2:
- Fix commit message
- Add R-b/A-b tags
--- arch/arm/mach-ep93xx/snappercl15.c | 7 ++-- arch/arm/mach-ep93xx/ts72xx.c | 7 ++-- arch/arm/mach-imx/mach-qong.c | 11 +++---- arch/arm/mach-ixp4xx/ixdp425-setup.c | 3 +- arch/arm/mach-omap1/board-fsample.c | 2 +- arch/arm/mach-omap1/board-h2.c | 2 +- arch/arm/mach-omap1/board-h3.c | 2 +- arch/arm/mach-omap1/board-nand.c | 3 +- arch/arm/mach-omap1/board-perseus2.c | 2 +- arch/arm/mach-omap1/common.h | 2 +- arch/arm/mach-orion5x/ts78xx-setup.c | 18 ++++------- arch/arm/mach-pxa/balloon3.c | 8 ++--- arch/arm/mach-pxa/em-x270.c | 5 ++- arch/arm/mach-pxa/palmtx.c | 5 ++- arch/mips/alchemy/devboards/db1200.c | 5 ++- arch/mips/alchemy/devboards/db1300.c | 5 ++- arch/mips/alchemy/devboards/db1550.c | 5 ++- arch/mips/netlogic/xlr/platform-flash.c | 4 +-- arch/mips/pnx833x/common/platform.c | 3 +- arch/mips/rb532/devices.c | 5 ++- arch/sh/boards/mach-migor/setup.c | 6 ++-- drivers/mtd/nand/raw/plat_nand.c | 57 ++++++++++++++++++++++++++++++--- include/linux/mtd/rawnand.h | 10 +++--- 23 files changed, 101 insertions(+), 76 deletions(-)
arch/arm/mach-ep93xx/snappercl15.c +2 -5
@@ -45,10 +45,9 @@#define NAND_CTRL_ADDR (chip) (chip->IO_ADDR_W + 0x40) -static void snappercl15_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void snappercl15_nand_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);static u16 nand_state =SNAPPERCL15_NAND_WPN ;u16 set;
@@ -73,10 +72,8 @@ static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,__raw_writew ((cmd &0xff ) | nand_state, chip->IO_ADDR_W); } -static int snappercl15_nand_dev_ready (struct mtd_info *mtd) +static int snappercl15_nand_dev_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd); -return !!(__raw_readw (NAND_CTRL_ADDR (chip)) &SNAPPERCL15_NAND_RDY ); }
arch/arm/mach-ep93xx/ts72xx.c +2 -5
@@ -76,11 +76,9 @@ static void __init ts72xx_map_io(void)#define TS72XX_NAND_CONTROL_ADDR_LINE 22/* 0xN0400000 */ #define TS72XX_NAND_BUSY_ADDR_LINE 23/* 0xN0800000 */ -static void ts72xx_nand_hwcontrol (struct mtd_info *mtd, +static void ts72xx_nand_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd); -if (ctrl &NAND_CTRL_CHANGE ) {void __iomem *addr = chip->IO_ADDR_R;unsigned char bits;
@@ -99,9 +97,8 @@ static void ts72xx_nand_hwcontrol(struct mtd_info *mtd,__raw_writeb (cmd, chip->IO_ADDR_W); } -static int ts72xx_nand_device_ready (struct mtd_info *mtd) +static int ts72xx_nand_device_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);void __iomem *addr = chip->IO_ADDR_R; addr += (1 <<TS72XX_NAND_BUSY_ADDR_LINE );
arch/arm/mach-imx/mach-qong.c +5 -6
@@ -129,10 +129,9 @@ static void qong_init_nor_mtd(void)/* * Hardware specific access to control-lines */ -static void qong_nand_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void qong_nand_cmd_ctrl (struct nand_chip *nand_chip,int cmd, +unsigned int ctrl) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); -if (cmd ==NAND_CMD_NONE )return ;
@@ -145,14 +144,14 @@ static void qong_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)/* * Read the Device Ready pin. */ -static int qong_nand_device_ready (struct mtd_info *mtd) +static int qong_nand_device_ready (struct nand_chip *chip) {return gpio_get_value (IOMUX_TO_GPIO (MX31_PIN_NFRB )); } -static void qong_nand_select_chip (struct mtd_info *mtd,int chip) +static void qong_nand_select_chip (struct nand_chip *chip,int cs) { -if (chip >=0 ) +if (cs >=0 )gpio_set_value (IOMUX_TO_GPIO (MX31_PIN_NFCE_B ),0 );else gpio_set_value (IOMUX_TO_GPIO (MX31_PIN_NFCE_B ),1 );
arch/arm/mach-ixp4xx/ixdp425-setup.c +1 -2
@@ -75,9 +75,8 @@ static struct mtd_partition ixdp425_partitions[] = { };static void -ixdp425_flash_nand_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +ixdp425_flash_nand_cmd_ctrl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);int offset = (int )nand_get_controller_data (this);if (ctrl &NAND_CTRL_CHANGE ) {
arch/arm/mach-omap1/board-fsample.c +1 -1
@@ -186,7 +186,7 @@ static struct platform_device nor_device = {#define FSAMPLE_NAND_RB_GPIO_PIN 62 -static int nand_dev_ready (struct mtd_info *mtd) +static int nand_dev_ready (struct nand_chip *chip) {return gpio_get_value (FSAMPLE_NAND_RB_GPIO_PIN ); }
arch/arm/mach-omap1/board-h2.c +1 -1
@@ -182,7 +182,7 @@ static struct mtd_partition h2_nand_partitions[] = {#define H2_NAND_RB_GPIO_PIN 62 -static int h2_nand_dev_ready (struct mtd_info *mtd) +static int h2_nand_dev_ready (struct nand_chip *chip) {return gpio_get_value (H2_NAND_RB_GPIO_PIN ); }
arch/arm/mach-omap1/board-h3.c +1 -1
@@ -185,7 +185,7 @@ static struct mtd_partition nand_partitions[] = {#define H3_NAND_RB_GPIO_PIN 10 -static int nand_dev_ready (struct mtd_info *mtd) +static int nand_dev_ready (struct nand_chip *chip) {return gpio_get_value (H3_NAND_RB_GPIO_PIN ); }
arch/arm/mach-omap1/board-nand.c +1 -2
@@ -20,9 +20,8 @@#include "common.h" -void omap1_nand_cmd_ctl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +void omap1_nand_cmd_ctl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long mask;if (cmd ==NAND_CMD_NONE )
arch/arm/mach-omap1/board-perseus2.c +1 -1
@@ -144,7 +144,7 @@ static struct platform_device nor_device = {#define P2_NAND_RB_GPIO_PIN 62 -static int nand_dev_ready (struct mtd_info *mtd) +static int nand_dev_ready (struct nand_chip *chip) {return gpio_get_value (P2_NAND_RB_GPIO_PIN ); }
arch/arm/mach-omap1/common.h +1 -1
@@ -82,7 +82,7 @@ void omap1_restart(enum reboot_mode, const char *);extern void __init omap_check_revision (void ); -extern void omap1_nand_cmd_ctl (struct mtd_info *mtd,int cmd, +extern void omap1_nand_cmd_ctl (struct nand_chip *this,int cmd,unsigned int ctrl);extern void omap1_timer_init (void );
arch/arm/mach-orion5x/ts78xx-setup.c +7 -11
@@ -131,11 +131,9 @@ static void ts78xx_ts_rtc_unload(void)* NAND_CLE: bit 1 -> bit 1 * NAND_ALE: bit 2 -> bit 0 */ -static void ts78xx_ts_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void ts78xx_ts_nand_cmd_ctrl (struct nand_chip *this,int cmd, +unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd); -if (ctrl &NAND_CTRL_CHANGE ) {unsigned char bits;
@@ -150,15 +148,14 @@ static void ts78xx_ts_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,writeb (cmd, this->IO_ADDR_W); } -static int ts78xx_ts_nand_dev_ready (struct mtd_info *mtd) +static int ts78xx_ts_nand_dev_ready (struct nand_chip *chip) {return readb (TS_NAND_CTRL ) &0x20 ; } -static void ts78xx_ts_nand_write_buf (struct mtd_info *mtd, -const uint8_t *buf,int len) +static void ts78xx_ts_nand_write_buf (struct nand_chip *chip, +const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);void __iomem *io_base = chip->IO_ADDR_W;unsigned long off = ((unsigned long )buf &3 );int sz;
@@ -182,10 +179,9 @@ static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd,writesb (io_base, buf, len); } -static void ts78xx_ts_nand_read_buf (struct mtd_info *mtd, -uint8_t *buf,int len) +static void ts78xx_ts_nand_read_buf (struct nand_chip *chip, +uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);void __iomem *io_base = chip->IO_ADDR_R;unsigned long off = ((unsigned long )buf &3 );int sz;
arch/arm/mach-pxa/balloon3.c +4 -4
@@ -571,9 +571,9 @@ static inline void balloon3_i2c_init(void) {}* NAND ******************************************************************************/ #if defined(CONFIG_MTD_NAND_PLATFORM )||defined(CONFIG_MTD_NAND_PLATFORM_MODULE ) -static void balloon3_nand_cmd_ctl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void balloon3_nand_cmd_ctl (struct nand_chip *this,int cmd, +unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);uint8_t balloon3_ctl_set =0 , balloon3_ctl_clr =0 ;if (ctrl &NAND_CTRL_CHANGE ) {
@@ -600,7 +600,7 @@ static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctwriteb (cmd, this->IO_ADDR_W); } -static void balloon3_nand_select_chip (struct mtd_info *mtd,int chip) +static void balloon3_nand_select_chip (struct nand_chip *this,int chip) {if (chip <0 || chip >3 )return ;
@@ -616,7 +616,7 @@ static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip) BALLOON3_NAND_CONTROL_REG); } -static int balloon3_nand_dev_ready (struct mtd_info *mtd) +static int balloon3_nand_dev_ready (struct nand_chip *this) {return __raw_readl (BALLOON3_NAND_STAT_REG ) &BALLOON3_NAND_STAT_RNB ; }
arch/arm/mach-pxa/em-x270.c +2 -3
@@ -285,10 +285,9 @@ static void nand_cs_off(void) }/* hardware specific access to control-lines */ -static void em_x270_nand_cmd_ctl (struct mtd_info *mtd,int dat, +static void em_x270_nand_cmd_ctl (struct nand_chip *this,int dat,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long nandaddr = (unsigned long )this->IO_ADDR_W;dsb ();
@@ -317,7 +316,7 @@ static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat, }/* read device ready pin */ -static int em_x270_nand_device_ready (struct mtd_info *mtd) +static int em_x270_nand_device_ready (struct nand_chip *this) {dsb ();
arch/arm/mach-pxa/palmtx.c +2 -3
@@ -247,10 +247,9 @@ static inline void palmtx_keys_init(void) {}******************************************************************************/ #if defined(CONFIG_MTD_NAND_PLATFORM ) || \ defined(CONFIG_MTD_NAND_PLATFORM_MODULE ) -static void palmtx_nand_cmd_ctl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void palmtx_nand_cmd_ctl (struct nand_chip *this,int cmd, +unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);char __iomem *nandaddr = this->IO_ADDR_W;if (cmd ==NAND_CMD_NONE )
arch/mips/alchemy/devboards/db1200.c +2 -3
@@ -197,10 +197,9 @@ static struct i2c_board_info db1200_i2c_devs[] __initdata = {/**********************************************************************/ -static void au1200_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void au1200_nand_cmd_ctrl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long ioaddr = (unsigned long )this->IO_ADDR_W; ioaddr &=0xffffff00 ;
@@ -220,7 +219,7 @@ static void au1200_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, } } -static int au1200_nand_device_ready (struct mtd_info *mtd) +static int au1200_nand_device_ready (struct nand_chip *this) {return alchemy_rdsmem (AU1000_MEM_STSTAT ) &1 ; }
arch/mips/alchemy/devboards/db1300.c +2 -3
@@ -149,10 +149,9 @@ static void __init db1300_gpio_config(void)/**********************************************************************/ -static void au1300_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void au1300_nand_cmd_ctrl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long ioaddr = (unsigned long )this->IO_ADDR_W; ioaddr &=0xffffff00 ;
@@ -172,7 +171,7 @@ static void au1300_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, } } -static int au1300_nand_device_ready (struct mtd_info *mtd) +static int au1300_nand_device_ready (struct nand_chip *this) {return alchemy_rdsmem (AU1000_MEM_STSTAT ) &1 ; }
arch/mips/alchemy/devboards/db1550.c +2 -3
@@ -126,10 +126,9 @@ static struct i2c_board_info db1550_i2c_devs[] __initdata = {/**********************************************************************/ -static void au1550_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void au1550_nand_cmd_ctrl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long ioaddr = (unsigned long )this->IO_ADDR_W; ioaddr &=0xffffff00 ;
@@ -149,7 +148,7 @@ static void au1550_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, } } -static int au1550_nand_device_ready (struct mtd_info *mtd) +static int au1550_nand_device_ready (struct nand_chip *this) {return alchemy_rdsmem (AU1000_MEM_STSTAT ) &1 ; }
arch/mips/netlogic/xlr/platform-flash.c +2 -2
@@ -92,8 +92,8 @@ struct xlr_nand_flash_priv {static struct xlr_nand_flash_priv nand_priv; -static void xlr_nand_ctrl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void xlr_nand_ctrl (struct nand_chip *chip,int cmd, +unsigned int ctrl) {if (ctrl &NAND_CLE ) nlm_write_reg(nand_priv.flash_mmio,
arch/mips/pnx833x/common/platform.c +1 -2
@@ -178,9 +178,8 @@ static struct platform_device pnx833x_sata_device = { };static void -pnx833x_flash_nand_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +pnx833x_flash_nand_cmd_ctrl (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned long nandaddr = (unsigned long )this->IO_ADDR_W;if (cmd ==NAND_CMD_NONE )
arch/mips/rb532/devices.c +2 -3
@@ -141,14 +141,13 @@ static struct platform_device cf_slot0 = { };/* Resources and device for NAND */ -static int rb532_dev_ready (struct mtd_info *mtd) +static int rb532_dev_ready (struct nand_chip *chip) {return gpio_get_value (GPIO_RDY ); } -static void rb532_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void rb532_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);unsigned char orbits, nandbits;if (ctrl &NAND_CTRL_CHANGE ) {
arch/sh/boards/mach-migor/setup.c +2 -4
@@ -165,11 +165,9 @@ static struct mtd_partition migor_nand_flash_partitions[] = { }, }; -static void migor_nand_flash_cmd_ctl (struct mtd_info *mtd,int cmd, +static void migor_nand_flash_cmd_ctl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd); -if (cmd ==NAND_CMD_NONE )return ;
@@ -181,7 +179,7 @@ static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,writeb (cmd, chip->IO_ADDR_W); } -static int migor_nand_flash_ready (struct mtd_info *mtd) +static int migor_nand_flash_ready (struct nand_chip *chip) {return gpio_get_value (GPIO_PTA1 );/* NAND_RBn */ }
drivers/mtd/nand/raw/plat_nand.c +52 -5
69 lines not on this page · raw message
include/linux/mtd/rawnand.h +5 -5
@@ -1595,11 +1595,11 @@ struct platform_device;struct platform_nand_ctrl {int (*probe)(struct platform_device *pdev);void (*remove)(struct platform_device *pdev); -int (*dev_ready)(struct mtd_info *mtd); -void (*select_chip)(struct mtd_info *mtd,int chip); -void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl); -void (*write_buf)(struct mtd_info *mtd,const uint8_t *buf,int len); -void (*read_buf)(struct mtd_info *mtd,uint8_t *buf,int len); +int (*dev_ready)(struct nand_chip *chip); +void (*select_chip)(struct nand_chip *chip,int cs); +void (*cmd_ctrl)(struct nand_chip *chip,int dat,unsigned int ctrl); +void (*write_buf)(struct nand_chip *chip,const uint8_t *buf,int len); +void (*read_buf)(struct nand_chip *chip,uint8_t *buf,int len);void *priv; };
Signature · 1 line
2.14.1
A message that is not in the archive (sent off-list or not yet received): 20180906120535.21255-2-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org
Paul Burton
Acked-byRe: [PATCH v2 01/23] mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks
Hi Boris,
Quoted 11 lines · Boris Brezillon
Let's make the raw NAND API consistent by patching all helpers and hooks to take a
nand_chipobject instead of anmtd_infoone or remove themtd_infoobject when both are passed.In order to do that, we first need to update the
platform_nand_ctrlhooks to take anand_chipobject instead of anmtd_info.We add temporary
plat_nand_xxx()wrappers to the do the mtd -> chip conversion, but those will be dropped when patchingnand_chiphooks to take anand_chipobject.
Quoted 5 lines
Signed-off-by Boris Brezillon <[email protected]>Reviewed-by Alexander Sverdlin <[email protected]>Acked-by Robert Jarzmik <[email protected]>Acked-by Krzysztof Halasa <[email protected]>
Thanks,
Paul
PATCH v2 2/23 mtd: rawnand: Pass a nand_chip object to nand_scan()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers to take a nand_chip object instead of an mtd_info one.
We start with nand_scan().
---
Changes in v2:
- Fix commit message
--- Documentation/driver-api/mtdnand.rst | 2 +- drivers/mtd/nand/raw/ams-delta.c | 2 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- drivers/mtd/nand/raw/au1550nd.c | 2 +- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 2 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 2 +- drivers/mtd/nand/raw/cafe_nand.c | 2 +- drivers/mtd/nand/raw/cmx270_nand.c | 2 +- drivers/mtd/nand/raw/cs553x_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 2 +- drivers/mtd/nand/raw/denali.c | 2 +- drivers/mtd/nand/raw/diskonchip.c | 2 +- drivers/mtd/nand/raw/docg4.c | 2 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_upm.c | 2 +- drivers/mtd/nand/raw/fsmc_nand.c | 2 +- drivers/mtd/nand/raw/gpio.c | 2 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- drivers/mtd/nand/raw/hisi504_nand.c | 2 +- drivers/mtd/nand/raw/jz4740_nand.c | 2 +- drivers/mtd/nand/raw/jz4780_nand.c | 2 +- drivers/mtd/nand/raw/lpc32xx_mlc.c | 2 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 +- drivers/mtd/nand/raw/marvell_nand.c | 2 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 2 +- drivers/mtd/nand/raw/mtk_nand.c | 2 +- drivers/mtd/nand/raw/mxc_nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 21 ++++++++++----------- drivers/mtd/nand/raw/nandsim.c | 2 +- drivers/mtd/nand/raw/ndfc.c | 2 +- drivers/mtd/nand/raw/nuc900_nand.c | 2 +- drivers/mtd/nand/raw/omap2.c | 2 +- drivers/mtd/nand/raw/orion_nand.c | 2 +- drivers/mtd/nand/raw/oxnas_nand.c | 2 +- drivers/mtd/nand/raw/pasemi_nand.c | 2 +- drivers/mtd/nand/raw/plat_nand.c | 2 +- drivers/mtd/nand/raw/qcom_nandc.c | 2 +- drivers/mtd/nand/raw/s3c2410.c | 2 +- drivers/mtd/nand/raw/sh_flctl.c | 2 +- drivers/mtd/nand/raw/sharpsl.c | 2 +- drivers/mtd/nand/raw/sm_common.c | 2 +- drivers/mtd/nand/raw/socrates_nand.c | 2 +- drivers/mtd/nand/raw/sunxi_nand.c | 2 +- drivers/mtd/nand/raw/tango_nand.c | 2 +- drivers/mtd/nand/raw/tegra_nand.c | 2 +- drivers/mtd/nand/raw/tmio_nand.c | 2 +- drivers/mtd/nand/raw/txx9ndfmc.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 2 +- drivers/mtd/nand/raw/xway_nand.c | 2 +- drivers/staging/mt29f_spinand/mt29f_spinand.c | 2 +- include/linux/mtd/rawnand.h | 7 ++++--- 52 files changed, 64 insertions(+), 64 deletions(-)
Documentation/driver-api/mtdnand.rst +1 -1
@@ -246,7 +246,7 @@ necessary information about the device. this->eccmode = NAND_ECC_SOFT; /* Scan to find existence of the device */ - if (nand_scan (board_mtd, 1)) { + if (nand_scan (this, 1)) { err = -ENXIO; goto out_ior; }
drivers/mtd/nand/raw/ams-delta.c +1 -1
@@ -235,7 +235,7 @@ static int ams_delta_init(struct platform_device *pdev) goto out_gpio;/* Scan to find existence of the device */ - err =nand_scan (ams_delta_mtd,1 ); + err =nand_scan (this,1 );if (err) goto out_mtd;
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -1683,7 +1683,7 @@ atmel_nand_controller_add_nand(struct atmel_nand_controller *nc, nc->caps->ops->nand_init (nc, nand); - ret =nand_scan (mtd, nand->numcs); + ret =nand_scan (chip, nand->numcs);if (ret) {dev_err (nc->dev,"NAND scan failed: %d\n" , ret);return ret;
drivers/mtd/nand/raw/au1550nd.c +1 -1
@@ -451,7 +451,7 @@ static int au1550nd_probe(struct platform_device *pdev) this->write_buf = (pd->devwidth) ? au_write_buf16 : au_write_buf; this->read_buf = (pd->devwidth) ? au_read_buf16 : au_read_buf; - ret =nand_scan (mtd,1 ); + ret =nand_scan (this,1 );if (ret) {dev_err (&pdev->dev,"NAND scan failed with %d\n" , ret); goto out3;
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +1 -1
@@ -423,7 +423,7 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n) (w4 << 24 | w3 << 18 | w2 << 12 | w1 << 6 | w0));/* Scan NAND */ - err =nand_scan (nand_to_mtd (&b47n->nand_chip),1 ); + err =nand_scan (&b47n->nand_chip,1 );if (err) {pr_err ("Could not scan NAND flash: %d\n" , err); goto exit;
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -1
@@ -2301,7 +2301,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)nand_writereg (ctrl, cfg_offs,nand_readreg (ctrl, cfg_offs) & ~CFG_BUS_WIDTH ); - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret)return ret;
drivers/mtd/nand/raw/cafe_nand.c +1 -1
@@ -783,7 +783,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,/* Scan to find existence of the device */ cafe->nand.dummy_controller.ops = &cafe_nand_controller_ops; - err =nand_scan (mtd,2 ); + err =nand_scan (&cafe->nand,2 );if (err) goto out_irq;
drivers/mtd/nand/raw/cmx270_nand.c +1 -1
@@ -193,7 +193,7 @@ static int __init cmx270_init(void) this->write_buf = cmx270_write_buf;/* Scan to find existence of the device */ - ret =nand_scan (cmx270_nand_mtd,1 ); + ret =nand_scan (this,1 );if (ret) {pr_notice ("No NAND device\n" ); goto err_scan;
drivers/mtd/nand/raw/cs553x_nand.c +1 -1
@@ -241,7 +241,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) }/* Scan to find existence of the device */ - err =nand_scan (new_mtd,1 ); + err =nand_scan (this,1 );if (err) goto out_free;
drivers/mtd/nand/raw/davinci_nand.c +1 -1
@@ -807,7 +807,7 @@ static int nand_davinci_probe(struct platform_device *pdev)/* Scan to find existence of the device(s) */ info->chip.dummy_controller.ops = &davinci_nand_controller_ops; - ret =nand_scan (mtd, pdata->mask_chipsel ?2 :1 ); + ret =nand_scan (&info->chip, pdata->mask_chipsel ?2 :1 );if (ret <0 ) {dev_dbg (&pdev->dev,"no NAND chip(s) found\n" );return ret;
drivers/mtd/nand/raw/denali.c +1 -1
@@ -1355,7 +1355,7 @@ int denali_init(struct denali_nand_info *denali) chip->setup_data_interface = denali_setup_data_interface; chip->dummy_controller.ops = &denali_controller_ops; - ret =nand_scan (mtd, denali->max_banks); + ret =nand_scan (chip, denali->max_banks);if (ret) goto disable_irq;
drivers/mtd/nand/raw/diskonchip.c +1 -1
@@ -1620,7 +1620,7 @@ static int __init doc_probe(unsigned long physadr)else numchips =doc2001_init (mtd); -if ((ret =nand_scan (mtd, numchips)) || (ret = doc->late_init (mtd))) { +if ((ret =nand_scan (nand, numchips)) || (ret = doc->late_init (mtd))) {/* DBB note: i believe nand_release is necessary here, as buffers may have been allocated in nand_base. Check with Thomas. FIX ME! */
drivers/mtd/nand/raw/docg4.c +1 -1
@@ -1391,7 +1391,7 @@ static int __init probe_docg4(struct platform_device *pdev)* ->attach_chip callback. */ nand->dummy_controller.ops = &docg4_controller_ops; - retval =nand_scan (mtd,0 ); + retval =nand_scan (nand,0 );if (retval) goto free_nand;
drivers/mtd/nand/raw/fsl_elbc_nand.c +1 -1
@@ -915,7 +915,7 @@ static int fsl_elbc_nand_probe(struct platform_device *pdev) goto err; priv->chip.controller->ops = &fsl_elbc_controller_ops; - ret =nand_scan (mtd,1 ); + ret =nand_scan (&priv->chip,1 );if (ret) goto err;
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -1
@@ -1079,7 +1079,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) goto err; priv->chip.controller->ops = &fsl_ifc_controller_ops; - ret =nand_scan (mtd,1 ); + ret =nand_scan (&priv->chip,1 );if (ret) goto err;
drivers/mtd/nand/raw/fsl_upm.c +1 -1
@@ -191,7 +191,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun, goto err; } - ret =nand_scan (mtd, fun->mchip_count); + ret =nand_scan (&fun->chip, fun->mchip_count);if (ret) goto err;
drivers/mtd/nand/raw/fsmc_nand.c +1 -1
@@ -1125,7 +1125,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)* Scan to find existence of the device */ nand->dummy_controller.ops = &fsmc_nand_controller_ops; - ret =nand_scan (mtd,1 ); + ret =nand_scan (nand,1 );if (ret) goto release_dma_write_chan;
drivers/mtd/nand/raw/gpio.c +1 -1
@@ -289,7 +289,7 @@ static int gpio_nand_probe(struct platform_device *pdev)if (gpiomtd->nwp && !IS_ERR (gpiomtd->nwp))gpiod_direction_output (gpiomtd->nwp,1 ); - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret) goto err_wp;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -1
@@ -1934,7 +1934,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) goto err_out; chip->dummy_controller.ops = &gpmi_nand_controller_ops; - ret =nand_scan (mtd,GPMI_IS_MX6 (this) ?2 :1 ); + ret =nand_scan (chip,GPMI_IS_MX6 (this) ?2 :1 );if (ret) goto err_out;
drivers/mtd/nand/raw/hisi504_nand.c +1 -1
@@ -801,7 +801,7 @@ static int hisi_nfc_probe(struct platform_device *pdev) } chip->dummy_controller.ops = &hisi_nfc_controller_ops; - ret =nand_scan (mtd, max_chips); + ret =nand_scan (chip, max_chips);if (ret)return ret;
drivers/mtd/nand/raw/jz4740_nand.c +1 -1
@@ -331,7 +331,7 @@ static int jz_nand_detect_bank(struct platform_device *pdev,if (chipnr ==0 ) {/* Detect first chip. */ - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret) goto notfound_id;
drivers/mtd/nand/raw/jz4780_nand.c +1 -1
@@ -286,7 +286,7 @@ static int jz4780_nand_init_chip(struct platform_device *pdev,nand_set_flash_node (chip, np); chip->controller->ops = &jz4780_nand_controller_ops; - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret)return ret;
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -1
@@ -802,7 +802,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)* SMALL block or LARGE block. */ nand_chip->dummy_controller.ops = &lpc32xx_nand_controller_ops; - res =nand_scan (mtd,1 ); + res =nand_scan (nand_chip,1 );if (res) goto free_irq;
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -1
@@ -925,7 +925,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)/* Find NAND device */ chip->dummy_controller.ops = &lpc32xx_nand_controller_ops; - res =nand_scan (mtd,1 ); + res =nand_scan (chip,1 );if (res) goto release_dma;
drivers/mtd/nand/raw/marvell_nand.c +1 -1
@@ -2605,7 +2605,7 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, chip->options |=NAND_BUSWIDTH_AUTO ; - ret =nand_scan (mtd, marvell_nand->nsels); + ret =nand_scan (chip, marvell_nand->nsels);if (ret) {dev_err (dev,"could not scan the nand chip\n" );return ret;
drivers/mtd/nand/raw/mpc5121_nfc.c +1 -1
@@ -767,7 +767,7 @@ static int mpc5121_nfc_probe(struct platform_device *op) }/* Detect NAND chips */ - retval =nand_scan (mtd,be32_to_cpup (chips_no)); + retval =nand_scan (chip,be32_to_cpup (chips_no));if (retval) {dev_err (dev,"NAND Flash not found !\n" ); goto error;
drivers/mtd/nand/raw/mtk_nand.c +1 -1
@@ -1365,7 +1365,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc,mtk_nfc_hw_init (nfc); - ret =nand_scan (mtd, nsels); + ret =nand_scan (nand, nsels);if (ret)return ret;
drivers/mtd/nand/raw/mxc_nand.c +1 -1
@@ -1887,7 +1887,7 @@ static int mxcnd_probe(struct platform_device *pdev)/* Scan the NAND device */ this->dummy_controller.ops = &mxcnd_controller_ops; - err =nand_scan (mtd,is_imx25_nfc (host) ?4 :1 ); + err =nand_scan (this,is_imx25_nfc (host) ?4 :1 );if (err) goto escan;
drivers/mtd/nand/raw/nand_base.c +10 -11
@@ -5960,7 +5960,7 @@ static int nand_dt_init(struct nand_chip *chip)/** * nand_scan_ident - Scan for the NAND device -* @mtd: MTD device structure +* @chip: NAND chip object * @maxchips: number of chips to scan for * @table: alternative NAND ID table *
@@ -5972,11 +5972,11 @@ static int nand_dt_init(struct nand_chip *chip)* prevented dynamic allocations during this phase which was unconvenient and * as been banned for the benefit of the ->init_ecc()/cleanup_ecc() hooks. */ -static int nand_scan_ident (struct mtd_info *mtd,int maxchips, +static int nand_scan_ident (struct nand_chip *chip,int maxchips,struct nand_flash_dev *table) { +struct mtd_info *mtd =nand_to_mtd (chip);int i, nand_maf_id, nand_dev_id; -struct nand_chip *chip =mtd_to_nand (mtd);int ret;/* Enforce the right timings for reset/detection */
@@ -6430,15 +6430,15 @@ static bool nand_ecc_strength_good(struct mtd_info *mtd)/** * nand_scan_tail - Scan for the NAND device -* @mtd: MTD device structure +* @chip: NAND chip object * * This is the second phase of the normal nand_scan() function. It fills out * all the uninitialized function pointers with the defaults and scans for a * bad block table if appropriate. */ -static int nand_scan_tail (struct mtd_info *mtd) +static int nand_scan_tail (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;int ret, i;
@@ -6777,7 +6777,7 @@ static void nand_detach(struct nand_chip *chip)/** * nand_scan_with_ids - [NAND Interface] Scan for the NAND device -* @mtd: MTD device structure +* @chip: NAND chip object * @maxchips: number of chips to scan for. @nand_scan_ident() will not be run if * this parameter is zero (useful for specific drivers that must * handle this part of the process themselves, e.g docg4).
@@ -6787,14 +6787,13 @@ static void nand_detach(struct nand_chip *chip)* The flash ID is read and the mtd/chip structures are filled with the * appropriate values. */ -int nand_scan_with_ids (struct mtd_info *mtd,int maxchips, +int nand_scan_with_ids (struct nand_chip *chip,int maxchips,struct nand_flash_dev *ids) { -struct nand_chip *chip =mtd_to_nand (mtd);int ret;if (maxchips) { - ret =nand_scan_ident (mtd, maxchips, ids); + ret =nand_scan_ident (chip, maxchips, ids);if (ret)return ret; }
@@ -6803,7 +6802,7 @@ int nand_scan_with_ids(struct mtd_info *mtd, int maxchips,if (ret) goto cleanup_ident; - ret =nand_scan_tail (mtd); + ret =nand_scan_tail (chip);if (ret) goto detach_chip;
drivers/mtd/nand/raw/nandsim.c +1 -1
@@ -2309,7 +2309,7 @@ static int __init ns_init_module(void) goto error; chip->dummy_controller.ops = &ns_controller_ops; - retval =nand_scan (nsmtd,1 ); + retval =nand_scan (chip,1 );if (retval) {NS_ERR ("Could not scan NAND Simulator device\n" ); goto error;
drivers/mtd/nand/raw/ndfc.c +1 -1
@@ -181,7 +181,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc, goto err; } - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret) goto err;
drivers/mtd/nand/raw/nuc900_nand.c +1 -1
@@ -270,7 +270,7 @@ static int nuc900_nand_probe(struct platform_device *pdev)nuc900_nand_enable (nuc900_nand); -if (nand_scan (mtd,1 )) +if (nand_scan (chip,1 ))return -ENXIO ;mtd_device_register (mtd, partitions,ARRAY_SIZE (partitions));
drivers/mtd/nand/raw/omap2.c +1 -1
@@ -2254,7 +2254,7 @@ static int omap_nand_probe(struct platform_device *pdev)/* scan NAND device connected to chip controller */ nand_chip->options |= info->devsize &NAND_BUSWIDTH_16 ; - err =nand_scan (mtd,1 ); + err =nand_scan (nand_chip,1 );if (err) goto return_error;
drivers/mtd/nand/raw/orion_nand.c +1 -1
@@ -174,7 +174,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)return ret; } - ret =nand_scan (mtd,1 ); + ret =nand_scan (nc,1 );if (ret) goto no_dev;
drivers/mtd/nand/raw/oxnas_nand.c +1 -1
@@ -142,7 +142,7 @@ static int oxnas_nand_probe(struct platform_device *pdev) chip->chip_delay =30 ;/* Scan to find existence of the device */ - err =nand_scan (mtd,1 ); + err =nand_scan (chip,1 );if (err) goto err_clk_unprepare;
drivers/mtd/nand/raw/pasemi_nand.c +1 -1
@@ -156,7 +156,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev) chip->bbt_options =NAND_BBT_USE_FLASH ;/* Scan to find existence of the device */ - err =nand_scan (pasemi_nand_mtd,1 ); + err =nand_scan (chip,1 );if (err) goto out_lpc;
drivers/mtd/nand/raw/plat_nand.c +1 -1
@@ -131,7 +131,7 @@ static int plat_nand_probe(struct platform_device *pdev) }/* Scan to find existence of the device */ - err =nand_scan (mtd, pdata->chip.nr_chips); + err =nand_scan (&data->chip, pdata->chip.nr_chips);if (err) goto out;
drivers/mtd/nand/raw/qcom_nandc.c +1 -1
@@ -2834,7 +2834,7 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,/* set up initial status value */ host->status =NAND_STATUS_READY |NAND_STATUS_WP ; - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret)return ret;
drivers/mtd/nand/raw/s3c2410.c +1 -1
@@ -1170,7 +1170,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev) mtd->dev.parent = &pdev->dev;s3c2410_nand_init_chip (info, nmtd, sets); - err =nand_scan (mtd, sets ? sets->nr_chips :1 ); + err =nand_scan (&nmtd->chip, sets ? sets->nr_chips :1 );if (err) goto exit_error;
drivers/mtd/nand/raw/sh_flctl.c +1 -1
@@ -1193,7 +1193,7 @@ static int flctl_probe(struct platform_device *pdev)flctl_setup_dma (flctl); nand->dummy_controller.ops = &flctl_nand_controller_ops; - ret =nand_scan (flctl_mtd,1 ); + ret =nand_scan (nand,1 );if (ret) goto err_chip;
drivers/mtd/nand/raw/sharpsl.c +1 -1
@@ -171,7 +171,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev) this->ecc.correct = nand_correct_data;/* Scan to find existence of the device */ - err =nand_scan (mtd,1 ); + err =nand_scan (this,1 );if (err) goto err_scan;
drivers/mtd/nand/raw/sm_common.c +1 -1
@@ -195,7 +195,7 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia)/* Scan for card properties */ chip->dummy_controller.ops = &sm_controller_ops; flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids; - ret =nand_scan_with_ids (mtd,1 , flash_ids); + ret =nand_scan_with_ids (chip,1 , flash_ids);if (ret)return ret;
drivers/mtd/nand/raw/socrates_nand.c +1 -1
@@ -173,7 +173,7 @@ static int socrates_nand_probe(struct platform_device *ofdev)dev_set_drvdata (&ofdev->dev, host); - res =nand_scan (mtd,1 ); + res =nand_scan (nand_chip,1 );if (res) goto out;
drivers/mtd/nand/raw/sunxi_nand.c +1 -1
@@ -1940,7 +1940,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, mtd =nand_to_mtd (nand); mtd->dev.parent = dev; - ret =nand_scan (mtd, nsels); + ret =nand_scan (nand, nsels);if (ret)return ret;
drivers/mtd/nand/raw/tango_nand.c +1 -1
@@ -588,7 +588,7 @@ static int chip_init(struct device *dev, struct device_node *np)mtd_set_ooblayout (mtd, &tango_nand_ooblayout_ops); mtd->dev.parent = dev; - err =nand_scan (mtd,1 ); + err =nand_scan (chip,1 );if (err)return err;
drivers/mtd/nand/raw/tegra_nand.c +1 -1
@@ -1119,7 +1119,7 @@ static int tegra_nand_chips_init(struct device *dev, chip->select_chip = tegra_nand_select_chip; chip->setup_data_interface = tegra_nand_setup_data_interface; - ret =nand_scan (mtd,1 ); + ret =nand_scan (chip,1 );if (ret)return ret;
drivers/mtd/nand/raw/tmio_nand.c +1 -1
@@ -436,7 +436,7 @@ static int tmio_probe(struct platform_device *dev) nand_chip->waitfunc = tmio_nand_wait;/* Scan to find existence of the device */ - retval =nand_scan (mtd,1 ); + retval =nand_scan (nand_chip,1 );if (retval) goto err_irq;
drivers/mtd/nand/raw/txx9ndfmc.c +1 -1
@@ -359,7 +359,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)if (plat->wide_mask & (1 << i)) chip->options |=NAND_BUSWIDTH_16 ; -if (nand_scan (mtd,1 )) { +if (nand_scan (chip,1 )) {kfree (txx9_priv->mtdname);kfree (txx9_priv);continue ;
drivers/mtd/nand/raw/vf610_nfc.c +1 -1
@@ -892,7 +892,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)/* Scan the NAND chip */ chip->dummy_controller.ops = &vf610_nfc_controller_ops; - err =nand_scan (mtd,1 ); + err =nand_scan (chip,1 );if (err) goto err_disable_clk;
drivers/mtd/nand/raw/xway_nand.c +1 -1
@@ -205,7 +205,7 @@ static int xway_nand_probe(struct platform_device *pdev) | cs_flag, EBU_NAND_CON);/* Scan to find existence of the device */ - err =nand_scan (mtd,1 ); + err =nand_scan (&data->chip,1 );if (err)return err;
drivers/staging/mt29f_spinand/mt29f_spinand.c +1 -1
@@ -934,7 +934,7 @@ static int spinand_probe(struct spi_device *spi_nand)mtd_set_ooblayout (mtd, &spinand_oob_64_ops);#endif -if (nand_scan (mtd,1 )) +if (nand_scan (chip,1 ))return -ENXIO ;return mtd_device_register (mtd,NULL ,0 );
include/linux/mtd/rawnand.h +4 -3
@@ -24,15 +24,16 @@#include <linux/of.h> #include <linux/types.h> +struct nand_chip ;struct nand_flash_dev ;/* Scan and identify a NAND device */ -int nand_scan_with_ids (struct mtd_info *mtd,int max_chips, +int nand_scan_with_ids (struct nand_chip *chip,int max_chips,struct nand_flash_dev *ids); -static inline int nand_scan (struct mtd_info *mtd,int max_chips) +static inline int nand_scan (struct nand_chip *chip,int max_chips) { -return nand_scan_with_ids (mtd, max_chips,NULL ); +return nand_scan_with_ids (chip, max_chips,NULL ); }/* Internal helper for board drivers which need to override command function */
Signature · 1 line
2.14.1
PATCH v2 3/23 mtd: rawnand: Pass a nand_chip object to nand_release()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers to take a nand_chip object instead of an mtd_info one.
Now is nand_release()'s turn.
--- Documentation/driver-api/mtdnand.rst | 2 +- drivers/mtd/nand/raw/ams-delta.c | 2 +- drivers/mtd/nand/raw/au1550nd.c | 2 +- drivers/mtd/nand/raw/bcm47xxnflash/main.c | 2 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 2 +- drivers/mtd/nand/raw/cafe_nand.c | 2 +- drivers/mtd/nand/raw/cmx270_nand.c | 2 +- drivers/mtd/nand/raw/cs553x_nand.c | 2 +- drivers/mtd/nand/raw/davinci_nand.c | 2 +- drivers/mtd/nand/raw/denali.c | 4 +--- drivers/mtd/nand/raw/diskonchip.c | 4 ++-- drivers/mtd/nand/raw/docg4.c | 2 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 3 +-- drivers/mtd/nand/raw/fsl_ifc_nand.c | 3 +-- drivers/mtd/nand/raw/fsl_upm.c | 2 +- drivers/mtd/nand/raw/fsmc_nand.c | 2 +- drivers/mtd/nand/raw/gpio.c | 2 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- drivers/mtd/nand/raw/hisi504_nand.c | 3 +-- drivers/mtd/nand/raw/jz4740_nand.c | 2 +- drivers/mtd/nand/raw/jz4780_nand.c | 4 ++-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 3 +-- drivers/mtd/nand/raw/lpc32xx_slc.c | 3 +-- drivers/mtd/nand/raw/marvell_nand.c | 4 ++-- drivers/mtd/nand/raw/mpc5121_nfc.c | 2 +- drivers/mtd/nand/raw/mtk_nand.c | 4 ++-- drivers/mtd/nand/raw/mxc_nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nandsim.c | 4 ++-- drivers/mtd/nand/raw/ndfc.c | 2 +- drivers/mtd/nand/raw/nuc900_nand.c | 2 +- drivers/mtd/nand/raw/omap2.c | 2 +- drivers/mtd/nand/raw/orion_nand.c | 5 ++--- drivers/mtd/nand/raw/oxnas_nand.c | 4 ++-- drivers/mtd/nand/raw/pasemi_nand.c | 2 +- drivers/mtd/nand/raw/plat_nand.c | 4 ++-- drivers/mtd/nand/raw/qcom_nandc.c | 2 +- drivers/mtd/nand/raw/r852.c | 4 ++-- drivers/mtd/nand/raw/s3c2410.c | 2 +- drivers/mtd/nand/raw/sh_flctl.c | 2 +- drivers/mtd/nand/raw/sharpsl.c | 4 ++-- drivers/mtd/nand/raw/socrates_nand.c | 5 ++--- drivers/mtd/nand/raw/sunxi_nand.c | 4 ++-- drivers/mtd/nand/raw/tango_nand.c | 2 +- drivers/mtd/nand/raw/tmio_nand.c | 4 ++-- drivers/mtd/nand/raw/txx9ndfmc.c | 2 +- drivers/mtd/nand/raw/vf610_nfc.c | 2 +- drivers/mtd/nand/raw/xway_nand.c | 4 ++-- include/linux/mtd/rawnand.h | 2 +- 49 files changed, 66 insertions(+), 75 deletions(-)
Documentation/driver-api/mtdnand.rst +1 -1
@@ -277,7 +277,7 @@ unregisters the partitions in the MTD layer. static void __exit board_cleanup (void) { /* Release resources, unregister device */ - nand_release (board_mtd); + nand_release (mtd_to_nand(board_mtd)); /* unmap physical address */ iounmap(baseaddr);
drivers/mtd/nand/raw/ams-delta.c +1 -1
@@ -264,7 +264,7 @@ static int ams_delta_cleanup(struct platform_device *pdev)void __iomem *io_base =platform_get_drvdata (pdev);/* Release resources, unregister device */ -nand_release (ams_delta_mtd); +nand_release (mtd_to_nand (ams_delta_mtd));gpio_free_array (_mandatory_gpio,ARRAY_SIZE (_mandatory_gpio));gpio_free (AMS_DELTA_GPIO_PIN_NAND_RB );
drivers/mtd/nand/raw/au1550nd.c +1 -1
@@ -477,7 +477,7 @@ static int au1550nd_remove(struct platform_device *pdev)struct au1550nd_ctx *ctx =platform_get_drvdata (pdev);struct resource *r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -nand_release (nand_to_mtd (&ctx->chip)); +nand_release (&ctx->chip);iounmap (ctx->base);release_mem_region (r->start,0x1000 );kfree (ctx);
drivers/mtd/nand/raw/bcm47xxnflash/main.c +1 -1
@@ -65,7 +65,7 @@ static int bcm47xxnflash_remove(struct platform_device *pdev) {struct bcm47xxnflash *nflash =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&nflash->nand_chip)); +nand_release (&nflash->nand_chip);return 0 ; }
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -1
@@ -2616,7 +2616,7 @@ int brcmnand_remove(struct platform_device *pdev)struct brcmnand_host *host;list_for_each_entry (host, &ctrl->host_list, node) -nand_release (nand_to_mtd (&host->chip)); +nand_release (&host->chip);clk_disable_unprepare (ctrl->clk);
drivers/mtd/nand/raw/cafe_nand.c +1 -1
@@ -819,7 +819,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)/* Disable NAND IRQ in global IRQ mask register */ cafe_writel (cafe, ~1 &cafe_readl (cafe,GLOBAL_IRQ_MASK ),GLOBAL_IRQ_MASK );free_irq (pdev->irq, mtd); -nand_release (mtd); +nand_release (chip);free_rs (cafe->rs);pci_iounmap (pdev, cafe->mmio);dma_free_coherent (&cafe->pdev->dev,2112 , cafe->dmabuf, cafe->dmaaddr);
drivers/mtd/nand/raw/cmx270_nand.c +1 -1
@@ -228,7 +228,7 @@ module_init(cmx270_init); static void __exit cmx270_cleanup(void) {/* Release resources, unregister device */ -nand_release (cmx270_nand_mtd); +nand_release (mtd_to_nand (cmx270_nand_mtd));gpio_free (GPIO_NAND_RB );gpio_free (GPIO_NAND_CS );
drivers/mtd/nand/raw/cs553x_nand.c +1 -1
@@ -336,7 +336,7 @@ static void __exit cs553x_cleanup(void) mmio_base = this->IO_ADDR_R;/* Release resources, unregister device */ -nand_release (mtd); +nand_release (this);kfree (mtd->name); cs553x_mtd[i] =NULL ;
drivers/mtd/nand/raw/davinci_nand.c +1 -1
@@ -841,7 +841,7 @@ static int nand_davinci_remove(struct platform_device *pdev) ecc4_busy = false;spin_unlock_irq (&davinci_nand_lock); -nand_release (nand_to_mtd (&info->chip)); +nand_release (&info->chip);return 0 ; }
drivers/mtd/nand/raw/denali.c +1 -3
@@ -1378,9 +1378,7 @@ EXPORT_SYMBOL(denali_init);void denali_remove (struct denali_nand_info *denali) { -struct mtd_info *mtd =nand_to_mtd (&denali->nand); - -nand_release (mtd); +nand_release (&denali->nand);denali_disable_irq (denali); }EXPORT_SYMBOL (denali_remove);
drivers/mtd/nand/raw/diskonchip.c +2 -2
@@ -1627,7 +1627,7 @@ static int __init doc_probe(unsigned long physadr)/* nand_release will call mtd_device_unregister, but we haven't yet added it. This is handled without incident by mtd_device_unregister, as far as I can tell. */ -nand_release (mtd); +nand_release (nand); goto fail; }
@@ -1662,7 +1662,7 @@ static void release_nanddoc(void) doc =nand_get_controller_data (nand); nextmtd = doc->nextdoc; -nand_release (mtd); +nand_release (nand);iounmap (doc->virtadr);release_mem_region (doc->physadr,DOC_IOREMAP_LEN );free_rs (doc->rs_decoder);
drivers/mtd/nand/raw/docg4.c +1 -1
@@ -1420,7 +1420,7 @@ static int __init probe_docg4(struct platform_device *pdev) static int __exit cleanup_docg4(struct platform_device *pdev) {struct docg4_priv *doc =platform_get_drvdata (pdev); -nand_release (doc->mtd); +nand_release (mtd_to_nand (doc->mtd));kfree (mtd_to_nand (doc->mtd));iounmap (doc->virtadr);return 0 ;
drivers/mtd/nand/raw/fsl_elbc_nand.c +1 -2
@@ -942,9 +942,8 @@ static int fsl_elbc_nand_remove(struct platform_device *pdev) {struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand;struct fsl_elbc_mtd *priv =dev_get_drvdata (&pdev->dev); -struct mtd_info *mtd =nand_to_mtd (&priv->chip); -nand_release (mtd); +nand_release (&priv->chip);fsl_elbc_chip_remove (priv);mutex_lock (&fsl_elbc_nand_mutex);
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -2
@@ -1105,9 +1105,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)static int fsl_ifc_nand_remove (struct platform_device *dev) {struct fsl_ifc_mtd *priv =dev_get_drvdata (&dev->dev); -struct mtd_info *mtd =nand_to_mtd (&priv->chip); -nand_release (mtd); +nand_release (&priv->chip);fsl_ifc_chip_remove (priv);mutex_lock (&fsl_ifc_nand_mutex);
drivers/mtd/nand/raw/fsl_upm.c +1 -1
@@ -326,7 +326,7 @@ static int fun_remove(struct platform_device *ofdev)struct mtd_info *mtd =nand_to_mtd (&fun->chip);int i; -nand_release (mtd); +nand_release (&fun->chip);kfree (mtd->name);for (i =0 ; i < fun->mchip_count; i++) {
drivers/mtd/nand/raw/fsmc_nand.c +1 -1
@@ -1161,7 +1161,7 @@ static int fsmc_nand_remove(struct platform_device *pdev)struct fsmc_nand_data *host =platform_get_drvdata (pdev);if (host) { -nand_release (nand_to_mtd (&host->nand)); +nand_release (&host->nand);if (host->mode ==USE_DMA_ACCESS ) {dma_release_channel (host->write_dma_chan);
drivers/mtd/nand/raw/gpio.c +1 -1
@@ -194,7 +194,7 @@ static int gpio_nand_remove(struct platform_device *pdev) {struct gpiomtd *gpiomtd =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&gpiomtd->nand_chip)); +nand_release (&gpiomtd->nand_chip);/* Enable write protection and disable the chip */ if (gpiomtd->nwp && !IS_ERR (gpiomtd->nwp))
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -1
@@ -2026,7 +2026,7 @@ static int gpmi_nand_remove(struct platform_device *pdev) {struct gpmi_nand_data *this =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&this->nand)); +nand_release (&this->nand);gpmi_free_dma_buffer (this);release_resources (this);return 0 ;
drivers/mtd/nand/raw/hisi504_nand.c +1 -2
@@ -818,9 +818,8 @@ static int hisi_nfc_probe(struct platform_device *pdev)static int hisi_nfc_remove (struct platform_device *pdev) {struct hinfc_host *host =platform_get_drvdata (pdev); -struct mtd_info *mtd =nand_to_mtd (&host->chip); -nand_release (mtd); +nand_release (&host->chip);return 0 ; }
drivers/mtd/nand/raw/jz4740_nand.c +1 -1
@@ -507,7 +507,7 @@ static int jz_nand_remove(struct platform_device *pdev)struct jz_nand *nand =platform_get_drvdata (pdev);size_t i; -nand_release (nand_to_mtd (&nand->chip)); +nand_release (&nand->chip);/* Deassert and disable all chips */ writel (0 , nand->base +JZ_REG_NAND_CTRL );
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -292,7 +292,7 @@ static int jz4780_nand_init_chip(struct platform_device *pdev, ret =mtd_device_register (mtd,NULL ,0 );if (ret) { -nand_release (mtd); +nand_release (chip);return ret; }
@@ -307,7 +307,7 @@ static void jz4780_nand_cleanup_chips(struct jz4780_nand_controller *nfc)while (!list_empty (&nfc->chips)) { chip = list_first_entry(&nfc->chips, struct jz4780_nand_chip, chip_list); -nand_release (nand_to_mtd (&chip->chip)); +nand_release (&chip->chip);list_del (&chip->chip_list); } }
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -2
@@ -839,9 +839,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)static int lpc32xx_nand_remove (struct platform_device *pdev) {struct lpc32xx_nand_host *host =platform_get_drvdata (pdev); -struct mtd_info *mtd =nand_to_mtd (&host->nand_chip); -nand_release (mtd); +nand_release (&host->nand_chip);free_irq (host->irq, host);if (use_dma)dma_release_channel (host->dma_chan);
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -2
@@ -956,9 +956,8 @@ static int lpc32xx_nand_remove(struct platform_device *pdev) {uint32_t tmp;struct lpc32xx_nand_host *host =platform_get_drvdata (pdev); -struct mtd_info *mtd =nand_to_mtd (&host->nand_chip); -nand_release (mtd); +nand_release (&host->nand_chip);dma_release_channel (host->dma_chan);/* Force CE high */
drivers/mtd/nand/raw/marvell_nand.c +2 -2
@@ -2618,7 +2618,7 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, ret =mtd_device_register (mtd,NULL ,0 );if (ret) {dev_err (dev,"failed to register mtd device: %d\n" , ret); -nand_release (mtd); +nand_release (chip);return ret; }
@@ -2673,7 +2673,7 @@ static void marvell_nand_chips_cleanup(struct marvell_nfc *nfc)struct marvell_nand_chip *entry, *temp;list_for_each_entry_safe (entry, temp, &nfc->chips, node) { -nand_release (nand_to_mtd (&entry->chip)); +nand_release (&entry->chip);list_del (&entry->node); } }
drivers/mtd/nand/raw/mpc5121_nfc.c +1 -1
@@ -817,7 +817,7 @@ static int mpc5121_nfc_remove(struct platform_device *op)struct device *dev = &op->dev;struct mtd_info *mtd =dev_get_drvdata (dev); -nand_release (mtd); +nand_release (mtd_to_nand (mtd));mpc5121_nfc_free (dev, mtd);return 0 ;
drivers/mtd/nand/raw/mtk_nand.c +2 -2
@@ -1372,7 +1372,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, ret =mtd_device_register (mtd,NULL ,0 );if (ret) {dev_err (dev,"mtd parse partition error\n" ); -nand_release (mtd); +nand_release (nand);return ret; }
@@ -1538,7 +1538,7 @@ static int mtk_nfc_remove(struct platform_device *pdev)while (!list_empty (&nfc->chips)) { chip = list_first_entry(&nfc->chips, struct mtk_nfc_nand_chip, node); -nand_release (nand_to_mtd (&chip->nand)); +nand_release (&chip->nand);list_del (&chip->node); }
drivers/mtd/nand/raw/mxc_nand.c +1 -1
@@ -1915,7 +1915,7 @@ static int mxcnd_remove(struct platform_device *pdev) {struct mxc_nand_host *host =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&host->nand)); +nand_release (&host->nand);if (host->clk_act)clk_disable_unprepare (host->clk);
drivers/mtd/nand/raw/nand_base.c +4 -4
@@ -6853,12 +6853,12 @@ EXPORT_SYMBOL_GPL(nand_cleanup);/** * nand_release - [NAND Interface] Unregister the MTD device and free resources * held by the NAND device -* @mtd: MTD device structure +* @chip: NAND chip object */ -void nand_release (struct mtd_info *mtd) +void nand_release (struct nand_chip *chip) { -mtd_device_unregister (mtd); -nand_cleanup (mtd_to_nand (mtd)); +mtd_device_unregister (nand_to_mtd (chip)); +nand_cleanup (chip); }EXPORT_SYMBOL_GPL (nand_release);
drivers/mtd/nand/raw/nandsim.c +2 -2
@@ -2354,7 +2354,7 @@ static int __init ns_init_module(void) err_exit:free_nandsim (nand); -nand_release (nsmtd); +nand_release (chip);for (i =0 ;i <ARRAY_SIZE (nand->partitions); ++i)kfree (nand->partitions[i].name); error:
@@ -2376,7 +2376,7 @@ static void __exit ns_cleanup_module(void)int i;free_nandsim (ns);/* Free nandsim private resources */ -nand_release (nsmtd);/* Unregister driver */ +nand_release (chip);/* Unregister driver */ for (i =0 ;i <ARRAY_SIZE (ns->partitions); ++i)kfree (ns->partitions[i].name);kfree (mtd_to_nand (nsmtd));/* Free other structures */
drivers/mtd/nand/raw/ndfc.c +1 -1
@@ -258,7 +258,7 @@ static int ndfc_remove(struct platform_device *ofdev)struct ndfc_controller *ndfc =dev_get_drvdata (&ofdev->dev);struct mtd_info *mtd =nand_to_mtd (&ndfc->chip); -nand_release (mtd); +nand_release (&ndfc->chip);kfree (mtd->name);return 0 ;
drivers/mtd/nand/raw/nuc900_nand.c +1 -1
@@ -284,7 +284,7 @@ static int nuc900_nand_remove(struct platform_device *pdev) {struct nuc900_nand *nuc900_nand =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&nuc900_nand->chip)); +nand_release (&nuc900_nand->chip);clk_disable (nuc900_nand->clk);return 0 ;
drivers/mtd/nand/raw/omap2.c +1 -1
@@ -2290,7 +2290,7 @@ static int omap_nand_remove(struct platform_device *pdev) }if (info->dma)dma_release_channel (info->dma); -nand_release (mtd); +nand_release (nand_chip);return 0 ; }
drivers/mtd/nand/raw/orion_nand.c +2 -3
@@ -181,7 +181,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) mtd->name ="orion_nand" ; ret =mtd_device_register (mtd, board->parts, board->nr_parts);if (ret) { -nand_release (mtd); +nand_release (nc); goto no_dev; }
@@ -196,9 +196,8 @@ static int orion_nand_remove(struct platform_device *pdev) {struct orion_nand_info *info =platform_get_drvdata (pdev);struct nand_chip *chip = &info->chip; -struct mtd_info *mtd =nand_to_mtd (chip); -nand_release (mtd); +nand_release (chip);clk_disable_unprepare (info->clk);
drivers/mtd/nand/raw/oxnas_nand.c +2 -2
@@ -148,7 +148,7 @@ static int oxnas_nand_probe(struct platform_device *pdev) err =mtd_device_register (mtd,NULL ,0 );if (err) { -nand_release (mtd); +nand_release (chip); goto err_clk_unprepare; }
@@ -176,7 +176,7 @@ static int oxnas_nand_remove(struct platform_device *pdev)struct oxnas_nand_ctrl *oxnas =platform_get_drvdata (pdev);if (oxnas->chips[0 ]) -nand_release (nand_to_mtd (oxnas->chips[0 ])); +nand_release (oxnas->chips[0 ]);clk_disable_unprepare (oxnas->clk);
drivers/mtd/nand/raw/pasemi_nand.c +1 -1
@@ -191,7 +191,7 @@ static int pasemi_nand_remove(struct platform_device *ofdev) chip =mtd_to_nand (pasemi_nand_mtd);/* Release resources, unregister device */ -nand_release (pasemi_nand_mtd); +nand_release (chip);release_region (lpcctl,4 );
drivers/mtd/nand/raw/plat_nand.c +2 -2
@@ -144,7 +144,7 @@ static int plat_nand_probe(struct platform_device *pdev)if (!err)return err; -nand_release (mtd); +nand_release (&data->chip); out:if (pdata->ctrl.remove) pdata->ctrl.remove (pdev);
@@ -159,7 +159,7 @@ static int plat_nand_remove(struct platform_device *pdev)struct plat_nand_data *data =platform_get_drvdata (pdev);struct platform_nand_data *pdata =dev_get_platdata (&pdev->dev); -nand_release (nand_to_mtd (&data->chip)); +nand_release (&data->chip);if (pdata->ctrl.remove) pdata->ctrl.remove (pdev);
drivers/mtd/nand/raw/qcom_nandc.c +1 -1
@@ -2999,7 +2999,7 @@ static int qcom_nandc_remove(struct platform_device *pdev)struct qcom_nand_host *host;list_for_each_entry (host, &nandc->host_list, node) -nand_release (nand_to_mtd (&host->chip)); +nand_release (&host->chip);qcom_nandc_unalloc (nandc);
drivers/mtd/nand/raw/r852.c +2 -2
@@ -656,7 +656,7 @@ static int r852_register_nand_device(struct r852_device *dev) dev->card_registred =1 ;return 0 ; error3: -nand_release (mtd); +nand_release (dev->chip); error1:/* Force card redetect */ dev->card_detected =0 ;
@@ -675,7 +675,7 @@ static void r852_unregister_nand_device(struct r852_device *dev)return ;device_remove_file (&mtd->dev, &dev_attr_media_type); -nand_release (mtd); +nand_release (dev->chip);r852_engine_disable (dev); dev->card_registred =0 ; }
drivers/mtd/nand/raw/s3c2410.c +1 -1
@@ -781,7 +781,7 @@ static int s3c24xx_nand_remove(struct platform_device *pdev)for (mtdno =0 ; mtdno < info->mtd_count; mtdno++, ptr++) {pr_debug ("releasing mtd %d (%p)\n" , mtdno, ptr); -nand_release (nand_to_mtd (&ptr->chip)); +nand_release (&ptr->chip); } }
drivers/mtd/nand/raw/sh_flctl.c +1 -1
@@ -1216,7 +1216,7 @@ static int flctl_remove(struct platform_device *pdev)struct sh_flctl *flctl =platform_get_drvdata (pdev);flctl_release_dma (flctl); -nand_release (nand_to_mtd (&flctl->chip)); +nand_release (&flctl->chip);pm_runtime_disable (&pdev->dev);return 0 ;
drivers/mtd/nand/raw/sharpsl.c +2 -2
@@ -187,7 +187,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)return 0 ; err_add: -nand_release (mtd); +nand_release (this); err_scan:iounmap (sharpsl->io);
@@ -205,7 +205,7 @@ static int sharpsl_nand_remove(struct platform_device *pdev)struct sharpsl_nand *sharpsl =platform_get_drvdata (pdev);/* Release resources, unregister device */ -nand_release (nand_to_mtd (&sharpsl->chip)); +nand_release (&sharpsl->chip);iounmap (sharpsl->io);
drivers/mtd/nand/raw/socrates_nand.c +2 -3
@@ -181,7 +181,7 @@ static int socrates_nand_probe(struct platform_device *ofdev)if (!res)return res; -nand_release (mtd); +nand_release (nand_chip); out:iounmap (host->io_base);
@@ -194,9 +194,8 @@ static int socrates_nand_probe(struct platform_device *ofdev)static int socrates_nand_remove (struct platform_device *ofdev) {struct socrates_nand_host *host =dev_get_drvdata (&ofdev->dev); -struct mtd_info *mtd =nand_to_mtd (&host->nand_chip); -nand_release (mtd); +nand_release (&host->nand_chip);iounmap (host->io_base);
drivers/mtd/nand/raw/sunxi_nand.c +2 -2
@@ -1947,7 +1947,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, ret =mtd_device_register (mtd,NULL ,0 );if (ret) {dev_err (dev,"failed to register mtd device: %d\n" , ret); -nand_release (mtd); +nand_release (nand);return ret; }
@@ -1986,7 +1986,7 @@ static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc)while (!list_empty (&nfc->chips)) { chip = list_first_entry(&nfc->chips, struct sunxi_nand_chip, node); -nand_release (nand_to_mtd (&chip->nand)); +nand_release (&chip->nand);sunxi_nand_ecc_cleanup (&chip->nand.ecc);list_del (&chip->node); }
drivers/mtd/nand/raw/tango_nand.c +1 -1
@@ -617,7 +617,7 @@ static int tango_nand_remove(struct platform_device *pdev)for (cs =0 ; cs <MAX_CS ; ++cs) {if (nfc->chips[cs]) -nand_release (nand_to_mtd (&nfc->chips[cs]->nand_chip)); +nand_release (&nfc->chips[cs]->nand_chip); }return 0 ;
drivers/mtd/nand/raw/tmio_nand.c +2 -2
@@ -449,7 +449,7 @@ static int tmio_probe(struct platform_device *dev)if (!retval)return retval; -nand_release (mtd); +nand_release (nand_chip); err_irq:tmio_hw_stop (dev, tmio);
@@ -460,7 +460,7 @@ static int tmio_remove(struct platform_device *dev) {struct tmio_nand *tmio =platform_get_drvdata (dev); -nand_release (nand_to_mtd (&tmio->chip)); +nand_release (&tmio->chip);tmio_hw_stop (dev, tmio);return 0 ; }
drivers/mtd/nand/raw/txx9ndfmc.c +1 -1
@@ -390,7 +390,7 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev) chip =mtd_to_nand (mtd); txx9_priv =nand_get_controller_data (chip); -nand_release (mtd); +nand_release (chip);kfree (txx9_priv->mtdname);kfree (txx9_priv); }
drivers/mtd/nand/raw/vf610_nfc.c +1 -1
@@ -916,7 +916,7 @@ static int vf610_nfc_remove(struct platform_device *pdev)struct mtd_info *mtd =platform_get_drvdata (pdev);struct vf610_nfc *nfc =mtd_to_nfc (mtd); -nand_release (mtd); +nand_release (mtd_to_nand (mtd));clk_disable_unprepare (nfc->clk);return 0 ; }
drivers/mtd/nand/raw/xway_nand.c +2 -2
@@ -211,7 +211,7 @@ static int xway_nand_probe(struct platform_device *pdev) err =mtd_device_register (mtd,NULL ,0 );if (err) -nand_release (mtd); +nand_release (&data->chip);return err; }
@@ -223,7 +223,7 @@ static int xway_nand_remove(struct platform_device *pdev) {struct xway_nand_data *data =platform_get_drvdata (pdev); -nand_release (nand_to_mtd (&data->chip)); +nand_release (&data->chip);return 0 ; }
include/linux/mtd/rawnand.h +1 -1
@@ -1739,7 +1739,7 @@ int nand_write_data_op(struct nand_chip *chip, const void *buf,*/ void nand_cleanup (struct nand_chip *chip);/* Unregister the MTD device and calls nand_cleanup() */ -void nand_release (struct mtd_info *mtd); +void nand_release (struct nand_chip *chip);/* Default extended ID decoding function */ void nand_decode_ext_id (struct nand_chip *chip);
Signature · 1 line
2.14.1
PATCH v2 4/23 mtd: rawnand: Pass a nand_chip object to nand_wait_ready()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers to take a nand_chip object instead of an mtd_info one.
Now is nand_wait_ready()'s turn.
--- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 2 +- drivers/mtd/nand/raw/cafe_nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 12 ++++++------ include/linux/mtd/rawnand.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +1 -1
@@ -232,7 +232,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, nand_chip->cmd_ctrl (mtd, command,NAND_CTRL_CLE );ndelay (100 ); -nand_wait_ready (mtd); +nand_wait_ready (nand_chip);break ;case NAND_CMD_READID : ctlcode =NCTL_CSA |0x01000000 |NCTL_CMD1W |NCTL_CMD0 ;
drivers/mtd/nand/raw/cafe_nand.c +1 -1
@@ -313,7 +313,7 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,cafe_writel (cafe, cafe->ctl2,NAND_CTRL2 );return ; } -nand_wait_ready (mtd); +nand_wait_ready (chip);cafe_writel (cafe, cafe->ctl2,NAND_CTRL2 ); }
drivers/mtd/nand/raw/nand_base.c +6 -6
@@ -624,13 +624,13 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)/** * nand_wait_ready - [GENERIC] Wait for the ready pin after commands. -* @mtd: MTD device structure +* @chip: NAND chip object * * Wait for the ready pin after a command, and warn if a timeout occurs. */ -void nand_wait_ready (struct mtd_info *mtd) +void nand_wait_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);unsigned long timeo =400 ;if (in_interrupt () || oops_in_progress)
@@ -852,7 +852,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,*/ ndelay (100 ); -nand_wait_ready (mtd); +nand_wait_ready (chip); }static void nand_ccs_delay (struct nand_chip *chip)
@@ -1004,7 +1004,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,*/ ndelay (100 ); -nand_wait_ready (mtd); +nand_wait_ready (chip); }/**
@@ -2251,7 +2251,7 @@ static int nand_wait_rdy_op(struct nand_chip *chip, unsigned int timeout_ms,if (!chip->dev_ready)udelay (chip->chip_delay);else -nand_wait_ready (nand_to_mtd (chip)); +nand_wait_ready (chip);return 0 ; }
include/linux/mtd/rawnand.h +1 -1
@@ -37,7 +37,7 @@ static inline int nand_scan(struct nand_chip *chip, int max_chips) }/* Internal helper for board drivers which need to override command function */ -void nand_wait_ready (struct mtd_info *mtd); +void nand_wait_ready (struct nand_chip *chip);/* The maximum number of NAND chips in an array */ #define NAND_MAX_CHIPS 8
Signature · 1 line
2.14.1
PATCH v2 5/23 mtd: rawnand: Pass a nand_chip object to ecc->hwctl()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one.
Now is ecc->hwctl()'s turn.
--- drivers/mtd/nand/raw/cs553x_nand.c | 3 +-- drivers/mtd/nand/raw/davinci_nand.c | 10 +++++----- drivers/mtd/nand/raw/diskonchip.c | 6 ++---- drivers/mtd/nand/raw/fsmc_nand.c | 6 +++--- drivers/mtd/nand/raw/jz4740_nand.c | 4 ++-- drivers/mtd/nand/raw/jz4780_nand.c | 4 ++-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 2 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 14 +++++++------- drivers/mtd/nand/raw/ndfc.c | 3 +-- drivers/mtd/nand/raw/omap2.c | 17 ++++++++--------- drivers/mtd/nand/raw/r852.c | 4 ++-- drivers/mtd/nand/raw/s3c2410.c | 15 +++++++++------ drivers/mtd/nand/raw/sharpsl.c | 4 ++-- drivers/mtd/nand/raw/tmio_nand.c | 4 ++-- drivers/mtd/nand/raw/txx9ndfmc.c | 4 ++-- include/linux/mtd/rawnand.h | 2 +- 17 files changed, 51 insertions(+), 53 deletions(-)
drivers/mtd/nand/raw/cs553x_nand.c +1 -2
@@ -157,9 +157,8 @@ static int cs553x_device_ready(struct mtd_info *mtd)return (foo &CS_NAND_STS_FLASH_RDY ) && !(foo &CS_NAND_CTLR_BUSY ); } -static void cs_enable_hwecc (struct mtd_info *mtd,int mode) +static void cs_enable_hwecc (struct nand_chip *this,int mode) { -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *mmio_base = this->IO_ADDR_R;writeb (0x07 , mmio_base +MM_NAND_ECC_CTL );
drivers/mtd/nand/raw/davinci_nand.c +5 -5
@@ -146,16 +146,16 @@ static inline uint32_t nand_davinci_readecc_1bit(struct mtd_info *mtd) + 4 * info->core_chipsel); } -static void nand_davinci_hwctl_1bit (struct mtd_info *mtd,int mode) +static void nand_davinci_hwctl_1bit (struct nand_chip *chip,int mode) {struct davinci_nand_info *info;uint32_t nandcfr;unsigned long flags; - info =to_davinci_nand (mtd); + info =to_davinci_nand (nand_to_mtd (chip));/* Reset ECC hardware */ -nand_davinci_readecc_1bit (mtd); +nand_davinci_readecc_1bit (nand_to_mtd (chip));spin_lock_irqsave (&davinci_nand_lock, flags);
@@ -231,9 +231,9 @@ static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat,* OOB without recomputing ECC. */ -static void nand_davinci_hwctl_4bit (struct mtd_info *mtd,int mode) +static void nand_davinci_hwctl_4bit (struct nand_chip *chip,int mode) { -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (chip));unsigned long flags;u32 val;
drivers/mtd/nand/raw/diskonchip.c +2 -4
@@ -797,9 +797,8 @@ static int doc200x_block_bad(struct mtd_info *mtd, loff_t ofs)return 0 ; } -static void doc200x_enable_hwecc (struct mtd_info *mtd,int mode) +static void doc200x_enable_hwecc (struct nand_chip *this,int mode) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
@@ -816,9 +815,8 @@ static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) } } -static void doc2001plus_enable_hwecc (struct mtd_info *mtd,int mode) +static void doc2001plus_enable_hwecc (struct nand_chip *this,int mode) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
drivers/mtd/nand/raw/fsmc_nand.c +3 -3
@@ -368,9 +368,9 @@ static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline,/* * fsmc_enable_hwecc - Enables Hardware ECC through FSMC registers */ -static void fsmc_enable_hwecc (struct mtd_info *mtd,int mode) +static void fsmc_enable_hwecc (struct nand_chip *chip,int mode) { -struct fsmc_nand_data *host =mtd_to_fsmc (mtd); +struct fsmc_nand_data *host =mtd_to_fsmc (nand_to_mtd (chip));writel_relaxed (readl (host->regs_va +FSMC_PC ) & ~FSMC_ECCPLEN_256 , host->regs_va +FSMC_PC );
@@ -740,7 +740,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 , s =0 ; s < eccsteps; s++, i += eccbytes, p += eccsize) {nand_read_page_op (chip, page, s * eccsize,NULL ,0 ); - chip->ecc.hwctl (mtd,NAND_ECC_READ ); + chip->ecc.hwctl (chip,NAND_ECC_READ );nand_read_data_op (chip, p, eccsize, false);for (j =0 ; j < eccbytes;) {
drivers/mtd/nand/raw/jz4740_nand.c +2 -2
@@ -134,9 +134,9 @@ static int jz_nand_dev_ready(struct mtd_info *mtd)return gpiod_get_value_cansleep (nand->busy_gpio); } -static void jz_nand_hwctl (struct mtd_info *mtd,int mode) +static void jz_nand_hwctl (struct nand_chip *chip,int mode) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));uint32_t reg;writel (0 , nand->base +JZ_REG_NAND_IRQ_STAT );
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -116,9 +116,9 @@ static int jz4780_nand_dev_ready(struct mtd_info *mtd)return !gpiod_get_value_cansleep (nand->busy_gpio); } -static void jz4780_nand_ecc_hwctl (struct mtd_info *mtd,int mode) +static void jz4780_nand_ecc_hwctl (struct nand_chip *chip,int mode) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip)); nand->reading = (mode ==NAND_ECC_READ ); }
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -1
@@ -576,7 +576,7 @@ static int lpc32xx_write_oob(struct mtd_info *mtd, struct nand_chip *chip, }/* Prepares MLC for transfers with H/W ECC enabled: always enabled anyway */ -static void lpc32xx_ecc_enable (struct mtd_info *mtd,int mode) +static void lpc32xx_ecc_enable (struct nand_chip *chip,int mode) {/* Always enabled! */ }
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -1
@@ -337,7 +337,7 @@ static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host)/* * Prepares SLC for transfers with H/W ECC enabled */ -static void lpc32xx_nand_ecc_enable (struct mtd_info *mtd,int mode) +static void lpc32xx_nand_ecc_enable (struct nand_chip *chip,int mode) {/* Hardware ECC is enabled automatically in hardware as needed */ }
drivers/mtd/nand/raw/nand_base.c +7 -7
@@ -3272,7 +3272,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,return ret;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { - chip->ecc.hwctl (mtd,NAND_ECC_READ ); + chip->ecc.hwctl (chip,NAND_ECC_READ ); ret =nand_read_data_op (chip, p, eccsize, false);if (ret)
@@ -3358,7 +3358,7 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {int stat; - chip->ecc.hwctl (mtd,NAND_ECC_READ ); + chip->ecc.hwctl (chip,NAND_ECC_READ ); ret =nand_read_data_op (chip, p, eccsize, false);if (ret)
@@ -3415,7 +3415,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {int stat; - chip->ecc.hwctl (mtd,NAND_ECC_READ ); + chip->ecc.hwctl (chip,NAND_ECC_READ ); ret =nand_read_data_op (chip, p, eccsize, false);if (ret)
@@ -3430,7 +3430,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, oob += chip->ecc.prepad; } - chip->ecc.hwctl (mtd,NAND_ECC_READSYN ); + chip->ecc.hwctl (chip,NAND_ECC_READSYN ); ret =nand_read_data_op (chip, oob, eccbytes, false);if (ret)
@@ -4151,7 +4151,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,return ret;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { - chip->ecc.hwctl (mtd,NAND_ECC_WRITE ); + chip->ecc.hwctl (chip,NAND_ECC_WRITE ); ret =nand_write_data_op (chip, p, eccsize, false);if (ret)
@@ -4204,7 +4204,7 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,for (step =0 ; step < ecc_steps; step++) {/* configure controller for WRITE access */ - chip->ecc.hwctl (mtd,NAND_ECC_WRITE ); + chip->ecc.hwctl (chip,NAND_ECC_WRITE );/* write data (untouched subpages already masked by 0xFF) */ ret =nand_write_data_op (chip, buf, ecc_size, false);
@@ -4272,7 +4272,7 @@ static int nand_write_page_syndrome(struct mtd_info *mtd,return ret;for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { - chip->ecc.hwctl (mtd,NAND_ECC_WRITE ); + chip->ecc.hwctl (chip,NAND_ECC_WRITE ); ret =nand_write_data_op (chip, p, eccsize, false);if (ret)
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -81,10 +81,9 @@ static int ndfc_ready(struct mtd_info *mtd)return in_be32 (ndfc->ndfcbase +NDFC_STAT ) &NDFC_STAT_IS_READY ; } -static void ndfc_enable_hwecc (struct mtd_info *mtd,int mode) +static void ndfc_enable_hwecc (struct nand_chip *chip,int mode) {uint32_t ccr; -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip); ccr =in_be32 (ndfc->ndfcbase +NDFC_CCR );
drivers/mtd/nand/raw/omap2.c +8 -9
@@ -935,10 +935,9 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const u_char *dat,* @mtd: MTD device structure * @mode: Read/Write mode */ -static void omap_enable_hwecc (struct mtd_info *mtd,int mode) +static void omap_enable_hwecc (struct nand_chip *chip,int mode) { -struct omap_nand_info *info =mtd_to_omap (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));unsigned int dev_width = (chip->options &NAND_BUSWIDTH_16 ) ?1 :0 ;u32 val;
@@ -1030,13 +1029,13 @@ static int omap_dev_ready(struct mtd_info *mtd)* eccsize0 = 0 (no additional protected byte in spare area) * eccsize1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area) */ -static void __maybe_unused omap_enable_hwecc_bch (struct mtd_info *mtd,int mode) +static void __maybe_unused omap_enable_hwecc_bch (struct nand_chip *chip, +int mode) {unsigned int bch_type;unsigned int dev_width, nsectors; -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));enum omap_ecc ecc_opt = info->ecc_opt; -struct nand_chip *chip =mtd_to_nand (mtd);u32 val, wr_mode;unsigned int ecc_size1, ecc_size0;
@@ -1529,7 +1528,7 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,nand_prog_page_begin_op (chip, page,0 ,NULL ,0 );/* Enable GPMC ecc engine */ - chip->ecc.hwctl (mtd,NAND_ECC_WRITE ); + chip->ecc.hwctl (chip,NAND_ECC_WRITE );/* Write data */ chip->write_buf (mtd, buf, mtd->writesize);
@@ -1582,7 +1581,7 @@ static int omap_write_subpage_bch(struct mtd_info *mtd,nand_prog_page_begin_op (chip, page,0 ,NULL ,0 );/* Enable GPMC ECC engine */ - chip->ecc.hwctl (mtd,NAND_ECC_WRITE ); + chip->ecc.hwctl (chip,NAND_ECC_WRITE );/* Write data */ chip->write_buf (mtd, buf, mtd->writesize);
@@ -1641,7 +1640,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,nand_read_page_op (chip, page,0 ,NULL ,0 );/* Enable GPMC ecc engine */ - chip->ecc.hwctl (mtd,NAND_ECC_READ ); + chip->ecc.hwctl (chip,NAND_ECC_READ );/* Read data */ chip->read_buf (mtd, buf, mtd->writesize);
drivers/mtd/nand/raw/r852.c +2 -2
@@ -401,9 +401,9 @@ static int r852_ready(struct mtd_info *mtd)* Set ECC engine mode */ -static void r852_ecc_hwctl (struct mtd_info *mtd,int mode) +static void r852_ecc_hwctl (struct nand_chip *chip,int mode) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));if (dev->card_unstable)return ;
drivers/mtd/nand/raw/s3c2410.c +9 -6
@@ -591,31 +591,34 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,* generator block to ECC the data as it passes through] */ -static void s3c2410_nand_enable_hwecc (struct mtd_info *mtd,int mode) +static void s3c2410_nand_enable_hwecc (struct nand_chip *chip,int mode) { -struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd); +struct s3c2410_nand_info *info;unsigned long ctrl; + info =s3c2410_nand_mtd_toinfo (nand_to_mtd (chip)); ctrl =readl (info->regs +S3C2410_NFCONF ); ctrl |=S3C2410_NFCONF_INITECC ;writel (ctrl, info->regs +S3C2410_NFCONF ); } -static void s3c2412_nand_enable_hwecc (struct mtd_info *mtd,int mode) +static void s3c2412_nand_enable_hwecc (struct nand_chip *chip,int mode) { -struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd); +struct s3c2410_nand_info *info;unsigned long ctrl; + info =s3c2410_nand_mtd_toinfo (nand_to_mtd (chip)); ctrl =readl (info->regs +S3C2440_NFCONT );writel (ctrl |S3C2412_NFCONT_INIT_MAIN_ECC , info->regs +S3C2440_NFCONT ); } -static void s3c2440_nand_enable_hwecc (struct mtd_info *mtd,int mode) +static void s3c2440_nand_enable_hwecc (struct nand_chip *chip,int mode) { -struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd); +struct s3c2410_nand_info *info;unsigned long ctrl; + info =s3c2410_nand_mtd_toinfo (nand_to_mtd (chip)); ctrl =readl (info->regs +S3C2440_NFCONT );writel (ctrl |S3C2440_NFCONT_INITECC , info->regs +S3C2440_NFCONT ); }
drivers/mtd/nand/raw/sharpsl.c +2 -2
@@ -85,9 +85,9 @@ static int sharpsl_nand_dev_ready(struct mtd_info *mtd)return !((readb (sharpsl->io +FLASHCTL ) &FLRYBY ) ==0 ); } -static void sharpsl_nand_enable_hwecc (struct mtd_info *mtd,int mode) +static void sharpsl_nand_enable_hwecc (struct nand_chip *chip,int mode) { -struct sharpsl_nand *sharpsl =mtd_to_sharpsl (mtd); +struct sharpsl_nand *sharpsl =mtd_to_sharpsl (nand_to_mtd (chip));writeb (0 , sharpsl->io +ECCCLRR ); }
drivers/mtd/nand/raw/tmio_nand.c +2 -2
@@ -259,9 +259,9 @@ static void tmio_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)tmio_ioread16_rep (tmio->fcr +FCR_DATA , buf, len >>1 ); } -static void tmio_nand_enable_hwecc (struct mtd_info *mtd,int mode) +static void tmio_nand_enable_hwecc (struct nand_chip *chip,int mode) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));tmio_iowrite8 (FCR_MODE_HWECC_RESET , tmio->fcr +FCR_MODE );tmio_ioread8 (tmio->fcr +FCR_DATA );/* dummy read */
drivers/mtd/nand/raw/txx9ndfmc.c +2 -2
@@ -211,9 +211,9 @@ static int txx9ndfmc_correct_data(struct mtd_info *mtd, unsigned char *buf,return corrected; } -static void txx9ndfmc_enable_hwecc (struct mtd_info *mtd,int mode) +static void txx9ndfmc_enable_hwecc (struct nand_chip *chip,int mode) { -struct platform_device *dev =mtd_to_platdev (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));u32 mcr =txx9ndfmc_read (dev,TXX9_NDFMCR ); mcr &= ~TXX9_NDFMCR_ECC_ALL ;
include/linux/mtd/rawnand.h +1 -1
@@ -647,7 +647,7 @@ struct nand_ecc_ctrl {void *priv;u8 *calc_buf;u8 *code_buf; -void (*hwctl)(struct mtd_info *mtd,int mode); +void (*hwctl)(struct nand_chip *chip,int mode);int (*calculate)(struct mtd_info *mtd,const uint8_t *dat,uint8_t *ecc_code); int (*correct)(struct mtd_info *mtd, uint8_t *dat, uint8_t *read_ecc,
Signature · 1 line
2.14.1
PATCH v2 6/23 mtd: rawnand: Pass a nand_chip object to ecc->calculate()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one.
Now is ecc->calculate()'s turn.
--- drivers/mtd/nand/raw/cs553x_nand.c | 4 ++-- drivers/mtd/nand/raw/davinci_nand.c | 12 ++++++------ drivers/mtd/nand/raw/diskonchip.c | 4 ++-- drivers/mtd/nand/raw/fsmc_nand.c | 10 +++++----- drivers/mtd/nand/raw/jz4740_nand.c | 6 +++--- drivers/mtd/nand/raw/jz4780_nand.c | 4 ++-- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 16 ++++++++-------- drivers/mtd/nand/raw/nand_bch.c | 5 ++--- drivers/mtd/nand/raw/nand_ecc.c | 5 ++--- drivers/mtd/nand/raw/ndfc.c | 3 +-- drivers/mtd/nand/raw/omap2.c | 14 +++++++------- drivers/mtd/nand/raw/r852.c | 6 +++--- drivers/mtd/nand/raw/s3c2410.c | 15 +++++++++------ drivers/mtd/nand/raw/sharpsl.c | 5 +++-- drivers/mtd/nand/raw/tmio_nand.c | 6 +++--- drivers/mtd/nand/raw/txx9ndfmc.c | 5 ++--- include/linux/mtd/nand_bch.h | 5 +++-- include/linux/mtd/nand_ecc.h | 4 +++- include/linux/mtd/rawnand.h | 4 ++-- 20 files changed, 69 insertions(+), 66 deletions(-)
drivers/mtd/nand/raw/cs553x_nand.c +2 -2
@@ -164,10 +164,10 @@ static void cs_enable_hwecc(struct nand_chip *this, int mode)writeb (0x07 , mmio_base +MM_NAND_ECC_CTL ); } -static int cs_calculate_ecc (struct mtd_info *mtd,const u_char *dat,u_char *ecc_code) +static int cs_calculate_ecc (struct nand_chip *this,const u_char *dat, +u_char *ecc_code) {uint32_t ecc; -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *mmio_base = this->IO_ADDR_R; ecc =readl (mmio_base +MM_NAND_STS );
drivers/mtd/nand/raw/davinci_nand.c +6 -6
@@ -170,10 +170,10 @@ static void nand_davinci_hwctl_1bit(struct nand_chip *chip, int mode)/* * Read hardware ECC value and pack into three bytes */ -static int nand_davinci_calculate_1bit (struct mtd_info *mtd, -const u_char *dat,u_char *ecc_code) +static int nand_davinci_calculate_1bit (struct nand_chip *chip, +const u_char *dat,u_char *ecc_code) { -unsigned int ecc_val =nand_davinci_readecc_1bit (mtd); +unsigned int ecc_val =nand_davinci_readecc_1bit (nand_to_mtd (chip));unsigned int ecc24 = (ecc_val &0x0fff ) | ((ecc_val &0x0fff0000 ) >>4 );/* invert so that erased block ecc is correct */
@@ -266,10 +266,10 @@ nand_davinci_readecc_4bit(struct davinci_nand_info *info, u32 code[4]) }/* Terminate read ECC; or return ECC (as bytes) of data written to NAND. */ -static int nand_davinci_calculate_4bit (struct mtd_info *mtd, -const u_char *dat,u_char *ecc_code) +static int nand_davinci_calculate_4bit (struct nand_chip *chip, +const u_char *dat,u_char *ecc_code) { -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (chip));u32 raw_ecc[4 ], *p;unsigned i;
drivers/mtd/nand/raw/diskonchip.c +2 -2
@@ -834,9 +834,9 @@ static void doc2001plus_enable_hwecc(struct nand_chip *this, int mode) }/* This code is only called on write */ -static int doc200x_calculate_ecc (struct mtd_info *mtd,const u_char *dat,unsigned char *ecc_code) +static int doc200x_calculate_ecc (struct nand_chip *this,const u_char *dat, +unsigned char *ecc_code) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
drivers/mtd/nand/raw/fsmc_nand.c +5 -5
@@ -385,10 +385,10 @@ static void fsmc_enable_hwecc(struct nand_chip *chip, int mode)* FSMC. ECC is 13 bytes for 512 bytes of data (supports error correction up to * max of 8-bits) */ -static int fsmc_read_hwecc_ecc4 (struct mtd_info *mtd,const uint8_t *data, +static int fsmc_read_hwecc_ecc4 (struct nand_chip *chip,const uint8_t *data,uint8_t *ecc) { -struct fsmc_nand_data *host =mtd_to_fsmc (mtd); +struct fsmc_nand_data *host =mtd_to_fsmc (nand_to_mtd (chip));uint32_t ecc_tmp;unsigned long deadline = jiffies +FSMC_BUSY_WAIT_TIMEOUT ;
@@ -433,10 +433,10 @@ static int fsmc_read_hwecc_ecc4(struct mtd_info *mtd, const uint8_t *data,* FSMC. ECC is 3 bytes for 512 bytes of data (supports error correction up to * max of 1-bit) */ -static int fsmc_read_hwecc_ecc1 (struct mtd_info *mtd,const uint8_t *data, +static int fsmc_read_hwecc_ecc1 (struct nand_chip *chip,const uint8_t *data,uint8_t *ecc) { -struct fsmc_nand_data *host =mtd_to_fsmc (mtd); +struct fsmc_nand_data *host =mtd_to_fsmc (nand_to_mtd (chip));uint32_t ecc_tmp; ecc_tmp =readl_relaxed (host->regs_va +ECC1 );
@@ -767,7 +767,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, }memcpy (&ecc_code[i], oob, chip->ecc.bytes); - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); stat = chip->ecc.correct (mtd, p, &ecc_code[i], &ecc_calc[i]);if (stat <0 ) {
drivers/mtd/nand/raw/jz4740_nand.c +3 -3
@@ -162,10 +162,10 @@ static void jz_nand_hwctl(struct nand_chip *chip, int mode)writel (reg, nand->base +JZ_REG_NAND_ECC_CTRL ); } -static int jz_nand_calculate_ecc_rs (struct mtd_info *mtd,const uint8_t *dat, -uint8_t *ecc_code) +static int jz_nand_calculate_ecc_rs (struct nand_chip *chip,const uint8_t *dat, +uint8_t *ecc_code) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));uint32_t reg, status;int i;unsigned int timeout =1000 ;
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -123,10 +123,10 @@ static void jz4780_nand_ecc_hwctl(struct nand_chip *chip, int mode) nand->reading = (mode ==NAND_ECC_READ ); } -static int jz4780_nand_ecc_calculate (struct mtd_info *mtd,const u8 *dat, +static int jz4780_nand_ecc_calculate (struct nand_chip *chip,const u8 *dat,u8 *ecc_code) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip));struct jz4780_nand_controller *nfc =to_jz4780_nand_controller (nand->chip.controller);struct jz4780_bch_params params;
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -1
@@ -345,7 +345,7 @@ static void lpc32xx_nand_ecc_enable(struct nand_chip *chip, int mode)/* * Calculates the ECC for the data */ -static int lpc32xx_nand_ecc_calculate (struct mtd_info *mtd, +static int lpc32xx_nand_ecc_calculate (struct nand_chip *chip,const unsigned char *buf,unsigned char *code) {
drivers/mtd/nand/raw/nand_base.c +8 -8
@@ -3110,7 +3110,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, chip->ecc.read_page_raw (mtd, chip, buf,1 , page);for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); ret =mtd_ooblayout_get_eccbytes (mtd, ecc_code, chip->oob_poi,0 , chip->ecc.total);
@@ -3175,7 +3175,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,/* Calculate ECC */ for (i =0 ; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) - chip->ecc.calculate (mtd, p, &chip->ecc.calc_buf[i]); + chip->ecc.calculate (chip, p, &chip->ecc.calc_buf[i]);/* * The performance is faster if we position offsets according to
@@ -3278,7 +3278,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,if (ret)return ret; - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); } ret =nand_read_data_op (chip, chip->oob_poi, mtd->oobsize, false);
@@ -3364,7 +3364,7 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd,if (ret)return ret; - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); stat = chip->ecc.correct (mtd, p, &ecc_code[i],NULL ); if (stat == -EBADMSG &&
@@ -4118,7 +4118,7 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,/* Software ECC calculation */ for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); ret =mtd_ooblayout_set_eccbytes (mtd, ecc_calc, chip->oob_poi,0 , chip->ecc.total);
@@ -4157,7 +4157,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,if (ret)return ret; - chip->ecc.calculate (mtd, p, &ecc_calc[i]); + chip->ecc.calculate (chip, p, &ecc_calc[i]); } ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
@@ -4215,7 +4215,7 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,if ((step < start_step) || (step > end_step))memset (ecc_calc,0xff , ecc_bytes);else - chip->ecc.calculate (mtd, buf, ecc_calc); + chip->ecc.calculate (chip, buf, ecc_calc);/* mask OOB of un-touched subpages by padding 0xFF */ /* if oob_required, preserve OOB metadata of written subpage */
@@ -4287,7 +4287,7 @@ static int nand_write_page_syndrome(struct mtd_info *mtd, oob += chip->ecc.prepad; } - chip->ecc.calculate (mtd, p, oob); + chip->ecc.calculate (chip, p, oob); ret =nand_write_data_op (chip, oob, eccbytes, false);if (ret)
drivers/mtd/nand/raw/nand_bch.c +2 -3
@@ -43,14 +43,13 @@ struct nand_bch_control {/** * nand_bch_calculate_ecc - [NAND Interface] Calculate ECC for data block -* @mtd: MTD block structure +* @chip: NAND chip object * @buf: input buffer with raw data * @code: output buffer with ECC */ -int nand_bch_calculate_ecc (struct mtd_info *mtd,const unsigned char *buf, +int nand_bch_calculate_ecc (struct nand_chip *chip,const unsigned char *buf,unsigned char *code) { -const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int i;
drivers/mtd/nand/raw/nand_ecc.c +2 -3
@@ -398,11 +398,10 @@ EXPORT_SYMBOL(__nand_calculate_ecc);* @buf: input buffer with raw data * @code: output buffer with ECC */ -int nand_calculate_ecc (struct mtd_info *mtd,const unsigned char *buf, +int nand_calculate_ecc (struct nand_chip *chip,const unsigned char *buf,unsigned char *code) { -__nand_calculate_ecc (buf, -mtd_to_nand (mtd)->ecc.size, code); +__nand_calculate_ecc (buf, chip->ecc.size, code);return 0 ; }
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -92,10 +92,9 @@ static void ndfc_enable_hwecc(struct nand_chip *chip, int mode)wmb (); } -static int ndfc_calculate_ecc (struct mtd_info *mtd, +static int ndfc_calculate_ecc (struct nand_chip *chip,const u_char *dat,u_char *ecc_code) { -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip);uint32_t ecc;uint8_t *p = (uint8_t *)&ecc;
drivers/mtd/nand/raw/omap2.c +7 -7
@@ -900,7 +900,7 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,/** * omap_calcuate_ecc - Generate non-inverted ECC bytes. -* @mtd: MTD device structure +* @chip: NAND chip object * @dat: The pointer to data on which ecc is computed * @ecc_code: The ecc_code buffer *
@@ -910,10 +910,10 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,* an erased page will produce an ECC mismatch between generated and read * ECC bytes that has to be dealt with separately. */ -static int omap_calculate_ecc (struct mtd_info *mtd,const u_char *dat, -u_char *ecc_code) +static int omap_calculate_ecc (struct nand_chip *chip,const u_char *dat, +u_char *ecc_code) { -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));u32 val; val =readl (info->reg.gpmc_ecc_config);
@@ -1255,7 +1255,7 @@ static int _omap_calculate_ecc_bch(struct mtd_info *mtd,/** * omap_calculate_ecc_bch_sw - ECC generator for sector for SW based correction -* @mtd: MTD device structure +* @chip: NAND chip object * @dat: The pointer to data on which ecc is computed * @ecc_code: The ecc_code buffer *
@@ -1263,10 +1263,10 @@ static int _omap_calculate_ecc_bch(struct mtd_info *mtd,* when SW based correction is required as ECC is required for one sector * at a time. */ -static int omap_calculate_ecc_bch_sw (struct mtd_info *mtd, +static int omap_calculate_ecc_bch_sw (struct nand_chip *chip,const u_char *dat,u_char *ecc_calc) { -return _omap_calculate_ecc_bch (mtd, dat, ecc_calc,0 ); +return _omap_calculate_ecc_bch (nand_to_mtd (chip), dat, ecc_calc,0 ); }/**
drivers/mtd/nand/raw/r852.c +3 -3
@@ -433,10 +433,10 @@ static void r852_ecc_hwctl(struct nand_chip *chip, int mode)* Calculate ECC, only used for writes */ -static int r852_ecc_calculate (struct mtd_info *mtd,const uint8_t *dat, -uint8_t *ecc_code) +static int r852_ecc_calculate (struct nand_chip *chip,const uint8_t *dat, +uint8_t *ecc_code) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));struct sm_oob *oob = (struct sm_oob *)ecc_code;uint32_t ecc1, ecc2;
drivers/mtd/nand/raw/s3c2410.c +9 -6
@@ -623,9 +623,10 @@ static void s3c2440_nand_enable_hwecc(struct nand_chip *chip, int mode)writel (ctrl |S3C2440_NFCONT_INITECC , info->regs +S3C2440_NFCONT ); } -static int s3c2410_nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat, -u_char *ecc_code) +static int s3c2410_nand_calculate_ecc (struct nand_chip *chip, +const u_char *dat,u_char *ecc_code) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd); ecc_code[0 ] =readb (info->regs +S3C2410_NFECC +0 );
@@ -637,9 +638,10 @@ static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,return 0 ; } -static int s3c2412_nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat, -u_char *ecc_code) +static int s3c2412_nand_calculate_ecc (struct nand_chip *chip, +const u_char *dat,u_char *ecc_code) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);unsigned long ecc =readl (info->regs +S3C2412_NFMECC0 );
@@ -652,9 +654,10 @@ static int s3c2412_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,return 0 ; } -static int s3c2440_nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat, -u_char *ecc_code) +static int s3c2440_nand_calculate_ecc (struct nand_chip *chip, +const u_char *dat,u_char *ecc_code) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);unsigned long ecc =readl (info->regs +S3C2440_NFMECC0 );
drivers/mtd/nand/raw/sharpsl.c +3 -2
@@ -91,9 +91,10 @@ static void sharpsl_nand_enable_hwecc(struct nand_chip *chip, int mode)writeb (0 , sharpsl->io +ECCCLRR ); } -static int sharpsl_nand_calculate_ecc (struct mtd_info *mtd,const u_char * dat,u_char * ecc_code) +static int sharpsl_nand_calculate_ecc (struct nand_chip *chip, +const u_char * dat,u_char * ecc_code) { -struct sharpsl_nand *sharpsl =mtd_to_sharpsl (mtd); +struct sharpsl_nand *sharpsl =mtd_to_sharpsl (nand_to_mtd (chip)); ecc_code[0 ] = ~readb (sharpsl->io +ECCLPUB ); ecc_code[1 ] = ~readb (sharpsl->io +ECCLPLB ); ecc_code[2 ] = (~readb (sharpsl->io +ECCCP ) <<2 ) |0x03 ;
drivers/mtd/nand/raw/tmio_nand.c +3 -3
@@ -268,10 +268,10 @@ static void tmio_nand_enable_hwecc(struct nand_chip *chip, int mode)tmio_iowrite8 (FCR_MODE_HWECC_CALC , tmio->fcr +FCR_MODE ); } -static int tmio_nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat, -u_char *ecc_code) +static int tmio_nand_calculate_ecc (struct nand_chip *chip,const u_char *dat, +u_char *ecc_code) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));unsigned int ecc;tmio_iowrite8 (FCR_MODE_HWECC_RESULT , tmio->fcr +FCR_MODE );
drivers/mtd/nand/raw/txx9ndfmc.c +2 -3
@@ -170,11 +170,10 @@ static int txx9ndfmc_dev_ready(struct mtd_info *mtd)return !(txx9ndfmc_read (dev,TXX9_NDFSR ) &TXX9_NDFSR_BUSY ); } -static int txx9ndfmc_calculate_ecc (struct mtd_info *mtd,const uint8_t *dat, +static int txx9ndfmc_calculate_ecc (struct nand_chip *chip,const uint8_t *dat,uint8_t *ecc_code) { -struct platform_device *dev =mtd_to_platdev (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));int eccbytes;u32 mcr =txx9ndfmc_read (dev,TXX9_NDFMCR );
include/linux/mtd/nand_bch.h +3 -2
@@ -12,6 +12,7 @@#define __MTD_NAND_BCH_H__struct mtd_info ; +struct nand_chip ;struct nand_bch_control ;#if defined(CONFIG_MTD_NAND_ECC_BCH )
@@ -21,7 +22,7 @@ static inline int mtd_nand_has_bch(void) { return 1; }/* * Calculate BCH ecc code */ -int nand_bch_calculate_ecc (struct mtd_info *mtd,const u_char *dat, +int nand_bch_calculate_ecc (struct nand_chip *chip,const u_char *dat,u_char *ecc_code);/*
@@ -43,7 +44,7 @@ void nand_bch_free(struct nand_bch_control *nbc);static inline int mtd_nand_has_bch (void ) {return 0 ; }static inline int -nand_bch_calculate_ecc (struct mtd_info *mtd,const u_char *dat, +nand_bch_calculate_ecc (struct nand_chip *chip,const u_char *dat,u_char *ecc_code) {return -1 ;
include/linux/mtd/nand_ecc.h +3 -1
@@ -14,6 +14,7 @@#define __MTD_NAND_ECC_H__struct mtd_info ; +struct nand_chip ;/* * Calculate 3 byte ECC code for eccsize byte block
@@ -24,7 +25,8 @@ void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,/* * Calculate 3 byte ECC code for 256/512 byte block */ -int nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat,u_char *ecc_code); +int nand_calculate_ecc (struct nand_chip *chip,const u_char *dat, +u_char *ecc_code);/* * Detect and correct a 1 bit error for eccsize byte block
include/linux/mtd/rawnand.h +2 -2
@@ -648,8 +648,8 @@ struct nand_ecc_ctrl {u8 *calc_buf;u8 *code_buf;void (*hwctl)(struct nand_chip *chip,int mode); -int (*calculate)(struct mtd_info *mtd,const uint8_t *dat, -uint8_t *ecc_code); +int (*calculate)(struct nand_chip *chip,const uint8_t *dat, +uint8_t *ecc_code);int (*correct)(struct mtd_info *mtd,uint8_t *dat,uint8_t *read_ecc,uint8_t *calc_ecc); int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH v2 7/23 mtd: rawnand: Pass a nand_chip object to ecc->correct()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one.
Now is ecc->correct()'s turn.
--- drivers/mtd/nand/raw/davinci_nand.c | 9 ++++----- drivers/mtd/nand/raw/diskonchip.c | 3 +-- drivers/mtd/nand/raw/fsmc_nand.c | 9 ++++----- drivers/mtd/nand/raw/jz4740_nand.c | 6 +++--- drivers/mtd/nand/raw/jz4780_nand.c | 4 ++-- drivers/mtd/nand/raw/lpc32xx_slc.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 10 +++++----- drivers/mtd/nand/raw/nand_bch.c | 5 ++--- drivers/mtd/nand/raw/nand_ecc.c | 7 +++---- drivers/mtd/nand/raw/omap2.c | 18 +++++++++--------- drivers/mtd/nand/raw/r852.c | 6 +++--- drivers/mtd/nand/raw/s3c2410.c | 3 ++- drivers/mtd/nand/raw/tmio_nand.c | 5 +++-- drivers/mtd/nand/raw/txx9ndfmc.c | 6 +++--- include/linux/mtd/nand_bch.h | 6 +++--- include/linux/mtd/nand_ecc.h | 4 ++-- include/linux/mtd/rawnand.h | 4 ++-- 17 files changed, 52 insertions(+), 55 deletions(-)
drivers/mtd/nand/raw/davinci_nand.c +4 -5
@@ -185,10 +185,9 @@ static int nand_davinci_calculate_1bit(struct nand_chip *chip,return 0 ; } -static int nand_davinci_correct_1bit (struct mtd_info *mtd,u_char *dat, +static int nand_davinci_correct_1bit (struct nand_chip *chip,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { -struct nand_chip *chip =mtd_to_nand (mtd);uint32_t eccNand = read_ecc[0 ] | (read_ecc[1 ] <<8 ) | (read_ecc[2 ] <<16 ); uint32_t eccCalc = calc_ecc[0] | (calc_ecc[1] << 8) |
@@ -303,11 +302,11 @@ static int nand_davinci_calculate_4bit(struct nand_chip *chip,/* Correct up to 4 bits in data we just read, using state left in the * hardware plus the ecc_code computed when it was first written. */ -static int nand_davinci_correct_4bit (struct mtd_info *mtd, -u_char *data,u_char *ecc_code,u_char *null) +static int nand_davinci_correct_4bit (struct nand_chip *chip,u_char *data, +u_char *ecc_code,u_char *null) {int i; -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (chip));unsigned short ecc10[8 ];unsigned short *ecc16;u32 syndrome[4 ];
drivers/mtd/nand/raw/diskonchip.c +1 -2
@@ -893,11 +893,10 @@ static int doc200x_calculate_ecc(struct nand_chip *this, const u_char *dat,return 0 ; } -static int doc200x_correct_data (struct mtd_info *mtd,u_char *dat, +static int doc200x_correct_data (struct nand_chip *this,u_char *dat,u_char *read_ecc,u_char *isnull) {int i, ret =0 ; -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;uint8_t calc_ecc[6 ];
drivers/mtd/nand/raw/fsmc_nand.c +4 -5
@@ -769,7 +769,7 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,memcpy (&ecc_code[i], oob, chip->ecc.bytes); chip->ecc.calculate (chip, p, &ecc_calc[i]); - stat = chip->ecc.correct (mtd, p, &ecc_code[i], &ecc_calc[i]); + stat = chip->ecc.correct (chip, p, &ecc_code[i], &ecc_calc[i]);if (stat <0 ) { mtd->ecc_stats.failed++; }else {
@@ -791,11 +791,10 @@ static int fsmc_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,* calc_ecc is a 104 bit information containing maximum of 8 error * offset informations of 13 bits each in 512 bytes of read data. */ -static int fsmc_bch8_correct_data (struct mtd_info *mtd,uint8_t *dat, -uint8_t *read_ecc,uint8_t *calc_ecc) +static int fsmc_bch8_correct_data (struct nand_chip *chip,uint8_t *dat, +uint8_t *read_ecc,uint8_t *calc_ecc) { -struct nand_chip *chip =mtd_to_nand (mtd); -struct fsmc_nand_data *host =mtd_to_fsmc (mtd); +struct fsmc_nand_data *host =mtd_to_fsmc (nand_to_mtd (chip));uint32_t err_idx[8 ];uint32_t num_err, i;uint32_t ecc1, ecc2, ecc3, ecc4;
drivers/mtd/nand/raw/jz4740_nand.c +3 -3
@@ -215,10 +215,10 @@ static void jz_nand_correct_data(uint8_t *dat, int index, int mask) dat[index+1 ] = (data >>8 ) &0xff ; } -static int jz_nand_correct_ecc_rs (struct mtd_info *mtd,uint8_t *dat, -uint8_t *read_ecc,uint8_t *calc_ecc) +static int jz_nand_correct_ecc_rs (struct nand_chip *chip,uint8_t *dat, +uint8_t *read_ecc,uint8_t *calc_ecc) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));int i, error_count, index;uint32_t reg, status, error;unsigned int timeout =1000 ;
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -144,10 +144,10 @@ static int jz4780_nand_ecc_calculate(struct nand_chip *chip, const u8 *dat,return jz4780_bch_calculate (nfc->bch, ¶ms, dat, ecc_code); } -static int jz4780_nand_ecc_correct (struct mtd_info *mtd,u8 *dat, +static int jz4780_nand_ecc_correct (struct nand_chip *chip,u8 *dat,u8 *read_ecc,u8 *calc_ecc) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip));struct jz4780_nand_controller *nfc =to_jz4780_nand_controller (nand->chip.controller);struct jz4780_bch_params params;
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -1
@@ -639,7 +639,7 @@ static int lpc32xx_nand_read_page_syndrome(struct mtd_info *mtd, oobecc = chip->oob_poi + oobregion.offset;for (i =0 ; i < chip->ecc.steps; i++) { - stat = chip->ecc.correct (mtd, buf, oobecc, + stat = chip->ecc.correct (chip, buf, oobecc, &tmpecc[i * chip->ecc.bytes]);if (stat <0 ) mtd->ecc_stats.failed++;
drivers/mtd/nand/raw/nand_base.c +5 -5
@@ -3123,7 +3123,7 @@ static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {int stat; - stat = chip->ecc.correct (mtd, p, &ecc_code[i], &ecc_calc[i]); + stat = chip->ecc.correct (chip, p, &ecc_code[i], &ecc_calc[i]);if (stat <0 ) { mtd->ecc_stats.failed++; }else {
@@ -3224,7 +3224,7 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) {int stat; - stat = chip->ecc.correct (mtd, p, &chip->ecc.code_buf[i], + stat = chip->ecc.correct (chip, p, &chip->ecc.code_buf[i], &chip->ecc.calc_buf[i]);if (stat == -EBADMSG && (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) {
@@ -3296,7 +3296,7 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {int stat; - stat = chip->ecc.correct (mtd, p, &ecc_code[i], &ecc_calc[i]); + stat = chip->ecc.correct (chip, p, &ecc_code[i], &ecc_calc[i]);if (stat == -EBADMSG && (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) {/* check for empty pages with bitflips */
@@ -3366,7 +3366,7 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, chip->ecc.calculate (chip, p, &ecc_calc[i]); - stat = chip->ecc.correct (mtd, p, &ecc_code[i],NULL ); + stat = chip->ecc.correct (chip, p, &ecc_code[i],NULL );if (stat == -EBADMSG && (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) {/* check for empty pages with bitflips */
@@ -3436,7 +3436,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,if (ret)return ret; - stat = chip->ecc.correct (mtd, p, oob,NULL ); + stat = chip->ecc.correct (chip, p, oob,NULL ); oob += eccbytes;
drivers/mtd/nand/raw/nand_bch.c +2 -3
@@ -66,17 +66,16 @@ EXPORT_SYMBOL(nand_bch_calculate_ecc);/** * nand_bch_correct_data - [NAND Interface] Detect and correct bit error(s) -* @mtd: MTD block structure +* @chip: NAND chip object * @buf: raw data read from the chip * @read_ecc: ECC from the chip * @calc_ecc: the ECC calculated from raw data * * Detect and correct bit errors for a data byte block */ -int nand_bch_correct_data (struct mtd_info *mtd,unsigned char *buf, +int nand_bch_correct_data (struct nand_chip *chip,unsigned char *buf,unsigned char *read_ecc,unsigned char *calc_ecc) { -const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int *errloc = nbc->errloc;int i, count;
drivers/mtd/nand/raw/nand_ecc.c +3 -4
@@ -490,18 +490,17 @@ EXPORT_SYMBOL(__nand_correct_data);/** * nand_correct_data - [NAND Interface] Detect and correct bit error(s) -* @mtd: MTD block structure +* @chip: NAND chip object * @buf: raw data read from the chip * @read_ecc: ECC from the chip * @calc_ecc: the ECC calculated from raw data * * Detect and correct a 1 bit error for 256/512 byte block */ -int nand_correct_data (struct mtd_info *mtd,unsigned char *buf, +int nand_correct_data (struct nand_chip *chip,unsigned char *buf,unsigned char *read_ecc,unsigned char *calc_ecc) { -return __nand_correct_data (buf, read_ecc, calc_ecc, -mtd_to_nand (mtd)->ecc.size); +return __nand_correct_data (buf, read_ecc, calc_ecc, chip->ecc.size); }EXPORT_SYMBOL (nand_correct_data);
drivers/mtd/nand/raw/omap2.c +9 -9
@@ -857,7 +857,7 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory *//** * omap_correct_data - Compares the ECC read with HW generated ECC -* @mtd: MTD device structure +* @chip: NAND chip object * @dat: page data * @read_ecc: ecc read from nand flash * @calc_ecc: ecc read from HW ECC registers
@@ -869,10 +869,10 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */* corrected errors is returned. If uncorrectable errors exist, %-1 is * returned. */ -static int omap_correct_data (struct mtd_info *mtd,u_char *dat, -u_char *read_ecc,u_char *calc_ecc) +static int omap_correct_data (struct nand_chip *chip,u_char *dat, +u_char *read_ecc,u_char *calc_ecc) { -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));int blockCnt =0 , i =0 , ret =0 ;int stat =0 ;
@@ -1338,7 +1338,7 @@ static int erased_sector_bitflips(u_char *data, u_char *oob,/** * omap_elm_correct_data - corrects page data area in case error reported -* @mtd: MTD device structure +* @chip: NAND chip object * @data: page data * @read_ecc: ecc read from nand flash * @calc_ecc: ecc read from HW ECC registers
@@ -1347,10 +1347,10 @@ static int erased_sector_bitflips(u_char *data, u_char *oob,* In case of non-zero ecc vector, first filter out erased-pages, and * then process data via ELM to detect bit-flips. */ -static int omap_elm_correct_data (struct mtd_info *mtd,u_char *data, -u_char *read_ecc,u_char *calc_ecc) +static int omap_elm_correct_data (struct nand_chip *chip,u_char *data, +u_char *read_ecc,u_char *calc_ecc) { -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));struct nand_ecc_ctrl *ecc = &info->nand.ecc;int eccsteps = info->nand.ecc.steps;int i , j, stat =0 ;
@@ -1659,7 +1659,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,if (ret)return ret; - stat = chip->ecc.correct (mtd, buf, ecc_code, ecc_calc); + stat = chip->ecc.correct (chip, buf, ecc_code, ecc_calc);if (stat <0 ) { mtd->ecc_stats.failed++;
drivers/mtd/nand/raw/r852.c +3 -3
@@ -465,14 +465,14 @@ static int r852_ecc_calculate(struct nand_chip *chip, const uint8_t *dat,* Correct the data using ECC, hw did almost everything for us */ -static int r852_ecc_correct (struct mtd_info *mtd,uint8_t *dat, -uint8_t *read_ecc,uint8_t *calc_ecc) +static int r852_ecc_correct (struct nand_chip *chip,uint8_t *dat, +uint8_t *read_ecc,uint8_t *calc_ecc) {uint32_t ecc_reg;uint8_t ecc_status, err_byte;int i, error =0 ; -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));if (dev->card_unstable)return 0 ;
drivers/mtd/nand/raw/s3c2410.c +2 -1
@@ -512,9 +512,10 @@ static int s3c2412_nand_devready(struct mtd_info *mtd)/* ECC handling functions */ -static int s3c2410_nand_correct_data (struct mtd_info *mtd,u_char *dat, +static int s3c2410_nand_correct_data (struct nand_chip *chip,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);unsigned int diff0, diff1, diff2;unsigned int bit, byte;
drivers/mtd/nand/raw/tmio_nand.c +3 -2
@@ -290,8 +290,9 @@ static int tmio_nand_calculate_ecc(struct nand_chip *chip, const u_char *dat,return 0 ; } -static int tmio_nand_correct_data (struct mtd_info *mtd,unsigned char *buf, -unsigned char *read_ecc,unsigned char *calc_ecc) +static int tmio_nand_correct_data (struct nand_chip *chip,unsigned char *buf, +unsigned char *read_ecc, +unsigned char *calc_ecc) {int r0, r1;
drivers/mtd/nand/raw/txx9ndfmc.c +3 -3
@@ -190,10 +190,10 @@ static int txx9ndfmc_calculate_ecc(struct nand_chip *chip, const uint8_t *dat,return 0 ; } -static int txx9ndfmc_correct_data (struct mtd_info *mtd,unsigned char *buf, -unsigned char *read_ecc,unsigned char *calc_ecc) +static int txx9ndfmc_correct_data (struct nand_chip *chip,unsigned char *buf, +unsigned char *read_ecc, +unsigned char *calc_ecc) { -struct nand_chip *chip =mtd_to_nand (mtd);int eccsize;int corrected =0 ;int stat;
include/linux/mtd/nand_bch.h +3 -3
@@ -28,8 +28,8 @@ int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,/* * Detect and correct bit errors */ -int nand_bch_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc, -u_char *calc_ecc); +int nand_bch_correct_data (struct nand_chip *chip,u_char *dat, +u_char *read_ecc,u_char *calc_ecc);/* * Initialize BCH encoder/decoder */
@@ -51,7 +51,7 @@ nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat, }static inline int -nand_bch_correct_data (struct mtd_info *mtd,unsigned char *buf, +nand_bch_correct_data (struct nand_chip *chip,unsigned char *buf,unsigned char *read_ecc,unsigned char *calc_ecc) {return -ENOTSUPP ;
include/linux/mtd/nand_ecc.h +2 -2
@@ -13,7 +13,6 @@#ifndef __MTD_NAND_ECC_H__#define __MTD_NAND_ECC_H__ -struct mtd_info ;struct nand_chip ;/*
@@ -37,6 +36,7 @@ int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,/* * Detect and correct a 1 bit error for 256/512 byte block */ -int nand_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *calc_ecc); +int nand_correct_data (struct nand_chip *chip,u_char *dat,u_char *read_ecc, +u_char *calc_ecc);#endif /* __MTD_NAND_ECC_H__ */
include/linux/mtd/rawnand.h +2 -2
@@ -650,8 +650,8 @@ struct nand_ecc_ctrl {void (*hwctl)(struct nand_chip *chip,int mode);int (*calculate)(struct nand_chip *chip,const uint8_t *dat,uint8_t *ecc_code); -int (*correct)(struct mtd_info *mtd,uint8_t *dat,uint8_t *read_ecc, -uint8_t *calc_ecc); +int (*correct)(struct nand_chip *chip,uint8_t *dat,uint8_t *read_ecc, +uint8_t *calc_ecc);int (*read_page_raw)(struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page); int (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH v2 8/23 mtd: rawnand: Pass a nand_chip object to ecc->read_xxx() hooks
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle all ecc->read_xxx() hooks at once.
---
Changes in v2:
- Add Stefan A-b
- Patched the Toshiba driver
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 12 ++--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 21 ++++---- drivers/mtd/nand/raw/cafe_nand.c | 10 ++-- drivers/mtd/nand/raw/denali.c | 17 +++--- drivers/mtd/nand/raw/docg4.c | 20 ++++---- drivers/mtd/nand/raw/fsl_elbc_nand.c | 5 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 5 +- drivers/mtd/nand/raw/fsmc_nand.c | 6 +-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 23 ++++----- drivers/mtd/nand/raw/hisi504_nand.c | 9 ++-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 10 ++-- drivers/mtd/nand/raw/lpc32xx_slc.c | 14 ++--- drivers/mtd/nand/raw/marvell_nand.c | 30 +++++------ drivers/mtd/nand/raw/mtk_nand.c | 23 +++++---- drivers/mtd/nand/raw/mxc_nand.c | 11 ++-- drivers/mtd/nand/raw/nand_base.c | 74 +++++++++++++-------------- drivers/mtd/nand/raw/nand_micron.c | 6 +-- drivers/mtd/nand/raw/nand_toshiba.c | 10 ++-- drivers/mtd/nand/raw/omap2.c | 6 +-- drivers/mtd/nand/raw/qcom_nandc.c | 11 ++-- drivers/mtd/nand/raw/r852.c | 5 +- drivers/mtd/nand/raw/sh_flctl.c | 6 ++- drivers/mtd/nand/raw/sunxi_nand.c | 26 +++++----- drivers/mtd/nand/raw/tango_nand.c | 16 +++--- drivers/mtd/nand/raw/tegra_nand.c | 15 +++--- drivers/mtd/nand/raw/vf610_nfc.c | 18 +++---- drivers/staging/mt29f_spinand/mt29f_spinand.c | 5 +- include/linux/mtd/rawnand.h | 30 +++++------ 28 files changed, 221 insertions(+), 223 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -8
@@ -895,15 +895,13 @@ static int atmel_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,return ret; } -static int atmel_nand_pmecc_read_page (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int atmel_nand_pmecc_read_page (struct nand_chip *chip,u8 *buf,int oob_required,int page) {return atmel_nand_pmecc_read_pg (chip, buf, oob_required, page, false); } -static int atmel_nand_pmecc_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int atmel_nand_pmecc_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) {return atmel_nand_pmecc_read_pg (chip, buf, oob_required, page, true);
@@ -1037,16 +1035,14 @@ static int atmel_hsmc_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,return ret; } -static int atmel_hsmc_nand_pmecc_read_page (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int atmel_hsmc_nand_pmecc_read_page (struct nand_chip *chip,u8 *buf,int oob_required,int page) {return atmel_hsmc_nand_pmecc_read_pg (chip, buf, oob_required, page, false); } -static int atmel_hsmc_nand_pmecc_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int atmel_hsmc_nand_pmecc_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) {
drivers/mtd/nand/raw/brcmnand/brcmnand.c +12 -9
@@ -1689,7 +1689,7 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, sas = mtd->oobsize / chip->ecc.steps;/* read without ecc for verification */ - ret = chip->ecc.read_page_raw (mtd, chip, buf, true, page); + ret = chip->ecc.read_page_raw (chip, buf, true, page);if (ret)return ret;
@@ -1786,9 +1786,10 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } -static int brcmnand_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int brcmnand_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);u8 *oob = oob_required ? (u8 *)chip->oob_poi :NULL ;
@@ -1798,10 +1799,11 @@ static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip, mtd->writesize >> FC_SHIFT, (u32 *)buf, oob); } -static int brcmnand_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int brcmnand_read_page_raw (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) {struct brcmnand_host *host =nand_get_controller_data (chip); +struct mtd_info *mtd =nand_to_mtd (chip);u8 *oob = oob_required ? (u8 *)chip->oob_poi :NULL ;int ret;
@@ -1814,17 +1816,18 @@ static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return ret; } -static int brcmnand_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int brcmnand_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return brcmnand_read (mtd, chip, (u64 )page << chip->page_shift, mtd->writesize >>FC_SHIFT ,NULL , (u8 *)chip->oob_poi); } -static int brcmnand_read_oob_raw (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int brcmnand_read_oob_raw (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);brcmnand_set_ecc_enabled (host,0 );
drivers/mtd/nand/raw/cafe_nand.c +6 -4
@@ -354,9 +354,10 @@ static int cafe_nand_write_oob(struct mtd_info *mtd, }/* Don't use -- use nand_read_oob_std for now */ -static int cafe_nand_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int cafe_nand_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return nand_read_oob_op (chip, page,0 , chip->oob_poi, mtd->oobsize); }/**
@@ -369,9 +370,10 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip,* The hw generator calculates the error syndrome automatically. Therefore * we need a special oob layout and handling. */ -static int cafe_nand_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int cafe_nand_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct cafe_priv *cafe =nand_get_controller_data (chip);unsigned int max_bitflips =0 ;
drivers/mtd/nand/raw/denali.c +10 -7
@@ -676,9 +676,10 @@ static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip, false); } -static int denali_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int denali_read_page_raw (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd);int writesize = mtd->writesize;int oobsize = mtd->oobsize;
@@ -751,9 +752,10 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } -static int denali_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int denali_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +denali_oob_xfer (mtd, chip, page,0 );return 0 ;
@@ -771,9 +773,10 @@ static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip,return nand_prog_page_end_op (chip); } -static int denali_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int denali_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd);unsigned long uncor_ecc_flags =0 ;int stat =0 ;
@@ -792,7 +795,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,return stat;if (uncor_ecc_flags) { - ret =denali_read_oob (mtd, chip, page); + ret =denali_read_oob (chip, page);if (ret)return ret;
drivers/mtd/nand/raw/docg4.c +10 -10
@@ -845,21 +845,21 @@ static int read_page(struct mtd_info *mtd, struct nand_chip *nand, } -static int docg4_read_page_raw (struct mtd_info *mtd,struct nand_chip *nand, -uint8_t *buf,int oob_required,int page) +static int docg4_read_page_raw (struct nand_chip *nand,uint8_t *buf, +int oob_required,int page) { -return read_page (mtd, nand, buf, page, false); +return read_page (nand_to_mtd (nand), nand, buf, page, false); } -static int docg4_read_page (struct mtd_info *mtd,struct nand_chip *nand, -uint8_t *buf,int oob_required,int page) +static int docg4_read_page (struct nand_chip *nand,uint8_t *buf, +int oob_required,int page) { -return read_page (mtd, nand, buf, page, true); +return read_page (nand_to_mtd (nand), nand, buf, page, true); } -static int docg4_read_oob (struct mtd_info *mtd,struct nand_chip *nand, -int page) +static int docg4_read_oob (struct nand_chip *nand,int page) { +struct mtd_info *mtd =nand_to_mtd (nand);struct docg4_priv *doc =nand_get_controller_data (nand);void __iomem *docptr = doc->virtadr;uint16_t status;
@@ -1059,7 +1059,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)return -ENOMEM ;read_page_prologue (mtd, g4_addr); -docg4_read_page (mtd, nand, buf,0 ,DOCG4_FACTORY_BBT_PAGE ); +docg4_read_page (nand, buf,0 ,DOCG4_FACTORY_BBT_PAGE );/* * If no memory-based bbt was created, exit. This will happen if module
@@ -1077,7 +1077,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)* It is stored redundantly, so we get another chance. */ eccfailed_stats = mtd->ecc_stats.failed; -docg4_read_page (mtd, nand, buf,0 ,DOCG4_REDUNDANT_BBT_PAGE ); +docg4_read_page (nand, buf,0 ,DOCG4_REDUNDANT_BBT_PAGE );if (mtd->ecc_stats.failed > eccfailed_stats) {dev_warn (doc->dev,"The factory bbt could not be read!\n" );
drivers/mtd/nand/raw/fsl_elbc_nand.c +3 -2
@@ -710,9 +710,10 @@ static const struct nand_controller_ops fsl_elbc_controller_ops = { .attach_chip = fsl_elbc_attach_chip, }; -static int fsl_elbc_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int fsl_elbc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_lbc_ctrl *ctrl = priv->ctrl;struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
drivers/mtd/nand/raw/fsl_ifc_nand.c +3 -2
@@ -679,9 +679,10 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)return bitflips; } -static int fsl_ifc_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int fsl_ifc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
drivers/mtd/nand/raw/fsmc_nand.c +3 -3
@@ -707,7 +707,6 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,/* * fsmc_read_page_hwecc -* @mtd: mtd info structure * @chip: nand chip info structure * @buf: buffer to store read data * @oob_required: caller expects OOB data read to chip->oob_poi
@@ -719,9 +718,10 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,* After this read, fsmc hardware generates and reports error data bits(up to a * max of 8 bits) */ -static int fsmc_read_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int fsmc_read_page_hwecc (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int i, j, s, stat, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccsteps = chip->ecc.steps;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +11 -12
@@ -1085,8 +1085,8 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip,return max_bitflips; } -static int gpmi_ecc_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int gpmi_ecc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) {nand_read_page_op (chip, page,0 ,NULL ,0 );
@@ -1094,8 +1094,8 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, }/* Fake a virtual small page for the subpage read */ -static int gpmi_ecc_read_subpage (struct mtd_info *mtd,struct nand_chip *chip, -uint32_t offs,uint32_t len,uint8_t *buf,int page) +static int gpmi_ecc_read_subpage (struct nand_chip *chip,uint32_t offs, +uint32_t len,uint8_t *buf,int page) {struct gpmi_nand_data *this =nand_get_controller_data (chip);void __iomem *bch_regs = this->resources.bch_regs;
@@ -1130,7 +1130,7 @@ static int gpmi_ecc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,dev_dbg (this->dev,"page:%d, first:%d, last:%d, marker at:%d\n" , page, first, last, marker_pos); -return gpmi_ecc_read_page (mtd, chip, buf,0 , page); +return gpmi_ecc_read_page (chip, buf,0 , page); } }
@@ -1324,9 +1324,9 @@ static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,* ECC-based or raw view of the page is implicit in which function it calls * (there is a similar pair of ECC-based/raw functions for writing). */ -static int gpmi_ecc_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int gpmi_ecc_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct gpmi_nand_data *this =nand_get_controller_data (chip);dev_dbg (this->dev,"page number is %d\n" , page);
@@ -1380,10 +1380,10 @@ gpmi_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, int page)* See set_geometry_by_ecc_info inline comments to have a full description * of the layout used by the GPMI controller. */ -static int gpmi_ecc_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf, +static int gpmi_ecc_read_page_raw (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry;int eccsize = nfc_geo->ecc_chunk_size;
@@ -1536,10 +1536,9 @@ static int gpmi_ecc_write_page_raw(struct mtd_info *mtd, mtd->writesize + mtd->oobsize); } -static int gpmi_ecc_read_oob_raw (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int gpmi_ecc_read_oob_raw (struct nand_chip *chip,int page) { -return gpmi_ecc_read_page_raw (mtd, chip,NULL ,1 , page); +return gpmi_ecc_read_page_raw (chip,NULL ,1 , page); } static int gpmi_ecc_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip,
drivers/mtd/nand/raw/hisi504_nand.c +5 -4
@@ -528,9 +528,10 @@ static irqreturn_t hinfc_irq_handle(int irq, void *devid)return IRQ_HANDLED ; } -static int hisi_nand_read_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf,int oob_required,int page) +static int hisi_nand_read_page_hwecc (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct hinfc_host *host =nand_get_controller_data (chip);int max_bitflips =0 , stat =0 , stat_max =0 , status_ecc;int stat_1, stat_2;
@@ -560,9 +561,9 @@ static int hisi_nand_read_page_hwecc(struct mtd_info *mtd,return max_bitflips; } -static int hisi_nand_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int hisi_nand_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct hinfc_host *host =nand_get_controller_data (chip);nand_read_oob_op (chip, page,0 , chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/raw/lpc32xx_mlc.c +5 -5
@@ -442,9 +442,10 @@ static int lpc32xx_xmit_dma(struct mtd_info *mtd, void *mem, int len,return -ENXIO ; } -static int lpc32xx_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int lpc32xx_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);int i, j;uint8_t *oobbuf = chip->oob_poi;
@@ -557,13 +558,12 @@ static int lpc32xx_write_page_lowlevel(struct mtd_info *mtd,return nand_prog_page_end_op (chip); } -static int lpc32xx_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int lpc32xx_read_oob (struct nand_chip *chip,int page) {struct lpc32xx_nand_host *host =nand_get_controller_data (chip);/* Read whole page - necessary with MLC controller! */ -lpc32xx_read_page (mtd, chip, host->dummy_buf,1 , page); +lpc32xx_read_page (chip, host->dummy_buf,1 , page);return 0 ; }
drivers/mtd/nand/raw/lpc32xx_slc.c +8 -6
@@ -396,9 +396,10 @@ static void lpc32xx_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int/* * Read the OOB data from the device without ECC using FIFO method */ -static int lpc32xx_nand_read_oob_syndrome (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int lpc32xx_nand_read_oob_syndrome (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return nand_read_oob_op (chip, page,0 , chip->oob_poi, mtd->oobsize); }
@@ -610,10 +611,10 @@ static int lpc32xx_xfer(struct mtd_info *mtd, uint8_t *buf, int eccsubpages,* Read the data and OOB data from the device, use ECC correction with the * data, disable ECC for the OOB data */ -static int lpc32xx_nand_read_page_syndrome (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf, +static int lpc32xx_nand_read_page_syndrome (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);struct mtd_oob_region oobregion = { };int stat, i, status, error;
@@ -657,11 +658,12 @@ static int lpc32xx_nand_read_page_syndrome(struct mtd_info *mtd,* Read the data and OOB data from the device, no ECC correction with the * data or OOB data */ -static int lpc32xx_nand_read_page_raw_syndrome (struct mtd_info *mtd, -struct nand_chip *chip, +static int lpc32xx_nand_read_page_raw_syndrome (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +/* Issue read command */ nand_read_page_op (chip, page,0 ,NULL ,0 );
drivers/mtd/nand/raw/marvell_nand.c +12 -18
@@ -1026,18 +1026,15 @@ static int marvell_nfc_hw_ecc_hmg_do_read_page(struct nand_chip *chip,return ret; } -static int marvell_nfc_hw_ecc_hmg_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int marvell_nfc_hw_ecc_hmg_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) {return marvell_nfc_hw_ecc_hmg_do_read_page (chip, buf, chip->oob_poi, true, page); } -static int marvell_nfc_hw_ecc_hmg_read_page (struct mtd_info *mtd, -struct nand_chip *chip, -u8 *buf,int oob_required, -int page) +static int marvell_nfc_hw_ecc_hmg_read_page (struct nand_chip *chip,u8 *buf, +int oob_required,int page) {const struct marvell_hw_ecc_layout *lt =to_marvell_nand (chip)->layout;unsigned int full_sz = lt->data_bytes + lt->spare_bytes + lt->ecc_bytes;
@@ -1075,8 +1072,7 @@ static int marvell_nfc_hw_ecc_hmg_read_page(struct mtd_info *mtd,* it appears before the ECC bytes when reading), the ->read_oob_raw() function * also stands for ->read_oob(). */ -static int marvell_nfc_hw_ecc_hmg_read_oob_raw (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int marvell_nfc_hw_ecc_hmg_read_oob_raw (struct nand_chip *chip,int page) {/* Invalidate page cache */ chip->pagebuf =-1 ;
@@ -1183,10 +1179,10 @@ static int marvell_nfc_hw_ecc_hmg_write_oob_raw(struct mtd_info *mtd, }/* BCH read helpers */ -static int marvell_nfc_hw_ecc_bch_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int marvell_nfc_hw_ecc_bch_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);const struct marvell_hw_ecc_layout *lt =to_marvell_nand (chip)->layout;u8 *oob = chip->oob_poi;int chunk_size = lt->data_bytes + lt->spare_bytes + lt->ecc_bytes;
@@ -1295,11 +1291,11 @@ static void marvell_nfc_hw_ecc_bch_read_chunk(struct nand_chip *chip, int chunk, } } -static int marvell_nfc_hw_ecc_bch_read_page (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_bch_read_page (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);const struct marvell_hw_ecc_layout *lt =to_marvell_nand (chip)->layout;int data_len = lt->data_bytes, spare_len = lt->spare_bytes, ecc_len;u8 *data = buf, *spare = chip->oob_poi, *ecc;
@@ -1392,22 +1388,20 @@ static int marvell_nfc_hw_ecc_bch_read_page(struct mtd_info *mtd,return max_bitflips; } -static int marvell_nfc_hw_ecc_bch_read_oob_raw (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int marvell_nfc_hw_ecc_bch_read_oob_raw (struct nand_chip *chip,int page) {/* Invalidate page cache */ chip->pagebuf =-1 ; -return chip->ecc.read_page_raw (mtd, chip, chip->data_buf, true, page); +return chip->ecc.read_page_raw (chip, chip->data_buf, true, page); } -static int marvell_nfc_hw_ecc_bch_read_oob (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int marvell_nfc_hw_ecc_bch_read_oob (struct nand_chip *chip,int page) {/* Invalidate page cache */ chip->pagebuf =-1 ; -return chip->ecc.read_page (mtd, chip, chip->data_buf, true, page); +return chip->ecc.read_page (chip, chip->data_buf, true, page); }/* BCH write helpers */
drivers/mtd/nand/raw/mtk_nand.c +12 -11
@@ -969,23 +969,25 @@ static int mtk_nfc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,return bitflips; } -static int mtk_nfc_read_subpage_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,u32 off, +static int mtk_nfc_read_subpage_hwecc (struct nand_chip *chip,u32 off,u32 len,u8 *p,int pg) { -return mtk_nfc_read_subpage (mtd, chip, off, len, p, pg,0 ); +return mtk_nfc_read_subpage (nand_to_mtd (chip), chip, off, len, p, pg, +0 ); } -static int mtk_nfc_read_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,u8 *p, -int oob_on,int pg) +static int mtk_nfc_read_page_hwecc (struct nand_chip *chip,u8 *p,int oob_on, +int pg) { +struct mtd_info *mtd =nand_to_mtd (chip); +return mtk_nfc_read_subpage (mtd, chip,0 , mtd->writesize, p, pg,0 ); } -static int mtk_nfc_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -u8 *buf,int oob_on,int page) +static int mtk_nfc_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_on, +int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mtk_nfc_nand_chip *mtk_nand =to_mtk_nand (chip);struct mtk_nfc *nfc =nand_get_controller_data (chip);struct mtk_nfc_fdm *fdm = &mtk_nand->fdm;
@@ -1011,10 +1013,9 @@ static int mtk_nfc_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return ret; } -static int mtk_nfc_read_oob_std (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int mtk_nfc_read_oob_std (struct nand_chip *chip,int page) { -return mtk_nfc_read_page_raw (mtd, chip,NULL ,1 , page); +return mtk_nfc_read_page_raw (chip,NULL ,1 , page); }static inline void mtk_nfc_hw_init (struct mtk_nfc *nfc)
drivers/mtd/nand/raw/mxc_nand.c +5 -6
@@ -816,8 +816,8 @@ static int mxc_nand_read_page_v2_v3(struct nand_chip *chip, void *buf,return max_bitflips; } -static int mxc_nand_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int mxc_nand_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) {struct mxc_nand_host *host =nand_get_controller_data (chip);void *oob_buf;
@@ -830,8 +830,8 @@ static int mxc_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,return host->devtype_data->read_page (chip, buf, oob_buf,1 , page); } -static int mxc_nand_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int mxc_nand_read_page_raw (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) {struct mxc_nand_host *host =nand_get_controller_data (chip);void *oob_buf;
@@ -844,8 +844,7 @@ static int mxc_nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return host->devtype_data->read_page (chip, buf, oob_buf,0 , page); } -static int mxc_nand_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int mxc_nand_read_oob (struct nand_chip *chip,int page) {struct mxc_nand_host *host =nand_get_controller_data (chip);
drivers/mtd/nand/raw/nand_base.c +35 -39
227 lines not on this page · raw message
drivers/mtd/nand/raw/nand_micron.c +3 -3
@@ -290,10 +290,10 @@ static int micron_nand_on_die_ecc_status_8(struct nand_chip *chip, u8 status) }static int -micron_nand_read_page_on_die_ecc (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required, -int page) +micron_nand_read_page_on_die_ecc (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);u8 status;int ret, max_bitflips =0 ;
drivers/mtd/nand/raw/nand_toshiba.c +5 -5
@@ -48,13 +48,13 @@ static int toshiba_nand_benand_eccstatus(struct mtd_info *mtd, }static int -toshiba_nand_read_page_benand (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf, +toshiba_nand_read_page_benand (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int ret; - ret =nand_read_page_raw (mtd, chip, buf, oob_required, page); + ret =nand_read_page_raw (chip, buf, oob_required, page);if (ret)return ret;
@@ -62,10 +62,10 @@ toshiba_nand_read_page_benand(struct mtd_info *mtd, }static int -toshiba_nand_read_subpage_benand (struct mtd_info *mtd, -struct nand_chip *chip,uint32_t data_offs, +toshiba_nand_read_subpage_benand (struct nand_chip *chip,uint32_t data_offs,uint32_t readlen,uint8_t *bufpoi,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int ret; ret = nand_read_page_op(chip, page, data_offs,
drivers/mtd/nand/raw/omap2.c +3 -3
@@ -1616,7 +1616,6 @@ static int omap_write_subpage_bch(struct mtd_info *mtd,/** * omap_read_page_bch - BCH ecc based page read function for entire page -* @mtd: mtd info structure * @chip: nand chip info structure * @buf: buffer to store read data * @oob_required: caller requires OOB data read to chip->oob_poi
@@ -1629,9 +1628,10 @@ static int omap_write_subpage_bch(struct mtd_info *mtd,* ecc engine enabled. ecc vector updated after read of OOB data. * For non error pages ecc vector reported as zero. */ -static int omap_read_page_bch (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int omap_read_page_bch (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);uint8_t *ecc_calc = chip->ecc.calc_buf;uint8_t *ecc_code = chip->ecc.code_buf;int stat, ret;
drivers/mtd/nand/raw/qcom_nandc.c +5 -6
@@ -1948,8 +1948,8 @@ static int copy_last_cw(struct qcom_nand_host *host, int page) }/* implements ecc->read_page() */ -static int qcom_nandc_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int qcom_nandc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) {struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);
@@ -1965,10 +1965,10 @@ static int qcom_nandc_read_page(struct mtd_info *mtd, struct nand_chip *chip, }/* implements ecc->read_page_raw() */ -static int qcom_nandc_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf, +static int qcom_nandc_read_page_raw (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;int cw, ret;
@@ -1988,8 +1988,7 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd, }/* implements ecc->read_oob() */ -static int qcom_nandc_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int qcom_nandc_read_oob (struct nand_chip *chip,int page) {struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);
drivers/mtd/nand/raw/r852.c +3 -2
@@ -521,9 +521,10 @@ static int r852_ecc_correct(struct nand_chip *chip, uint8_t *dat,* This is copy of nand_read_oob_std * nand_read_oob_syndrome assumes we can send column address - we can't */ -static int r852_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int r852_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return nand_read_oob_op (chip, page,0 , chip->oob_poi, mtd->oobsize); }
drivers/mtd/nand/raw/sh_flctl.c +4 -2
@@ -611,9 +611,11 @@ static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_vawritel (flcmcdr_val,FLCMCDR (flctl)); } -static int flctl_read_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int flctl_read_page_hwecc (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_read_page_op (chip, page,0 , buf, mtd->writesize);if (oob_required) chip->read_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/raw/sunxi_nand.c +12 -14
@@ -1189,10 +1189,10 @@ static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd, *cur_off = mtd->oobsize + mtd->writesize; } -static int sunxi_nfc_hw_ecc_read_page (struct mtd_info *mtd, -struct nand_chip *chip,uint8_t *buf, +static int sunxi_nfc_hw_ecc_read_page (struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;unsigned int max_bitflips =0 ;int ret, i, cur_off =0 ;
@@ -1227,10 +1227,10 @@ static int sunxi_nfc_hw_ecc_read_page(struct mtd_info *mtd,return max_bitflips; } -static int sunxi_nfc_hw_ecc_read_page_dma (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int sunxi_nfc_hw_ecc_read_page_dma (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int ret;nand_read_page_op (chip, page,0 ,NULL ,0 );
@@ -1241,14 +1241,14 @@ static int sunxi_nfc_hw_ecc_read_page_dma(struct mtd_info *mtd,return ret;/* Fallback to PIO mode */ -return sunxi_nfc_hw_ecc_read_page (mtd, chip, buf, oob_required, page); +return sunxi_nfc_hw_ecc_read_page (chip, buf, oob_required, page); } -static int sunxi_nfc_hw_ecc_read_subpage (struct mtd_info *mtd, -struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_read_subpage (struct nand_chip *chip,u32 data_offs,u32 readlen,u8 *bufpoi,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;int ret, i, cur_off =0 ;unsigned int max_bitflips =0 ;
@@ -1278,11 +1278,11 @@ static int sunxi_nfc_hw_ecc_read_subpage(struct mtd_info *mtd,return max_bitflips; } -static int sunxi_nfc_hw_ecc_read_subpage_dma (struct mtd_info *mtd, -struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_read_subpage_dma (struct nand_chip *chip,u32 data_offs,u32 readlen,u8 *buf,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int nchunks =DIV_ROUND_UP (data_offs + readlen, chip->ecc.size);int ret;
@@ -1293,7 +1293,7 @@ static int sunxi_nfc_hw_ecc_read_subpage_dma(struct mtd_info *mtd,return ret;/* Fallback to PIO mode */ -return sunxi_nfc_hw_ecc_read_subpage (mtd, chip, data_offs, readlen, +return sunxi_nfc_hw_ecc_read_subpage (chip, data_offs, readlen, buf, page); }
@@ -1428,13 +1428,11 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct mtd_info *mtd,return sunxi_nfc_hw_ecc_write_page (mtd, chip, buf, oob_required, page); } -static int sunxi_nfc_hw_ecc_read_oob (struct mtd_info *mtd, -struct nand_chip *chip, -int page) +static int sunxi_nfc_hw_ecc_read_oob (struct nand_chip *chip,int page) { chip->pagebuf =-1 ; -return chip->ecc.read_page (mtd, chip, chip->data_buf,1 , page); +return chip->ecc.read_page (chip, chip->data_buf,1 , page); } static int sunxi_nfc_hw_ecc_write_oob(struct mtd_info *mtd,
drivers/mtd/nand/raw/tango_nand.c +8 -8
@@ -277,14 +277,15 @@ static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd,return err; } -static int tango_read_page (struct mtd_info *mtd,struct nand_chip *chip, -u8 *buf,int oob_required,int page) +static int tango_read_page (struct nand_chip *chip,u8 *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct tango_nfc *nfc =to_tango_nfc (chip->controller);int err, res, len = mtd->writesize;if (oob_required) - chip->ecc.read_oob (mtd, chip, page); + chip->ecc.read_oob (chip, page); err =do_dma (nfc,DMA_FROM_DEVICE ,NFC_READ , buf, len, page);if (err)
@@ -292,7 +293,7 @@ static int tango_read_page(struct mtd_info *mtd, struct nand_chip *chip, res =decode_error_report (chip);if (res <0 ) { - chip->ecc.read_oob_raw (mtd, chip, page); + chip->ecc.read_oob_raw (chip, page); res =check_erased_page (chip, buf); }
@@ -424,8 +425,8 @@ static void raw_write(struct nand_chip *chip, const u8 *buf, const u8 *oob)aux_write (chip, &oob, ecc_size, &pos); } -static int tango_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -u8 *buf,int oob_required,int page) +static int tango_read_page_raw (struct nand_chip *chip,u8 *buf, +int oob_required,int page) {nand_read_page_op (chip, page,0 ,NULL ,0 );raw_read (chip, buf, chip->oob_poi);
@@ -440,8 +441,7 @@ static int tango_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return nand_prog_page_end_op (chip); } -static int tango_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int tango_read_oob (struct nand_chip *chip,int page) {nand_read_page_op (chip, page,0 ,NULL ,0 );raw_read (chip,NULL , chip->oob_poi);
drivers/mtd/nand/raw/tegra_nand.c +8 -7
@@ -615,10 +615,10 @@ static int tegra_nand_page_xfer(struct mtd_info *mtd, struct nand_chip *chip,return ret; } -static int tegra_nand_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int tegra_nand_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);void *oob_buf = oob_required ? chip->oob_poi :NULL ; return tegra_nand_page_xfer(mtd, chip, buf, oob_buf,
@@ -635,9 +635,10 @@ static int tegra_nand_write_page_raw(struct mtd_info *mtd, mtd->oobsize, page, false); } -static int tegra_nand_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int tegra_nand_read_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return tegra_nand_page_xfer (mtd, chip,NULL , chip->oob_poi, mtd->oobsize, page, true); }
@@ -649,10 +650,10 @@ static int tegra_nand_write_oob(struct mtd_info *mtd, struct nand_chip *chip, mtd->oobsize, page, false); } -static int tegra_nand_read_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int tegra_nand_read_page_hwecc (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct tegra_nand_controller *ctrl =to_tegra_ctrl (chip->controller);struct tegra_nand_chip *nand =to_tegra_chip (chip);void *oob_buf = oob_required ? chip->oob_poi :NULL ;
@@ -716,7 +717,7 @@ static int tegra_nand_read_page_hwecc(struct mtd_info *mtd,* erased or if error correction just failed for all sub- * pages. */ - ret =tegra_nand_read_oob (mtd, chip, page); + ret =tegra_nand_read_oob (chip, page);if (ret <0 )return ret;
drivers/mtd/nand/raw/vf610_nfc.c +9 -9
@@ -557,9 +557,10 @@ static void vf610_nfc_fill_row(struct nand_chip *chip, int page, u32 *code, } } -static int vf610_nfc_read_page (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page) +static int vf610_nfc_read_page (struct nand_chip *chip,uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct vf610_nfc *nfc =mtd_to_nfc (mtd);int trfr_sz = mtd->writesize + mtd->oobsize;u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;
@@ -643,15 +644,15 @@ static int vf610_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } -static int vf610_nfc_read_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,u8 *buf, +static int vf610_nfc_read_page_raw (struct nand_chip *chip,u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct vf610_nfc *nfc =mtd_to_nfc (mtd);int ret; nfc->data_access = true; - ret =nand_read_page_raw (mtd, chip, buf, oob_required, page); + ret =nand_read_page_raw (chip, buf, oob_required, page); nfc->data_access = false;return ret;
@@ -677,14 +678,13 @@ static int vf610_nfc_write_page_raw(struct mtd_info *mtd,return nand_prog_page_end_op (chip); } -static int vf610_nfc_read_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int vf610_nfc_read_oob (struct nand_chip *chip,int page) { -struct vf610_nfc *nfc =mtd_to_nfc (mtd); +struct vf610_nfc *nfc =mtd_to_nfc (nand_to_mtd (chip));int ret; nfc->data_access = true; - ret =nand_read_oob_std (mtd, chip, page); + ret =nand_read_oob_std (chip, page); nfc->data_access = false;return ret;
drivers/staging/mt29f_spinand/mt29f_spinand.c +3 -2
@@ -643,14 +643,15 @@ static int spinand_write_page_hwecc(struct mtd_info *mtd,return nand_prog_page_op (chip, page,0 , p, eccsize * eccsteps); } -static int spinand_read_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -u8 *buf,int oob_required,int page) +static int spinand_read_page_hwecc (struct nand_chip *chip,u8 *buf, +int oob_required,int page) {int retval;u8 status;u8 *p = buf;int eccsize = chip->ecc.size;int eccsteps = chip->ecc.steps; +struct mtd_info *mtd =nand_to_mtd (chip);struct spinand_info *info =nand_get_controller_data (chip); enable_read_hw_ecc =1 ;
include/linux/mtd/rawnand.h +14 -16
@@ -652,14 +652,14 @@ struct nand_ecc_ctrl { uint8_t *ecc_code);int (*correct)(struct nand_chip *chip,uint8_t *dat,uint8_t *read_ecc,uint8_t *calc_ecc); -int (*read_page_raw)(struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page); +int (*read_page_raw)(struct nand_chip *chip,uint8_t *buf, +int oob_required,int page);int (*write_page_raw)(struct mtd_info *mtd,struct nand_chip *chip,const uint8_t *buf,int oob_required,int page); -int (*read_page)(struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page); -int (*read_subpage)(struct mtd_info *mtd,struct nand_chip *chip, -uint32_t offs,uint32_t len,uint8_t *buf,int page); +int (*read_page)(struct nand_chip *chip,uint8_t *buf, +int oob_required,int page); +int (*read_subpage)(struct nand_chip *chip,uint32_t offs, +uint32_t len,uint8_t *buf,int page);int (*write_subpage)(struct mtd_info *mtd,struct nand_chip *chip,uint32_t offset,uint32_t data_len,const uint8_t *data_buf,int oob_required,int page);
@@ -667,9 +667,8 @@ struct nand_ecc_ctrl { const uint8_t *buf, int oob_required, int page);int (*write_oob_raw)(struct mtd_info *mtd,struct nand_chip *chip,int page); -int (*read_oob_raw)(struct mtd_info *mtd,struct nand_chip *chip, -int page); -int (*read_oob)(struct mtd_info *mtd,struct nand_chip *chip,int page); +int (*read_oob_raw)(struct nand_chip *chip,int page); +int (*read_oob)(struct nand_chip *chip,int page);int (*write_oob)(struct mtd_info *mtd,struct nand_chip *chip,int page); };
@@ -1676,11 +1675,10 @@ int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, int page);/* Default read_oob implementation */ -int nand_read_oob_std (struct mtd_info *mtd,struct nand_chip *chip,int page); +int nand_read_oob_std (struct nand_chip *chip,int page);/* Default read_oob syndrome implementation */ -int nand_read_oob_syndrome (struct mtd_info *mtd,struct nand_chip *chip, -int page); +int nand_read_oob_syndrome (struct nand_chip *chip,int page);/* Wrapper to use in order for controllers/vendors to GET/SET FEATURES */ int nand_get_features (struct nand_chip *chip,int addr,u8 *subfeature_param);
@@ -1690,10 +1688,10 @@ int nand_get_set_features_notsupp(struct mtd_info *mtd, struct nand_chip *chip, int addr, u8 *subfeature_param);/* Default read_page_raw implementation */ -int nand_read_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -uint8_t *buf,int oob_required,int page); -int nand_read_page_raw_notsupp (struct mtd_info *mtd,struct nand_chip *chip, -u8 *buf,int oob_required,int page); +int nand_read_page_raw (struct nand_chip *chip,uint8_t *buf,int oob_required, +int page); +int nand_read_page_raw_notsupp (struct nand_chip *chip,u8 *buf, +int oob_required,int page);/* Default write_page_raw implementation */ int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH v2 9/23 mtd: rawnand: Pass a nand_chip object to ecc->write_xxx() hooks
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle all ecc->write_xxx() hooks at once.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 12 ++--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 21 ++++---- drivers/mtd/nand/raw/cafe_nand.c | 13 ++--- drivers/mtd/nand/raw/denali.c | 14 ++--- drivers/mtd/nand/raw/docg4.c | 17 +++--- drivers/mtd/nand/raw/fsl_elbc_nand.c | 14 +++-- drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 ++- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 21 ++++---- drivers/mtd/nand/raw/hisi504_nand.c | 8 +-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 7 ++- drivers/mtd/nand/raw/lpc32xx_slc.c | 14 ++--- drivers/mtd/nand/raw/marvell_nand.c | 32 ++++++------ drivers/mtd/nand/raw/mtk_nand.c | 19 ++++--- drivers/mtd/nand/raw/mxc_nand.c | 13 +++-- drivers/mtd/nand/raw/nand_base.c | 74 ++++++++++++--------------- drivers/mtd/nand/raw/nand_ecc.c | 2 +- drivers/mtd/nand/raw/nand_micron.c | 7 ++- drivers/mtd/nand/raw/omap2.c | 11 ++-- drivers/mtd/nand/raw/qcom_nandc.c | 15 +++--- drivers/mtd/nand/raw/sh_flctl.c | 7 +-- drivers/mtd/nand/raw/sunxi_nand.c | 21 ++++---- drivers/mtd/nand/raw/tango_nand.c | 12 ++--- drivers/mtd/nand/raw/tegra_nand.c | 13 ++--- drivers/mtd/nand/raw/vf610_nfc.c | 13 ++--- drivers/staging/mt29f_spinand/mt29f_spinand.c | 3 +- include/linux/mtd/rawnand.h | 33 ++++++------ 26 files changed, 208 insertions(+), 214 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -8
@@ -858,15 +858,13 @@ static int atmel_nand_pmecc_write_pg(struct nand_chip *chip, const u8 *buf,return nand_prog_page_end_op (chip); } -static int atmel_nand_pmecc_write_page (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf, +static int atmel_nand_pmecc_write_page (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {return atmel_nand_pmecc_write_pg (chip, buf, oob_required, page, false); } -static int atmel_nand_pmecc_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int atmel_nand_pmecc_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
@@ -963,8 +961,7 @@ static int atmel_hsmc_nand_pmecc_write_pg(struct nand_chip *chip,return ret; } -static int atmel_hsmc_nand_pmecc_write_page (struct mtd_info *mtd, -struct nand_chip *chip, +static int atmel_hsmc_nand_pmecc_write_page (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
@@ -972,8 +969,7 @@ static int atmel_hsmc_nand_pmecc_write_page(struct mtd_info *mtd, false); } -static int atmel_hsmc_nand_pmecc_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int atmel_hsmc_nand_pmecc_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
drivers/mtd/nand/raw/brcmnand/brcmnand.c +11 -10
@@ -1909,9 +1909,10 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,return ret; } -static int brcmnand_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int brcmnand_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);void *oob = oob_required ? chip->oob_poi :NULL ;
@@ -1921,10 +1922,10 @@ static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip,return nand_prog_page_end_op (chip); } -static int brcmnand_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf, +static int brcmnand_write_page_raw (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);void *oob = oob_required ? chip->oob_poi :NULL ;
@@ -1936,16 +1937,16 @@ static int brcmnand_write_page_raw(struct mtd_info *mtd,return nand_prog_page_end_op (chip); } -static int brcmnand_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int brcmnand_write_oob (struct nand_chip *chip,int page) { -return brcmnand_write (mtd, chip, (u64 )page << chip->page_shift, -NULL , chip->oob_poi); +return brcmnand_write (nand_to_mtd (chip), chip, + (u64 )page << chip->page_shift,NULL , + chip->oob_poi); } -static int brcmnand_write_oob_raw (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int brcmnand_write_oob_raw (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);int ret;
drivers/mtd/nand/raw/cafe_nand.c +7 -6
@@ -346,9 +346,10 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id)return IRQ_HANDLED ; } -static int cafe_nand_write_oob (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int cafe_nand_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return nand_prog_page_op (chip, page, mtd->writesize, chip->oob_poi, mtd->oobsize); }
@@ -533,11 +534,11 @@ static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { }; -static int cafe_nand_write_page_lowlevel (struct mtd_info *mtd, -struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +static int cafe_nand_write_page_lowlevel (struct nand_chip *chip, +const uint8_t *buf,int oob_required, +int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct cafe_priv *cafe =nand_get_controller_data (chip);nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize);
drivers/mtd/nand/raw/denali.c +8 -6
@@ -761,9 +761,9 @@ static int denali_read_oob(struct nand_chip *chip, int page)return 0 ; } -static int denali_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int denali_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd);denali_reset_irq (denali);
@@ -806,9 +806,10 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf,return stat; } -static int denali_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int denali_write_page_raw (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd);int writesize = mtd->writesize;int oobsize = mtd->oobsize;
@@ -884,9 +885,10 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,return denali_data_xfer (denali, tmp_buf, size, page,1 ,1 ); } -static int denali_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int denali_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd); return denali_data_xfer(denali, (void *)buf, mtd->writesize,
drivers/mtd/nand/raw/docg4.c +8 -9
@@ -1007,20 +1007,19 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *nand,return nand_prog_page_end_op (nand); } -static int docg4_write_page_raw (struct mtd_info *mtd,struct nand_chip *nand, -const uint8_t *buf,int oob_required,int page) +static int docg4_write_page_raw (struct nand_chip *nand,const uint8_t *buf, +int oob_required,int page) { -return write_page (mtd, nand, buf, page, false); +return write_page (nand_to_mtd (nand), nand, buf, page, false); } -static int docg4_write_page (struct mtd_info *mtd,struct nand_chip *nand, -const uint8_t *buf,int oob_required,int page) +static int docg4_write_page (struct nand_chip *nand,const uint8_t *buf, +int oob_required,int page) { -return write_page (mtd, nand, buf, page, true); +return write_page (nand_to_mtd (nand), nand, buf, page, true); } -static int docg4_write_oob (struct mtd_info *mtd,struct nand_chip *nand, -int page) +static int docg4_write_oob (struct nand_chip *nand,int page) {/* * Writing oob-only is not really supported, because MLC nand must write
@@ -1144,7 +1143,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)/* write first page of block */ write_page_prologue (mtd, g4_addr); -docg4_write_page (mtd, nand, buf,1 , page); +docg4_write_page (nand, buf,1 , page); ret =pageprog (mtd);kfree (buf);
drivers/mtd/nand/raw/fsl_elbc_nand.c +9 -5
@@ -731,9 +731,11 @@ static int fsl_elbc_read_page(struct nand_chip *chip, uint8_t *buf,/* ECC will be calculated automatically, and errors will be detected in * waitfunc. */ -static int fsl_elbc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int fsl_elbc_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize);fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
@@ -743,10 +745,12 @@ static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,/* ECC will be calculated automatically, and errors will be detected in * waitfunc. */ -static int fsl_elbc_write_subpage (struct mtd_info *mtd,struct nand_chip *chip, -uint32_t offset,uint32_t data_len, -const uint8_t *buf,int oob_required,int page) +static int fsl_elbc_write_subpage (struct nand_chip *chip,uint32_t offset, +uint32_t data_len,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_prog_page_begin_op (chip, page,0 ,NULL ,0 );fsl_elbc_write_buf (mtd, buf, mtd->writesize);fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/raw/fsl_ifc_nand.c +4 -2
@@ -707,9 +707,11 @@ static int fsl_ifc_read_page(struct nand_chip *chip, uint8_t *buf,/* ECC will be calculated automatically, and errors will be detected in * waitfunc. */ -static int fsl_ifc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int fsl_ifc_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize);fsl_ifc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +10 -11
@@ -1182,9 +1182,10 @@ static int gpmi_ecc_read_subpage(struct nand_chip *chip, uint32_t offs,return max_bitflips; } -static int gpmi_ecc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int gpmi_ecc_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry;const void *payload_virt;
@@ -1351,9 +1352,9 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)return 0 ; } -static int -gpmi_ecc_write_oob (struct mtd_info *mtd,struct nand_chip *chip,int page) +static int gpmi_ecc_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mtd_oob_region of = { };/* Do we have available oob area? */
@@ -1464,11 +1465,10 @@ static int gpmi_ecc_read_page_raw(struct nand_chip *chip, uint8_t *buf,* See set_geometry_by_ecc_info inline comments to have a full description * of the layout used by the GPMI controller. */ -static int gpmi_ecc_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, -const uint8_t *buf, +static int gpmi_ecc_write_page_raw (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct gpmi_nand_data *this =nand_get_controller_data (chip);struct bch_geometry *nfc_geo = &this->bch_geometry;int eccsize = nfc_geo->ecc_chunk_size;
@@ -1541,10 +1541,9 @@ static int gpmi_ecc_read_oob_raw(struct nand_chip *chip, int page)return gpmi_ecc_read_page_raw (chip,NULL ,1 , page); } -static int gpmi_ecc_write_oob_raw (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int gpmi_ecc_write_oob_raw (struct nand_chip *chip,int page) { -return gpmi_ecc_write_page_raw (mtd, chip,NULL ,1 , page); +return gpmi_ecc_write_page_raw (chip,NULL ,1 , page); }static int gpmi_block_markbad (struct mtd_info *mtd,loff_t ofs)
@@ -1715,7 +1714,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)/* Write the first page of the current stride. */ dev_dbg (dev,"Writing an NCB fingerprint in page 0x%x\n" , page); - status = chip->ecc.write_page_raw (mtd, chip, buffer,0 , page); + status = chip->ecc.write_page_raw (chip, buffer,0 , page);if (status)dev_err (dev,"[%s] Write failed.\n" , __func__); }
drivers/mtd/nand/raw/hisi504_nand.c +5 -3
@@ -577,10 +577,12 @@ static int hisi_nand_read_oob(struct nand_chip *chip, int page)return 0 ; } -static int hisi_nand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required, -int page) +static int hisi_nand_write_page_hwecc (struct nand_chip *chip, +const uint8_t *buf,int oob_required, +int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize);if (oob_required) chip->write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/raw/lpc32xx_mlc.c +3 -4
@@ -508,11 +508,11 @@ static int lpc32xx_read_page(struct nand_chip *chip, uint8_t *buf,return 0 ; } -static int lpc32xx_write_page_lowlevel (struct mtd_info *mtd, -struct nand_chip *chip, +static int lpc32xx_write_page_lowlevel (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);const uint8_t *oobbuf = chip->oob_poi;uint8_t *dma_buf = (uint8_t *)buf;
@@ -568,8 +568,7 @@ static int lpc32xx_read_oob(struct nand_chip *chip, int page)return 0 ; } -static int lpc32xx_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int lpc32xx_write_oob (struct nand_chip *chip,int page) {/* None, write_oob conflicts with the automatic LPC MLC ECC decoder! */ return 0 ;
drivers/mtd/nand/raw/lpc32xx_slc.c +8 -6
@@ -406,9 +406,10 @@ static int lpc32xx_nand_read_oob_syndrome(struct nand_chip *chip, int page)/* * Write the OOB data to the device without ECC using FIFO method */ -static int lpc32xx_nand_write_oob_syndrome (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int lpc32xx_nand_write_oob_syndrome (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return nand_prog_page_op (chip, page, mtd->writesize, chip->oob_poi, mtd->oobsize); }
@@ -678,11 +679,11 @@ static int lpc32xx_nand_read_page_raw_syndrome(struct nand_chip *chip,* Write the data and OOB data to the device, use ECC with the data, * disable ECC for the OOB data */ -static int lpc32xx_nand_write_page_syndrome (struct mtd_info *mtd, -struct nand_chip *chip, +static int lpc32xx_nand_write_page_syndrome (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);struct mtd_oob_region oobregion = { };uint8_t *pb;
@@ -716,11 +717,12 @@ static int lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,* Write the data and OOB data to the device, no ECC correction with the * data or OOB data */ -static int lpc32xx_nand_write_page_raw_syndrome (struct mtd_info *mtd, -struct nand_chip *chip, +static int lpc32xx_nand_write_page_raw_syndrome (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +/* Raw writes can just use the FIFO interface */ nand_prog_page_begin_op (chip, page,0 , buf, chip->ecc.size * chip->ecc.steps);
drivers/mtd/nand/raw/marvell_nand.c +16 -16
@@ -1136,8 +1136,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,return ret; } -static int marvell_nfc_hw_ecc_hmg_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_hmg_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
@@ -1145,8 +1144,7 @@ static int marvell_nfc_hw_ecc_hmg_write_page_raw(struct mtd_info *mtd, true, page); } -static int marvell_nfc_hw_ecc_hmg_write_page (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_hmg_write_page (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
@@ -1165,10 +1163,11 @@ static int marvell_nfc_hw_ecc_hmg_write_page(struct mtd_info *mtd,* it appears before the ECC bytes when reading), the ->write_oob_raw() function * also stands for ->write_oob(). */ -static int marvell_nfc_hw_ecc_hmg_write_oob_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_hmg_write_oob_raw (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +/* Invalidate page cache */ chip->pagebuf =-1 ;
@@ -1405,8 +1404,7 @@ static int marvell_nfc_hw_ecc_bch_read_oob(struct nand_chip *chip, int page) }/* BCH write helpers */ -static int marvell_nfc_hw_ecc_bch_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_bch_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
@@ -1519,11 +1517,11 @@ marvell_nfc_hw_ecc_bch_write_chunk(struct nand_chip *chip, int chunk,return 0 ; } -static int marvell_nfc_hw_ecc_bch_write_page (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_bch_write_page (struct nand_chip *chip,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);const struct marvell_hw_ecc_layout *lt =to_marvell_nand (chip)->layout;const u8 *data = buf;const u8 *spare = chip->oob_poi;
@@ -1568,27 +1566,29 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,return 0 ; } -static int marvell_nfc_hw_ecc_bch_write_oob_raw (struct mtd_info *mtd, -struct nand_chip *chip, +static int marvell_nfc_hw_ecc_bch_write_oob_raw (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +/* Invalidate page cache */ chip->pagebuf =-1 ;memset (chip->data_buf,0xFF , mtd->writesize); -return chip->ecc.write_page_raw (mtd, chip, chip->data_buf, true, page); +return chip->ecc.write_page_raw (chip, chip->data_buf, true, page); } -static int marvell_nfc_hw_ecc_bch_write_oob (struct mtd_info *mtd, -struct nand_chip *chip,int page) +static int marvell_nfc_hw_ecc_bch_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +/* Invalidate page cache */ chip->pagebuf =-1 ;memset (chip->data_buf,0xFF , mtd->writesize); -return chip->ecc.write_page (mtd, chip, chip->data_buf, true, page); +return chip->ecc.write_page (chip, chip->data_buf, true, page); }/* NAND framework ->exec_op() hooks and related helpers */
drivers/mtd/nand/raw/mtk_nand.c +9 -10
@@ -807,27 +807,27 @@ static int mtk_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,return nand_prog_page_end_op (chip); } -static int mtk_nfc_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf, +static int mtk_nfc_write_page_hwecc (struct nand_chip *chip,const u8 *buf,int oob_on,int page) { -return mtk_nfc_write_page (mtd, chip, buf, page,0 ); +return mtk_nfc_write_page (nand_to_mtd (chip), chip, buf, page,0 ); } -static int mtk_nfc_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const u8 *buf,int oob_on,int pg) +static int mtk_nfc_write_page_raw (struct nand_chip *chip,const u8 *buf, +int oob_on,int pg) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mtk_nfc *nfc =nand_get_controller_data (chip);mtk_nfc_format_page (mtd, buf);return mtk_nfc_write_page (mtd, chip, nfc->buffer, pg,1 ); } -static int mtk_nfc_write_subpage_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,u32 offset, +static int mtk_nfc_write_subpage_hwecc (struct nand_chip *chip,u32 offset,u32 data_len,const u8 *buf,int oob_on,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mtk_nfc *nfc =nand_get_controller_data (chip);int ret;
@@ -839,10 +839,9 @@ static int mtk_nfc_write_subpage_hwecc(struct mtd_info *mtd,return mtk_nfc_write_page (mtd, chip, nfc->buffer, page,1 ); } -static int mtk_nfc_write_oob_std (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int mtk_nfc_write_oob_std (struct nand_chip *chip,int page) { -return mtk_nfc_write_page_raw (mtd, chip,NULL ,1 , page); +return mtk_nfc_write_page_raw (chip,NULL ,1 , page); }static int mtk_nfc_update_ecc_stats (struct mtd_info *mtd,u8 *buf,u32 sectors)
drivers/mtd/nand/raw/mxc_nand.c +6 -7
@@ -873,22 +873,21 @@ static int mxc_nand_write_page(struct nand_chip *chip, const uint8_t *buf,return 0 ; } -static int mxc_nand_write_page_ecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +static int mxc_nand_write_page_ecc (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) {return mxc_nand_write_page (chip, buf, true, page); } -static int mxc_nand_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int mxc_nand_write_page_raw (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) {return mxc_nand_write_page (chip, buf, false, page); } -static int mxc_nand_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int mxc_nand_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mxc_nand_host *host =nand_get_controller_data (chip);memset (host->data_buf,0xff , mtd->writesize);
drivers/mtd/nand/raw/nand_base.c +33 -41
203 lines not on this page · raw message
drivers/mtd/nand/raw/nand_ecc.c +1 -1
@@ -394,7 +394,7 @@ EXPORT_SYMBOL(__nand_calculate_ecc);/** * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte * block -* @mtd: MTD block structure +* @chip: NAND chip object * @buf: input buffer with raw data * @code: output buffer with ECC */
drivers/mtd/nand/raw/nand_micron.c +3 -4
@@ -332,9 +332,8 @@ micron_nand_read_page_on_die_ecc(struct nand_chip *chip, uint8_t *buf, }static int -micron_nand_write_page_on_die_ecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +micron_nand_write_page_on_die_ecc (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) {int ret;
@@ -342,7 +341,7 @@ micron_nand_write_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip,if (ret)return ret; - ret =nand_write_page_raw (mtd, chip, buf, oob_required, page); + ret =nand_write_page_raw (chip, buf, oob_required, page);micron_nand_on_die_ecc_setup (chip, false);return ret;
drivers/mtd/nand/raw/omap2.c +5 -6
@@ -1511,7 +1511,6 @@ static int omap_elm_correct_data(struct nand_chip *chip, u_char *data,/** * omap_write_page_bch - BCH ecc based write page function for entire page -* @mtd: mtd info structure * @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB
@@ -1519,9 +1518,10 @@ static int omap_elm_correct_data(struct nand_chip *chip, u_char *data,* * Custom write page method evolved to support multi sector writing in one shot */ -static int omap_write_page_bch (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int omap_write_page_bch (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int ret;uint8_t *ecc_calc = chip->ecc.calc_buf;
@@ -1549,7 +1549,6 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,/** * omap_write_subpage_bch - BCH hardware ECC based subpage write -* @mtd: mtd info structure * @chip: nand chip info structure * @offset: column address of subpage within the page * @data_len: data length
@@ -1559,11 +1558,11 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,* * OMAP optimized subpage write method. */ -static int omap_write_subpage_bch (struct mtd_info *mtd, -struct nand_chip *chip,u32 offset, +static int omap_write_subpage_bch (struct nand_chip *chip,u32 offset,u32 data_len,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);u8 *ecc_calc = chip->ecc.calc_buf;int ecc_size = chip->ecc.size;int ecc_bytes = chip->ecc.bytes;
drivers/mtd/nand/raw/qcom_nandc.c +8 -7
@@ -2005,8 +2005,8 @@ static int qcom_nandc_read_oob(struct nand_chip *chip, int page) }/* implements ecc->write_page() */ -static int qcom_nandc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int qcom_nandc_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) {struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);
@@ -2075,10 +2075,11 @@ static int qcom_nandc_write_page(struct mtd_info *mtd, struct nand_chip *chip, }/* implements ecc->write_page_raw() */ -static int qcom_nandc_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf, -int oob_required,int page) +static int qcom_nandc_write_page_raw (struct nand_chip *chip, +const uint8_t *buf,int oob_required, +int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;
@@ -2153,9 +2154,9 @@ static int qcom_nandc_write_page_raw(struct mtd_info *mtd,* since ECC is calculated for the combined codeword. So update the OOB from * chip->oob_poi, and pad the data area with OxFF before writing. */ -static int qcom_nandc_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int qcom_nandc_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;
drivers/mtd/nand/raw/sh_flctl.c +4 -3
@@ -622,10 +622,11 @@ static int flctl_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,return 0 ; } -static int flctl_write_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +static int flctl_write_page_hwecc (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize); chip->write_buf (mtd, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip);
drivers/mtd/nand/raw/sunxi_nand.c +10 -11
@@ -1297,11 +1297,11 @@ static int sunxi_nfc_hw_ecc_read_subpage_dma(struct nand_chip *chip, buf, page); } -static int sunxi_nfc_hw_ecc_write_page (struct mtd_info *mtd, -struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_page (struct nand_chip *chip,const uint8_t *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;int ret, i, cur_off =0 ;
@@ -1331,12 +1331,12 @@ static int sunxi_nfc_hw_ecc_write_page(struct mtd_info *mtd,return nand_prog_page_end_op (chip); } -static int sunxi_nfc_hw_ecc_write_subpage (struct mtd_info *mtd, -struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_subpage (struct nand_chip *chip,u32 data_offs,u32 data_len,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;int ret, i, cur_off =0 ;
@@ -1363,12 +1363,12 @@ static int sunxi_nfc_hw_ecc_write_subpage(struct mtd_info *mtd,return nand_prog_page_end_op (chip); } -static int sunxi_nfc_hw_ecc_write_page_dma (struct mtd_info *mtd, -struct nand_chip *chip, +static int sunxi_nfc_hw_ecc_write_page_dma (struct nand_chip *chip,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct nand_ecc_ctrl *ecc = &nand->ecc;
@@ -1425,7 +1425,7 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct mtd_info *mtd,return nand_prog_page_end_op (chip); pio_fallback: -return sunxi_nfc_hw_ecc_write_page (mtd, chip, buf, oob_required, page); +return sunxi_nfc_hw_ecc_write_page (chip, buf, oob_required, page); }static int sunxi_nfc_hw_ecc_read_oob (struct nand_chip *chip,int page)
@@ -1435,16 +1435,15 @@ static int sunxi_nfc_hw_ecc_read_oob(struct nand_chip *chip, int page)return chip->ecc.read_page (chip, chip->data_buf,1 , page); } -static int sunxi_nfc_hw_ecc_write_oob (struct mtd_info *mtd, -struct nand_chip *chip, -int page) +static int sunxi_nfc_hw_ecc_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);int ret; chip->pagebuf =-1 ;memset (chip->data_buf,0xff , mtd->writesize); - ret = chip->ecc.write_page (mtd, chip, chip->data_buf,1 , page); + ret = chip->ecc.write_page (chip, chip->data_buf,1 , page);if (ret)return ret;
drivers/mtd/nand/raw/tango_nand.c +6 -6
@@ -300,9 +300,10 @@ static int tango_read_page(struct nand_chip *chip, u8 *buf,return res; } -static int tango_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const u8 *buf,int oob_required,int page) +static int tango_write_page (struct nand_chip *chip,const u8 *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct tango_nfc *nfc =to_tango_nfc (chip->controller);int err, status, len = mtd->writesize;
@@ -433,8 +434,8 @@ static int tango_read_page_raw(struct nand_chip *chip, u8 *buf,return 0 ; } -static int tango_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const u8 *buf,int oob_required,int page) +static int tango_write_page_raw (struct nand_chip *chip,const u8 *buf, +int oob_required,int page) {nand_prog_page_begin_op (chip, page,0 ,NULL ,0 );raw_write (chip, buf, chip->oob_poi);
@@ -448,8 +449,7 @@ static int tango_read_oob(struct nand_chip *chip, int page)return 0 ; } -static int tango_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int tango_write_oob (struct nand_chip *chip,int page) {nand_prog_page_begin_op (chip, page,0 ,NULL ,0 );raw_write (chip,NULL , chip->oob_poi);
drivers/mtd/nand/raw/tegra_nand.c +7 -6
@@ -625,10 +625,10 @@ static int tegra_nand_read_page_raw(struct nand_chip *chip, u8 *buf, mtd->oobsize, page, true); } -static int tegra_nand_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf, +static int tegra_nand_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);void *oob_buf = oob_required ? chip->oob_poi :NULL ; return tegra_nand_page_xfer(mtd, chip, (void *)buf, oob_buf,
@@ -643,9 +643,10 @@ static int tegra_nand_read_oob(struct nand_chip *chip, int page) mtd->oobsize, page, true); } -static int tegra_nand_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int tegra_nand_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip); +return tegra_nand_page_xfer (mtd, chip,NULL , chip->oob_poi, mtd->oobsize, page, false); }
@@ -760,10 +761,10 @@ static int tegra_nand_read_page_hwecc(struct nand_chip *chip, u8 *buf, } } -static int tegra_nand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf, +static int tegra_nand_write_page_hwecc (struct nand_chip *chip,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct tegra_nand_controller *ctrl =to_tegra_ctrl (chip->controller);void *oob_buf = oob_required ? chip->oob_poi :NULL ;int ret;
drivers/mtd/nand/raw/vf610_nfc.c +7 -6
@@ -603,9 +603,10 @@ static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf, } } -static int vf610_nfc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page) +static int vf610_nfc_write_page (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct vf610_nfc *nfc =mtd_to_nfc (mtd);int trfr_sz = mtd->writesize + mtd->oobsize;u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;
@@ -658,10 +659,10 @@ static int vf610_nfc_read_page_raw(struct nand_chip *chip, u8 *buf,return ret; } -static int vf610_nfc_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf, +static int vf610_nfc_write_page_raw (struct nand_chip *chip,const u8 *buf,int oob_required,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct vf610_nfc *nfc =mtd_to_nfc (mtd);int ret;
@@ -690,9 +691,9 @@ static int vf610_nfc_read_oob(struct nand_chip *chip, int page)return ret; } -static int vf610_nfc_write_oob (struct mtd_info *mtd,struct nand_chip *chip, -int page) +static int vf610_nfc_write_oob (struct nand_chip *chip,int page) { +struct mtd_info *mtd =nand_to_mtd (chip);struct vf610_nfc *nfc =mtd_to_nfc (mtd);int ret;
drivers/staging/mt29f_spinand/mt29f_spinand.c +1 -2
@@ -630,8 +630,7 @@ static int spinand_erase_block(struct spi_device *spi_nand, u16 block_id) }#ifdef CONFIG_MTD_SPINAND_ONDIEECC -static int spinand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip, +static int spinand_write_page_hwecc (struct nand_chip *chip,const u8 *buf,int oob_required,int page) {
include/linux/mtd/rawnand.h +15 -18
@@ -654,23 +654,21 @@ struct nand_ecc_ctrl { uint8_t *calc_ecc);int (*read_page_raw)(struct nand_chip *chip,uint8_t *buf,int oob_required,int page); -int (*write_page_raw)(struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page); +int (*write_page_raw)(struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page);int (*read_page)(struct nand_chip *chip,uint8_t *buf,int oob_required,int page);int (*read_subpage)(struct nand_chip *chip,uint32_t offs,uint32_t len,uint8_t *buf,int page); -int (*write_subpage)(struct mtd_info *mtd,struct nand_chip *chip, -uint32_t offset,uint32_t data_len, -const uint8_t *data_buf,int oob_required,int page); -int (*write_page)(struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page); -int (*write_oob_raw)(struct mtd_info *mtd,struct nand_chip *chip, -int page); +int (*write_subpage)(struct nand_chip *chip,uint32_t offset, +uint32_t data_len,const uint8_t *data_buf, +int oob_required,int page); +int (*write_page)(struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page); +int (*write_oob_raw)(struct nand_chip *chip,int page);int (*read_oob_raw)(struct nand_chip *chip,int page);int (*read_oob)(struct nand_chip *chip,int page); -int (*write_oob)(struct mtd_info *mtd,struct nand_chip *chip, -int page); +int (*write_oob)(struct nand_chip *chip,int page); };/**
@@ -1668,11 +1666,10 @@ int nand_ecc_choose_conf(struct nand_chip *chip, const struct nand_ecc_caps *caps, int oobavail);/* Default write_oob implementation */ -int nand_write_oob_std (struct mtd_info *mtd,struct nand_chip *chip,int page); +int nand_write_oob_std (struct nand_chip *chip,int page);/* Default write_oob syndrome implementation */ -int nand_write_oob_syndrome (struct mtd_info *mtd,struct nand_chip *chip, -int page); +int nand_write_oob_syndrome (struct nand_chip *chip,int page);/* Default read_oob implementation */ int nand_read_oob_std (struct nand_chip *chip,int page);
@@ -1694,10 +1691,10 @@ int nand_read_page_raw_notsupp(struct nand_chip *chip, u8 *buf, int oob_required, int page);/* Default write_page_raw implementation */ -int nand_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required,int page); -int nand_write_page_raw_notsupp (struct mtd_info *mtd,struct nand_chip *chip, -const u8 *buf,int oob_required,int page); +int nand_write_page_raw (struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page); +int nand_write_page_raw_notsupp (struct nand_chip *chip,const u8 *buf, +int oob_required,int page);/* Reset and initialize a NAND device */ int nand_reset (struct nand_chip *chip,int chipnr);
Signature · 1 line
2.14.1
PATCH v2 10/23 mtd: rawnand: Pass a nand_chip object to chip->read_xxx() hooks
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle all chip->read_xxx() hooks at once.
--- drivers/mtd/nand/raw/ams-delta.c | 7 ++-- drivers/mtd/nand/raw/atmel/nand-controller.c | 10 +++--- drivers/mtd/nand/raw/au1550nd.c | 15 ++++----- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 10 +++--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 7 ++-- drivers/mtd/nand/raw/cafe_nand.c | 10 +++--- drivers/mtd/nand/raw/cmx270_nand.c | 7 ++-- drivers/mtd/nand/raw/cs553x_nand.c | 7 ++-- drivers/mtd/nand/raw/davinci_nand.c | 5 ++- drivers/mtd/nand/raw/denali.c | 11 ++++--- drivers/mtd/nand/raw/diskonchip.c | 32 +++++++----------- drivers/mtd/nand/raw/docg4.c | 13 +++----- drivers/mtd/nand/raw/fsl_elbc_nand.c | 8 ++--- drivers/mtd/nand/raw/fsl_ifc_nand.c | 13 +++----- drivers/mtd/nand/raw/fsl_upm.c | 8 ++--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 16 ++++----- drivers/mtd/nand/raw/hisi504_nand.c | 8 ++--- drivers/mtd/nand/raw/lpc32xx_slc.c | 12 +++---- drivers/mtd/nand/raw/mpc5121_nfc.c | 8 ++--- drivers/mtd/nand/raw/mtk_nand.c | 7 ++-- drivers/mtd/nand/raw/mxc_nand.c | 10 +++--- drivers/mtd/nand/raw/nand_base.c | 41 ++++++++++-------------- drivers/mtd/nand/raw/nandsim.c | 8 ++--- drivers/mtd/nand/raw/ndfc.c | 3 +- drivers/mtd/nand/raw/nuc900_nand.c | 8 ++--- drivers/mtd/nand/raw/omap2.c | 24 ++++++++------ drivers/mtd/nand/raw/orion_nand.c | 3 +- drivers/mtd/nand/raw/oxnas_nand.c | 6 ++-- drivers/mtd/nand/raw/pasemi_nand.c | 4 +-- drivers/mtd/nand/raw/plat_nand.c | 11 +------ drivers/mtd/nand/raw/qcom_nandc.c | 6 ++-- drivers/mtd/nand/raw/r852.c | 8 ++--- drivers/mtd/nand/raw/s3c2410.c | 6 ++-- drivers/mtd/nand/raw/sh_flctl.c | 10 +++--- drivers/mtd/nand/raw/socrates_nand.c | 10 +++--- drivers/mtd/nand/raw/sunxi_nand.c | 11 +++---- drivers/mtd/nand/raw/tango_nand.c | 12 +++---- drivers/mtd/nand/raw/tmio_nand.c | 8 ++--- drivers/mtd/nand/raw/txx9ndfmc.c | 8 ++--- drivers/mtd/nand/raw/xway_nand.c | 8 ++--- drivers/staging/mt29f_spinand/mt29f_spinand.c | 10 +++--- include/linux/mtd/rawnand.h | 4 +-- 42 files changed, 186 insertions(+), 247 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +3 -4
@@ -75,10 +75,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)gpio_set_value (AMS_DELTA_GPIO_PIN_NAND_NWE ,1 ); } -static u_char ams_delta_read_byte (struct mtd_info *mtd) +static u_char ams_delta_read_byte (struct nand_chip *this) {u_char res; -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *io_base = (void __iomem *)nand_get_controller_data (this);gpio_set_value (AMS_DELTA_GPIO_PIN_NAND_NRE ,0 );
@@ -99,12 +98,12 @@ static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf,ams_delta_write_byte (mtd, buf[i]); } -static void ams_delta_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void ams_delta_read_buf (struct nand_chip *this,u_char *buf,int len) {int i;for (i=0 ; i<len; i++) - buf[i] =ams_delta_read_byte (mtd); + buf[i] =ams_delta_read_byte (this); }/*
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -6
@@ -410,9 +410,8 @@ static int atmel_nand_dma_transfer(struct atmel_nand_controller *nc,return -EIO ; } -static u8 atmel_nand_read_byte (struct mtd_info *mtd) +static u8 atmel_nand_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);return ioread8 (nand->activecs->io.virt);
@@ -429,9 +428,8 @@ static void atmel_nand_write_byte(struct mtd_info *mtd, u8 byte)iowrite8 (byte, nand->activecs->io.virt); } -static void atmel_nand_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void atmel_nand_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;
@@ -883,8 +881,8 @@ static int atmel_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,if (ret)return ret; -atmel_nand_read_buf (mtd, buf, mtd->writesize); -atmel_nand_read_buf (mtd, chip->oob_poi, mtd->oobsize); +atmel_nand_read_buf (chip, buf, mtd->writesize); +atmel_nand_read_buf (chip, chip->oob_poi, mtd->oobsize); ret =atmel_nand_pmecc_correct_data (chip, buf, raw);
drivers/mtd/nand/raw/au1550nd.c +6 -9
@@ -29,13 +29,12 @@ struct au1550nd_ctx {/** * au_read_byte - read one byte from the chip -* @mtd: MTD device structure +* @this: NAND chip object * * read function for 8bit buswidth */ -static u_char au_read_byte (struct mtd_info *mtd) +static u_char au_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);u_char ret =readb (this->IO_ADDR_R);wmb ();/* drain writebuffer */ return ret;
@@ -57,13 +56,12 @@ static void au_write_byte(struct mtd_info *mtd, u_char byte)/** * au_read_byte16 - read one byte endianness aware from the chip -* @mtd: MTD device structure +* @this: NAND chip object * * read function for 16bit buswidth with endianness conversion */ -static u_char au_read_byte16 (struct mtd_info *mtd) +static u_char au_read_byte16 (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);u_char ret = (u_char )cpu_to_le16 (readw (this->IO_ADDR_R));wmb ();/* drain writebuffer */ return ret;
@@ -104,16 +102,15 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)/** * au_read_buf - read chip data into buffer -* @mtd: MTD device structure +* @this: NAND chip object * @buf: buffer to store date * @len: number of bytes to read * * read function for 8bit buswidth */ -static void au_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void au_read_buf (struct nand_chip *this,u_char *buf,int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) { buf[i] =readb (this->IO_ADDR_R);
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +5 -5
@@ -310,9 +310,9 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, b47n->curr_command = command; } -static u8 bcm47xxnflash_ops_bcm4706_read_byte (struct mtd_info *mtd) +static u8 bcm47xxnflash_ops_bcm4706_read_byte (struct nand_chip *nand_chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand_chip);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);struct bcma_drv_cc *cc = b47n->cc;u32 tmp =0 ;
@@ -338,16 +338,16 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)return 0 ; } -static void bcm47xxnflash_ops_bcm4706_read_buf (struct mtd_info *mtd, +static void bcm47xxnflash_ops_bcm4706_read_buf (struct nand_chip *nand_chip,uint8_t *buf,int len) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);switch (b47n->curr_command) {case NAND_CMD_READ0 :case NAND_CMD_READOOB : -bcm47xxnflash_ops_bcm4706_read (mtd, buf, len); +bcm47xxnflash_ops_bcm4706_read (nand_to_mtd (nand_chip), buf, + len);return ; }
drivers/mtd/nand/raw/brcmnand/brcmnand.c +3 -4
@@ -1417,9 +1417,8 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,brcmnand_wp (mtd,1 ); } -static uint8_t brcmnand_read_byte (struct mtd_info *mtd) +static uint8_t brcmnand_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct brcmnand_host *host =nand_get_controller_data (chip);struct brcmnand_controller *ctrl = host->ctrl;uint8_t ret =0 ;
@@ -1474,12 +1473,12 @@ static uint8_t brcmnand_read_byte(struct mtd_info *mtd)return ret; } -static void brcmnand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void brcmnand_read_buf (struct nand_chip *chip,uint8_t *buf,int len) {int i;for (i =0 ; i < len; i++, buf++) - *buf =brcmnand_read_byte (mtd); + *buf =brcmnand_read_byte (chip); } static void brcmnand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
drivers/mtd/nand/raw/cafe_nand.c +4 -6
@@ -133,9 +133,8 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) len, cafe->datalen); } -static void cafe_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void cafe_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct cafe_priv *cafe =nand_get_controller_data (chip);if (cafe->usedma)
@@ -148,13 +147,12 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) cafe->datalen += len; } -static uint8_t cafe_read_byte (struct mtd_info *mtd) +static uint8_t cafe_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct cafe_priv *cafe =nand_get_controller_data (chip);uint8_t d; -cafe_read_buf (mtd, &d,1 ); +cafe_read_buf (chip, &d,1 );cafe_dev_dbg (&cafe->pdev->dev,"Read %02x\n" , d);return d;
@@ -383,7 +381,7 @@ static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf, cafe_readl(cafe, NAND_ECC_SYN01));nand_read_page_op (chip, page,0 , buf, mtd->writesize); - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);if (checkecc &&cafe_readl (cafe,NAND_ECC_RESULT ) & (1 <<18 )) {unsigned short syn[8 ], pat[4 ];
drivers/mtd/nand/raw/cmx270_nand.c +2 -5
@@ -49,10 +49,8 @@ static const struct mtd_partition partition_info[] = { };#define NUM_PARTITIONS (ARRAY_SIZE(partition_info)) -static u_char cmx270_read_byte (struct mtd_info *mtd) +static u_char cmx270_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd); -return (readl (this->IO_ADDR_R) >>16 ); }
@@ -65,10 +63,9 @@ static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len)writel ((*buf++ <<16 ), this->IO_ADDR_W); } -static void cmx270_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void cmx270_read_buf (struct nand_chip *this,u_char *buf,int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);for (i=0 ; i<len; i++) *buf++ =readl (this->IO_ADDR_R) >>16 ;
drivers/mtd/nand/raw/cs553x_nand.c +2 -5
@@ -93,10 +93,8 @@#define CS_NAND_ECC_CLRECC (1<<1)#define CS_NAND_ECC_ENECC (1<<0) -static void cs553x_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void cs553x_read_buf (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd); -while (unlikely (len >0x800 )) {memcpy_fromio (buf, this->IO_ADDR_R,0x800 ); buf +=0x800 ;
@@ -117,9 +115,8 @@ static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len)memcpy_toio (this->IO_ADDR_R, buf, len); } -static unsigned char cs553x_read_byte (struct mtd_info *mtd) +static unsigned char cs553x_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);return readb (this->IO_ADDR_R); }
drivers/mtd/nand/raw/davinci_nand.c +2 -3
@@ -435,10 +435,9 @@ static int nand_davinci_correct_4bit(struct nand_chip *chip, u_char *data,* the two LSBs for NAND access ... so we can issue 32-bit reads/writes * and have that transparently morphed into multiple NAND operations. */ -static void nand_davinci_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void nand_davinci_read_buf (struct nand_chip *chip,uint8_t *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd); -if ((0x03 & ((uintptr_t )buf)) ==0 && (0x03 & len) ==0 )ioread32_rep (chip->IO_ADDR_R, buf, len >>2 );else if ((0x01 & ((uintptr_t )buf)) ==0 && (0x01 & len) ==0 )
drivers/mtd/nand/raw/denali.c +6 -5
@@ -215,8 +215,9 @@ static uint32_t denali_check_irq(struct denali_nand_info *denali)return irq_status; } -static void denali_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void denali_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { +struct mtd_info *mtd =nand_to_mtd (chip);struct denali_nand_info *denali =mtd_to_denali (mtd);u32 addr =DENALI_MAP11_DATA |DENALI_BANK (denali);int i;
@@ -235,9 +236,9 @@ static void denali_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) denali->host_write (denali, addr, buf[i]); } -static void denali_read_buf16 (struct mtd_info *mtd,uint8_t *buf,int len) +static void denali_read_buf16 (struct nand_chip *chip,uint8_t *buf,int len) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));u32 addr =DENALI_MAP11_DATA |DENALI_BANK (denali);uint16_t *buf16 = (uint16_t *)buf;int i;
@@ -258,11 +259,11 @@ static void denali_write_buf16(struct mtd_info *mtd, const uint8_t *buf, denali->host_write (denali, addr, buf16[i]); } -static uint8_t denali_read_byte (struct mtd_info *mtd) +static uint8_t denali_read_byte (struct nand_chip *chip) {uint8_t byte; -denali_read_buf (mtd, &byte,1 ); +denali_read_buf (chip, &byte,1 );return byte; }
drivers/mtd/nand/raw/diskonchip.c +12 -20
@@ -302,9 +302,8 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) WriteDOC(datum, docptr, 2k_CDSN_IO); } -static u_char doc2000_read_byte (struct mtd_info *mtd) +static u_char doc2000_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;u_char ret;
@@ -334,9 +333,8 @@ static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len)printk ("\n" ); } -static void doc2000_readbuf (struct mtd_info *mtd,u_char *buf,int len) +static void doc2000_readbuf (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -344,14 +342,12 @@ static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)if (debug)printk ("readbuf of %d bytes: " , len); -for (i =0 ; i < len; i++) { +for (i =0 ; i < len; i++) buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); - } } -static void doc2000_readbuf_dword (struct mtd_info *mtd,u_char *buf,int len) +static void doc2000_readbuf_dword (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -387,8 +383,8 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)*/ udelay (50 ); - ret = this->read_byte (mtd) <<8 ; - ret |= this->read_byte (mtd); + ret = this->read_byte (this) <<8 ; + ret |= this->read_byte (this);if (doc->ChipID == DOC_ChipID_Doc2k && try_dword && !nr) {/* First chip probe. See if we get same results by 32-bit access */
@@ -447,7 +443,7 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)DoC_WaitReady (doc);nand_status_op (this,NULL );DoC_WaitReady (doc); - status = (int )this->read_byte (mtd); + status = (int )this->read_byte (this);return status; }
@@ -463,9 +459,8 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)WriteDOC (datum, docptr, WritePipeTerm); } -static u_char doc2001_read_byte (struct mtd_info *mtd) +static u_char doc2001_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
@@ -490,9 +485,8 @@ static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len)WriteDOC (0x00 , docptr, WritePipeTerm); } -static void doc2001_readbuf (struct mtd_info *mtd,u_char *buf,int len) +static void doc2001_readbuf (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -507,9 +501,8 @@ static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) buf[i] =ReadDOC (docptr, LastDataRead); } -static u_char doc2001plus_read_byte (struct mtd_info *mtd) +static u_char doc2001plus_read_byte (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;u_char ret;
@@ -540,9 +533,8 @@ static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int leprintk ("\n" ); } -static void doc2001plus_readbuf (struct mtd_info *mtd,u_char *buf,int len) +static void doc2001plus_readbuf (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -735,7 +727,7 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int coluWriteDOC (NAND_CMD_STATUS , docptr, Mplus_FlashCmd);WriteDOC (0 , docptr, Mplus_WritePipeTerm);WriteDOC (0 , docptr, Mplus_WritePipeTerm); -while (!(this->read_byte (mtd) &0x40 )) ; +while (!(this->read_byte (this) &0x40 )) ;return ;/* This applies to read commands */
drivers/mtd/nand/raw/docg4.c +5 -8
@@ -261,10 +261,9 @@ static inline void write_nop(void __iomem *docptr)writew (0 , docptr +DOC_NOP ); } -static void docg4_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void docg4_read_buf (struct nand_chip *nand,uint8_t *buf,int len) {int i; -struct nand_chip *nand =mtd_to_nand (mtd);uint16_t *p = (uint16_t *) buf; len >>=1 ;
@@ -484,9 +483,8 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page)return numerrs; } -static uint8_t docg4_read_byte (struct mtd_info *mtd) +static uint8_t docg4_read_byte (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct docg4_priv *doc =nand_get_controller_data (nand);dev_dbg (doc->dev,"%s\n" , __func__);
@@ -809,11 +807,11 @@ static int read_page(struct mtd_info *mtd, struct nand_chip *nand,dev_dbg (doc->dev,"%s: status = 0x%x\n" , __func__, status); -docg4_read_buf (mtd, buf,DOCG4_PAGE_SIZE );/* read the page data */ +docg4_read_buf (nand, buf,DOCG4_PAGE_SIZE );/* read the page data */ /* this device always reads oob after page data */ /* first 14 oob bytes read from I/O reg */ -docg4_read_buf (mtd, nand->oob_poi,14 ); +docg4_read_buf (nand, nand->oob_poi,14 );/* last 2 read from another reg */ buf16 = (uint16_t *)(nand->oob_poi +14 );
@@ -859,7 +857,6 @@ static int docg4_read_page(struct nand_chip *nand, uint8_t *buf,static int docg4_read_oob (struct nand_chip *nand,int page) { -struct mtd_info *mtd =nand_to_mtd (nand);struct docg4_priv *doc =nand_get_controller_data (nand);void __iomem *docptr = doc->virtadr;uint16_t status;
@@ -885,7 +882,7 @@ static int docg4_read_oob(struct nand_chip *nand, int page)dev_dbg (doc->dev,"%s: status = 0x%x\n" , __func__, status); -docg4_read_buf (mtd, nand->oob_poi,16 ); +docg4_read_buf (nand, nand->oob_poi,16 );write_nop (docptr);write_nop (docptr);
drivers/mtd/nand/raw/fsl_elbc_nand.c +3 -5
@@ -581,9 +581,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)* read a byte from either the FCM hardware buffer if it has any data left * otherwise issue a command to read a single byte. */ -static u8 fsl_elbc_read_byte (struct mtd_info *mtd) +static u8 fsl_elbc_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
@@ -598,9 +597,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)/* * Read from the FCM Controller Data Buffer */ -static void fsl_elbc_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void fsl_elbc_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;int avail;
@@ -720,7 +718,7 @@ static int fsl_elbc_read_page(struct nand_chip *chip, uint8_t *buf,nand_read_page_op (chip, page,0 , buf, mtd->writesize);if (oob_required) -fsl_elbc_read_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_elbc_read_buf (chip, chip->oob_poi, mtd->oobsize);if (fsl_elbc_wait (mtd, chip) &NAND_STATUS_FAIL ) mtd->ecc_stats.failed++;
drivers/mtd/nand/raw/fsl_ifc_nand.c +5 -8
@@ -545,9 +545,8 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)* Read a byte from either the IFC hardware buffer * read function for 8-bit buswidth */ -static uint8_t fsl_ifc_read_byte (struct mtd_info *mtd) +static uint8_t fsl_ifc_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);unsigned int offset;
@@ -568,9 +567,8 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)* Read two bytes from the IFC hardware buffer * read function for 16-bit buswith */ -static uint8_t fsl_ifc_read_byte16 (struct mtd_info *mtd) +static uint8_t fsl_ifc_read_byte16 (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);uint16_t data;
@@ -591,9 +589,8 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)/* * Read from the IFC Controller Data Buffer */ -static void fsl_ifc_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void fsl_ifc_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);int avail;
@@ -689,11 +686,11 @@ static int fsl_ifc_read_page(struct nand_chip *chip, uint8_t *buf,nand_read_page_op (chip, page,0 , buf, mtd->writesize);if (oob_required) -fsl_ifc_read_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_ifc_read_buf (chip, chip->oob_poi, mtd->oobsize);if (ctrl->nand_stat &IFC_NAND_EVTER_STAT_ECCER ) {if (!oob_required) -fsl_ifc_read_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_ifc_read_buf (chip, chip->oob_poi, mtd->oobsize);return check_erased_page (chip, buf); }
drivers/mtd/nand/raw/fsl_upm.c +4 -4
@@ -124,16 +124,16 @@ static void fun_select_chip(struct mtd_info *mtd, int mchip_nr) } } -static uint8_t fun_read_byte (struct mtd_info *mtd) +static uint8_t fun_read_byte (struct nand_chip *chip) { -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));return in_8 (fun->chip.IO_ADDR_R); } -static void fun_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void fun_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));int i;for (i =0 ; i < len; i++)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +7 -9
@@ -859,9 +859,8 @@ static void gpmi_select_chip(struct mtd_info *mtd, int chipnr) this->current_chip = chipnr; } -static void gpmi_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void gpmi_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);dev_dbg (this->dev,"len is %d\n" , len);
@@ -879,13 +878,12 @@ static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)gpmi_send_data (this, buf, len); } -static uint8_t gpmi_read_byte (struct mtd_info *mtd) +static uint8_t gpmi_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);uint8_t *buf = this->data_buffer_dma; -gpmi_read_buf (mtd, buf,1 ); +gpmi_read_buf (chip, buf,1 );return buf[0 ]; }
@@ -1336,7 +1334,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)/* Read out the conventional OOB. */ nand_read_page_op (chip, page, mtd->writesize,NULL ,0 ); - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);/* * Now, we want to make sure the block mark is correct. In the
@@ -1346,7 +1344,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)if (GPMI_IS_MX23 (this)) {/* Read the block mark into the first byte of the OOB buffer. */ nand_read_page_op (chip, page,0 ,NULL ,0 ); - chip->oob_poi[0 ] = chip->read_byte (mtd); + chip->oob_poi[0 ] = chip->read_byte (chip); }return 0 ;
@@ -1635,7 +1633,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)* and starts in the 12th byte of the page. */ nand_read_page_op (chip, page,12 ,NULL ,0 ); - chip->read_buf (mtd, buffer,strlen (fingerprint)); + chip->read_buf (chip, buffer,strlen (fingerprint));/* Look for the fingerprint. */ if (!memcmp (buffer, fingerprint,strlen (fingerprint))) {
@@ -1771,7 +1769,7 @@ static int mx23_boot_init(struct gpmi_nand_data *this)/* Send the command to read the conventional block mark. */ chip->select_chip (mtd, chipnr);nand_read_page_op (chip, page, mtd->writesize,NULL ,0 ); - block_mark = chip->read_byte (mtd); + block_mark = chip->read_byte (chip); chip->select_chip (mtd,-1 );/*
drivers/mtd/nand/raw/hisi504_nand.c +3 -5
@@ -364,9 +364,8 @@ static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) host->chipselect = chipselect; } -static uint8_t hisi_nfc_read_byte (struct mtd_info *mtd) +static uint8_t hisi_nfc_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct hinfc_host *host =nand_get_controller_data (chip);if (host->command ==NAND_CMD_STATUS )
@@ -390,9 +389,8 @@ hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) host->offset += len; } -static void hisi_nfc_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void hisi_nfc_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct hinfc_host *host =nand_get_controller_data (chip);memcpy (buf, host->buffer + host->offset, len);
@@ -537,7 +535,7 @@ static int hisi_nand_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,int stat_1, stat_2;nand_read_page_op (chip, page,0 , buf, mtd->writesize); - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);/* errors which can not be corrected by ECC */ if (host->irq_status &HINFC504_INTS_UE ) {
drivers/mtd/nand/raw/lpc32xx_slc.c +5 -7
@@ -359,9 +359,8 @@ static int lpc32xx_nand_ecc_calculate(struct nand_chip *chip,/* * Read a single byte from NAND device */ -static uint8_t lpc32xx_nand_read_byte (struct mtd_info *mtd) +static uint8_t lpc32xx_nand_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);return (uint8_t )readl (SLC_DATA (host->io_base));
@@ -370,9 +369,8 @@ static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd)/* * Simple device read without ECC */ -static void lpc32xx_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void lpc32xx_nand_read_buf (struct nand_chip *chip,u_char *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);/* Direct device read with no ECC */
@@ -628,7 +626,7 @@ static int lpc32xx_nand_read_page_syndrome(struct nand_chip *chip, uint8_t *buf, status =lpc32xx_xfer (mtd, buf, chip->ecc.steps,1 );/* Get OOB data */ - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);/* Convert to stored ECC format */ lpc32xx_slc_ecc_copy (tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps);
@@ -669,8 +667,8 @@ static int lpc32xx_nand_read_page_raw_syndrome(struct nand_chip *chip,nand_read_page_op (chip, page,0 ,NULL ,0 );/* Raw reads can just use the FIFO interface */ - chip->read_buf (mtd, buf, chip->ecc.size * chip->ecc.steps); - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, buf, chip->ecc.size * chip->ecc.steps); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);return 0 ; }
drivers/mtd/nand/raw/mpc5121_nfc.c +4 -4
@@ -493,9 +493,9 @@ static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len, }/* Read data from NFC buffers */ -static void mpc5121_nfc_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void mpc5121_nfc_read_buf (struct nand_chip *chip,u_char *buf,int len) { -mpc5121_nfc_buf_copy (mtd, buf, len,0 ); +mpc5121_nfc_buf_copy (nand_to_mtd (chip), buf, len,0 ); }/* Write data to NFC buffers */
@@ -506,11 +506,11 @@ static void mpc5121_nfc_write_buf(struct mtd_info *mtd, }/* Read byte from NFC buffers */ -static u8 mpc5121_nfc_read_byte (struct mtd_info *mtd) +static u8 mpc5121_nfc_read_byte (struct nand_chip *chip) {u8 tmp; -mpc5121_nfc_read_buf (mtd, &tmp,sizeof (tmp)); +mpc5121_nfc_read_buf (chip, &tmp,sizeof (tmp));return tmp; }
drivers/mtd/nand/raw/mtk_nand.c +3 -4
@@ -438,9 +438,8 @@ static inline void mtk_nfc_wait_ioready(struct mtk_nfc *nfc)dev_err (nfc->dev,"data not ready\n" ); } -static inline u8 mtk_nfc_read_byte (struct mtd_info *mtd) +static inline u8 mtk_nfc_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct mtk_nfc *nfc =nand_get_controller_data (chip);u32 reg;
@@ -467,12 +466,12 @@ static inline u8 mtk_nfc_read_byte(struct mtd_info *mtd)return nfi_readb (nfc,NFI_DATAR ); } -static void mtk_nfc_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void mtk_nfc_read_buf (struct nand_chip *chip,u8 *buf,int len) {int i;for (i =0 ; i < len; i++) - buf[i] =mtk_nfc_read_byte (mtd); + buf[i] =mtk_nfc_read_byte (chip); }static void mtk_nfc_write_byte (struct mtd_info *mtd,u8 byte)
drivers/mtd/nand/raw/mxc_nand.c +5 -5
@@ -895,9 +895,8 @@ static int mxc_nand_write_oob(struct nand_chip *chip, int page)return mxc_nand_write_page (chip, host->data_buf, false, page); } -static u_char mxc_nand_read_byte (struct mtd_info *mtd) +static u_char mxc_nand_read_byte (struct nand_chip *nand_chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct mxc_nand_host *host =nand_get_controller_data (nand_chip);uint8_t ret;
@@ -941,9 +940,10 @@ static void mxc_nand_write_buf(struct mtd_info *mtd,* Flash first the data output cycle is initiated by the NFC, which copies * the data to RAMbuffer. This data of length len is then copied to buffer buf. */ -static void mxc_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void mxc_nand_read_buf (struct nand_chip *nand_chip,u_char *buf, +int len) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand_chip);struct mxc_nand_host *host =nand_get_controller_data (nand_chip);u16 col = host->buf_start;int n = mtd->oobsize + mtd->writesize - col;
@@ -1429,7 +1429,7 @@ static int mxc_nand_get_features(struct mtd_info *mtd, struct nand_chip *chip, host->buf_start =0 ;for (i =0 ; i <ONFI_SUBFEATURE_PARAM_LEN ; ++i) - *subfeature_param++ = chip->read_byte (mtd); + *subfeature_param++ = chip->read_byte (chip);return 0 ; }
drivers/mtd/nand/raw/nand_base.c +17 -24
140 lines not on this page · raw message
drivers/mtd/nand/raw/nandsim.c +3 -5
@@ -1872,9 +1872,8 @@ static void switch_state(struct nandsim *ns) } } -static u_char ns_nand_read_byte (struct mtd_info *mtd) +static u_char ns_nand_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct nandsim *ns =nand_get_controller_data (chip);u_char outb =0x00 ;
@@ -2136,9 +2135,8 @@ static void ns_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) } } -static void ns_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void ns_nand_read_buf (struct nand_chip *chip,u_char *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct nandsim *ns =nand_get_controller_data (chip);/* Sanity and correctness checks */
@@ -2160,7 +2158,7 @@ static void ns_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)int i;for (i =0 ; i < len; i++) - buf[i] =mtd_to_nand (mtd)->read_byte (mtd); + buf[i] = chip->read_byte (chip);return ; }
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -116,9 +116,8 @@ static int ndfc_calculate_ecc(struct nand_chip *chip,* functions. No further checking, as nand_base will always read/write * page aligned. */ -static void ndfc_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void ndfc_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip);uint32_t *p = (uint32_t *) buf;
drivers/mtd/nand/raw/nuc900_nand.c +4 -4
@@ -79,21 +79,21 @@ static const struct mtd_partition partitions[] = { } }; -static unsigned char nuc900_nand_read_byte (struct mtd_info *mtd) +static unsigned char nuc900_nand_read_byte (struct nand_chip *chip) {unsigned char ret; -struct nuc900_nand *nand =mtd_to_nuc900 (mtd); +struct nuc900_nand *nand =mtd_to_nuc900 (nand_to_mtd (chip)); ret = (unsigned char )read_data_reg (nand);return ret; } -static void nuc900_nand_read_buf (struct mtd_info *mtd, +static void nuc900_nand_read_buf (struct nand_chip *chip,unsigned char *buf,int len) {int i; -struct nuc900_nand *nand =mtd_to_nuc900 (mtd); +struct nuc900_nand *nand =mtd_to_nuc900 (nand_to_mtd (chip));for (i =0 ; i < len; i++) buf[i] = (unsigned char )read_data_reg (nand);
drivers/mtd/nand/raw/omap2.c +15 -9
@@ -337,12 +337,13 @@ static void omap_write_buf16(struct mtd_info *mtd, const u_char * buf, int len)/** * omap_read_buf_pref - read data from NAND controller into buffer -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: buffer to store date * @len: number of bytes to read */ -static void omap_read_buf_pref (struct mtd_info *mtd,u_char *buf,int len) +static void omap_read_buf_pref (struct nand_chip *chip,u_char *buf,int len) { +struct mtd_info *mtd =nand_to_mtd (chip);struct omap_nand_info *info =mtd_to_omap (mtd);uint32_t r_count =0 ;int ret =0 ;
@@ -528,14 +529,17 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr,/** * omap_read_buf_dma_pref - read data from NAND controller into buffer -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: buffer to store date * @len: number of bytes to read */ -static void omap_read_buf_dma_pref (struct mtd_info *mtd,u_char *buf,int len) +static void omap_read_buf_dma_pref (struct nand_chip *chip,u_char *buf, +int len) { +struct mtd_info *mtd =nand_to_mtd (chip); +if (len <= mtd->oobsize) -omap_read_buf_pref (mtd, buf, len); +omap_read_buf_pref (chip, buf, len);else /* start transfer in DMA mode */ omap_nand_dma_transfer (mtd, buf, len,0x0 );
@@ -605,17 +609,19 @@ static irqreturn_t omap_nand_irq(int this_irq, void *dev)/* * omap_read_buf_irq_pref - read data from NAND controller into buffer -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: buffer to store date * @len: number of bytes to read */ -static void omap_read_buf_irq_pref (struct mtd_info *mtd,u_char *buf,int len) +static void omap_read_buf_irq_pref (struct nand_chip *chip,u_char *buf, +int len) { +struct mtd_info *mtd =nand_to_mtd (chip);struct omap_nand_info *info =mtd_to_omap (mtd);int ret =0 ;if (len <= mtd->oobsize) { -omap_read_buf_pref (mtd, buf, len); +omap_read_buf_pref (chip, buf, len);return ; }
@@ -1642,7 +1648,7 @@ static int omap_read_page_bch(struct nand_chip *chip, uint8_t *buf, chip->ecc.hwctl (chip,NAND_ECC_READ );/* Read data */ - chip->read_buf (mtd, buf, mtd->writesize); + chip->read_buf (chip, buf, mtd->writesize);/* Read oob bytes */ nand_change_read_column_op(chip,
drivers/mtd/nand/raw/orion_nand.c +1 -2
@@ -48,9 +48,8 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrlwriteb (cmd, nc->IO_ADDR_W + offs); } -static void orion_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void orion_nand_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);void __iomem *io_base = chip->IO_ADDR_R;#if defined(__LINUX_ARM_ARCH__) && __LINUX_ARM_ARCH__ >=5 uint64_t *buf64;
drivers/mtd/nand/raw/oxnas_nand.c +2 -4
@@ -38,17 +38,15 @@ struct oxnas_nand_ctrl {struct nand_chip *chips[OXNAS_NAND_MAX_CHIPS ]; }; -static uint8_t oxnas_nand_read_byte (struct mtd_info *mtd) +static uint8_t oxnas_nand_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct oxnas_nand_ctrl *oxnas =nand_get_controller_data (chip);return readb (oxnas->io_base); } -static void oxnas_nand_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void oxnas_nand_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct oxnas_nand_ctrl *oxnas =nand_get_controller_data (chip);ioread8_rep (oxnas->io_base, buf, len);
drivers/mtd/nand/raw/pasemi_nand.c +1 -3
@@ -43,10 +43,8 @@ static unsigned int lpcctl;static struct mtd_info *pasemi_nand_mtd;static const char driver_name[] ="pasemi-nand" ; -static void pasemi_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void pasemi_read_buf (struct nand_chip *chip,u_char *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd); -while (len >0x800 ) {memcpy_fromio (buf, chip->IO_ADDR_R,0x800 ); buf +=0x800 ;
drivers/mtd/nand/raw/plat_nand.c +1 -10
@@ -52,13 +52,6 @@ static void plat_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, pdata->ctrl.write_buf (mtd_to_nand (mtd), buf, len); } -static void plat_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) -{ -struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent); - - pdata->ctrl.read_buf (mtd_to_nand (mtd), buf, len); -} -/* * Probe for the NAND device. */
@@ -111,9 +104,7 @@ static int plat_nand_probe(struct platform_device *pdev)if (pdata->ctrl.write_buf) data->chip.write_buf = plat_nand_write_buf; -if (pdata->ctrl.read_buf) - data->chip.read_buf = plat_nand_read_buf; - + data->chip.read_buf = pdata->ctrl.read_buf; data->chip.chip_delay = pdata->chip.chip_delay; data->chip.options |= pdata->chip.options; data->chip.bbt_options |= pdata->chip.bbt_options;
drivers/mtd/nand/raw/qcom_nandc.c +2 -4
@@ -2282,9 +2282,8 @@ static int qcom_nandc_block_markbad(struct mtd_info *mtd, loff_t ofs)* reading/writing page data, they are used for smaller data like reading * id, status etc */ -static uint8_t qcom_nandc_read_byte (struct mtd_info *mtd) +static uint8_t qcom_nandc_read_byte (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);u8 *buf = nandc->data_buffer;
@@ -2304,9 +2303,8 @@ static uint8_t qcom_nandc_read_byte(struct mtd_info *mtd)return ret; } -static void qcom_nandc_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void qcom_nandc_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);int real_len =min_t (size_t, len, nandc->buf_count - nandc->buf_start);
drivers/mtd/nand/raw/r852.c +4 -4
@@ -266,9 +266,9 @@ static void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)/* * Read data lines of the nand chip to retrieve data */ -static void r852_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void r852_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));uint32_t reg;if (dev->card_unstable) {
@@ -303,9 +303,9 @@ static void r852_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)/* * Read one byte from nand chip */ -static uint8_t r852_read_byte (struct mtd_info *mtd) +static uint8_t r852_read_byte (struct nand_chip *chip) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));/* Same problem as in r852_read_buf.... */ if (dev->card_unstable)
drivers/mtd/nand/raw/s3c2410.c +3 -3
@@ -675,14 +675,14 @@ static int s3c2440_nand_calculate_ecc(struct nand_chip *chip,* use read/write block to move the data buffers to/from the controller */ -static void s3c2410_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void s3c2410_nand_read_buf (struct nand_chip *this,u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);readsb (this->IO_ADDR_R, buf, len); } -static void s3c2440_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void s3c2440_nand_read_buf (struct nand_chip *this,u_char *buf,int len) { +struct mtd_info *mtd =nand_to_mtd (this);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);readsl (info->regs +S3C2440_NFDATA , buf, len >>2 );
drivers/mtd/nand/raw/sh_flctl.c +5 -5
@@ -618,7 +618,7 @@ static int flctl_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,nand_read_page_op (chip, page,0 , buf, mtd->writesize);if (oob_required) - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);return 0 ; }
@@ -978,9 +978,9 @@ static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) flctl->index += len; } -static uint8_t flctl_read_byte (struct mtd_info *mtd) +static uint8_t flctl_read_byte (struct nand_chip *chip) { -struct sh_flctl *flctl =mtd_to_flctl (mtd); +struct sh_flctl *flctl =mtd_to_flctl (nand_to_mtd (chip));uint8_t data; data = flctl->done_buff[flctl->index];
@@ -988,9 +988,9 @@ static uint8_t flctl_read_byte(struct mtd_info *mtd)return data; } -static void flctl_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void flctl_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct sh_flctl *flctl =mtd_to_flctl (mtd); +struct sh_flctl *flctl =mtd_to_flctl (nand_to_mtd (chip));memcpy (buf, &flctl->done_buff[flctl->index], len); flctl->index += len;
drivers/mtd/nand/raw/socrates_nand.c +5 -5
@@ -54,14 +54,14 @@ static void socrates_nand_write_buf(struct mtd_info *mtd,/** * socrates_nand_read_buf - read chip data into buffer -* @mtd: MTD device structure +* @this: NAND chip object * @buf: buffer to store date * @len: number of bytes to read */ -static void socrates_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void socrates_nand_read_buf (struct nand_chip *this,uint8_t *buf, +int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);struct socrates_nand_host *host =nand_get_controller_data (this);uint32_t val;
@@ -78,10 +78,10 @@ static void socrates_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)* socrates_nand_read_byte - read one byte from the chip * @mtd: MTD device structure */ -static uint8_t socrates_nand_read_byte (struct mtd_info *mtd) +static uint8_t socrates_nand_read_byte (struct nand_chip *this) {uint8_t byte; -socrates_nand_read_buf (mtd, &byte,sizeof (byte)); +socrates_nand_read_buf (this, &byte,sizeof (byte));return byte; }
drivers/mtd/nand/raw/sunxi_nand.c +5 -6
@@ -464,9 +464,8 @@ static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip) sunxi_nand->selected = chip; } -static void sunxi_nfc_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void sunxi_nfc_read_buf (struct nand_chip *nand,uint8_t *buf,int len) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);int ret;
@@ -540,11 +539,11 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, } } -static uint8_t sunxi_nfc_read_byte (struct mtd_info *mtd) +static uint8_t sunxi_nfc_read_byte (struct nand_chip *nand) {uint8_t ret =0 ; -sunxi_nfc_read_buf (mtd, &ret,1 ); +sunxi_nfc_read_buf (nand, &ret,1 );return ret; }
@@ -770,7 +769,7 @@ static void sunxi_nfc_randomizer_read_buf(struct mtd_info *mtd, uint8_t *buf, {sunxi_nfc_randomizer_config (mtd, page, ecc);sunxi_nfc_randomizer_enable (mtd); -sunxi_nfc_read_buf (mtd, buf, len); +sunxi_nfc_read_buf (mtd_to_nand (mtd), buf, len);sunxi_nfc_randomizer_disable (mtd); }
@@ -995,7 +994,7 @@ static void sunxi_nfc_hw_ecc_read_extra_oob(struct mtd_info *mtd, false);if (!randomize) -sunxi_nfc_read_buf (mtd, oob + offset, len); +sunxi_nfc_read_buf (nand, oob + offset, len);else sunxi_nfc_randomizer_read_buf (mtd, oob + offset, len, false, page);
drivers/mtd/nand/raw/tango_nand.c +5 -7
@@ -135,16 +135,16 @@ static int tango_dev_ready(struct mtd_info *mtd)return readl_relaxed (nfc->pbus_base +PBUS_CS_CTRL ) &PBUS_IORDY ; } -static u8 tango_read_byte (struct mtd_info *mtd) +static u8 tango_read_byte (struct nand_chip *chip) { -struct tango_chip *tchip =to_tango_chip (mtd_to_nand (mtd)); +struct tango_chip *tchip =to_tango_chip (chip);return readb_relaxed (tchip->base +PBUS_DATA ); } -static void tango_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void tango_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct tango_chip *tchip =to_tango_chip (mtd_to_nand (mtd)); +struct tango_chip *tchip =to_tango_chip (chip);ioread8_rep (tchip->base +PBUS_DATA , buf, len); }
@@ -325,15 +325,13 @@ static int tango_write_page(struct nand_chip *chip, const u8 *buf,static void aux_read (struct nand_chip *chip,u8 **buf,int len,int *pos) { -struct mtd_info *mtd =nand_to_mtd (chip); - *pos += len;if (!*buf) {/* skip over "len" bytes */ nand_change_read_column_op (chip, *pos,NULL ,0 , false); }else { -tango_read_buf (mtd, *buf, len); +tango_read_buf (chip, *buf, len); *buf += len; } }
drivers/mtd/nand/raw/tmio_nand.c +4 -4
@@ -225,9 +225,9 @@ tmio_nand_wait(struct mtd_info *mtd, struct nand_chip *nand_chip)*To prevent stale data from being read, tmio_nand_hwcontrol() clears *tmio->read_good. */ -static u_char tmio_nand_read_byte (struct mtd_info *mtd) +static u_char tmio_nand_read_byte (struct nand_chip *chip) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));unsigned int data;if (tmio->read_good--)
@@ -252,9 +252,9 @@ tmio_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)tmio_iowrite16_rep (tmio->fcr +FCR_DATA , buf, len >>1 ); } -static void tmio_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void tmio_nand_read_buf (struct nand_chip *chip,u_char *buf,int len) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));tmio_ioread16_rep (tmio->fcr +FCR_DATA , buf, len >>1 ); }
drivers/mtd/nand/raw/txx9ndfmc.c +4 -4
@@ -102,9 +102,9 @@ static void txx9ndfmc_write(struct platform_device *dev,__raw_writel (val,ndregaddr (dev, reg)); } -static uint8_t txx9ndfmc_read_byte (struct mtd_info *mtd) +static uint8_t txx9ndfmc_read_byte (struct nand_chip *chip) { -struct platform_device *dev =mtd_to_platdev (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));return txx9ndfmc_read (dev,TXX9_NDFDTR ); }
@@ -122,9 +122,9 @@ static void txx9ndfmc_write_buf(struct mtd_info *mtd, const uint8_t *buf,txx9ndfmc_write (dev, mcr,TXX9_NDFMCR ); } -static void txx9ndfmc_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) +static void txx9ndfmc_read_buf (struct nand_chip *chip,uint8_t *buf,int len) { -struct platform_device *dev =mtd_to_platdev (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));void __iomem *ndfdtr =ndregaddr (dev,TXX9_NDFDTR );while (len--)
drivers/mtd/nand/raw/xway_nand.c +4 -4
@@ -125,17 +125,17 @@ static int xway_dev_ready(struct mtd_info *mtd)return ltq_ebu_r32 (EBU_NAND_WAIT ) &NAND_WAIT_RD ; } -static unsigned char xway_read_byte (struct mtd_info *mtd) +static unsigned char xway_read_byte (struct nand_chip *chip) { -return xway_readb (mtd,NAND_READ_DATA ); +return xway_readb (nand_to_mtd (chip),NAND_READ_DATA ); } -static void xway_read_buf (struct mtd_info *mtd,u_char *buf,int len) +static void xway_read_buf (struct nand_chip *chip,u_char *buf,int len) {int i;for (i =0 ; i < len; i++) - buf[i] =xway_readb (mtd,NAND_WRITE_DATA ); + buf[i] =xway_readb (nand_to_mtd (chip),NAND_WRITE_DATA ); }static void xway_write_buf (struct mtd_info *mtd,const u_char *buf,int len)
drivers/staging/mt29f_spinand/mt29f_spinand.c +5 -5
@@ -657,7 +657,7 @@ static int spinand_read_page_hwecc(struct nand_chip *chip, u8 *buf,nand_read_page_op (chip, page,0 , p, eccsize * eccsteps);if (oob_required) - chip->read_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->read_buf (chip, chip->oob_poi, mtd->oobsize);while (1 ) { retval =spinand_read_status (info->spi, &status);
@@ -685,9 +685,9 @@ static void spinand_select_chip(struct mtd_info *mtd, int dev) { } -static u8 spinand_read_byte (struct mtd_info *mtd) +static u8 spinand_read_byte (struct nand_chip *chip) { -struct spinand_state *state =mtd_to_state (mtd); +struct spinand_state *state =mtd_to_state (nand_to_mtd (chip));u8 data; data = state->buf[state->buf_ptr];
@@ -732,9 +732,9 @@ static void spinand_write_buf(struct mtd_info *mtd, const u8 *buf, int len) state->buf_ptr += len; } -static void spinand_read_buf (struct mtd_info *mtd,u8 *buf,int len) +static void spinand_read_buf (struct nand_chip *chip,u8 *buf,int len) { -struct spinand_state *state =mtd_to_state (mtd); +struct spinand_state *state =mtd_to_state (nand_to_mtd (chip));memcpy (buf, state->buf + state->buf_ptr, len); state->buf_ptr += len;
include/linux/mtd/rawnand.h +2 -2
@@ -1283,10 +1283,10 @@ struct nand_chip {void __iomem *IO_ADDR_R ;void __iomem *IO_ADDR_W ; -uint8_t (*read_byte)(struct mtd_info *mtd); +uint8_t (*read_byte)(struct nand_chip *chip);void (*write_byte)(struct mtd_info *mtd,uint8_t byte);void (*write_buf)(struct mtd_info *mtd,const uint8_t *buf,int len); -void (*read_buf)(struct mtd_info *mtd,uint8_t *buf,int len); +void (*read_buf)(struct nand_chip *chip,uint8_t *buf,int len);void (*select_chip)(struct mtd_info *mtd,int chip);int (*block_bad)(struct mtd_info *mtd,loff_t ofs);int (*block_markbad)(struct mtd_info *mtd,loff_t ofs);
Signature · 1 line
2.14.1
PATCH v2 11/23 mtd: rawnand: Pass a nand_chip object to chip->write_xxx() hooks
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle all chip->write_xxx() hooks at once.
--- drivers/mtd/nand/raw/ams-delta.c | 9 +++--- drivers/mtd/nand/raw/atmel/nand-controller.c | 12 +++---- drivers/mtd/nand/raw/au1550nd.c | 34 +++++++++----------- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 6 ++-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 5 ++- drivers/mtd/nand/raw/cafe_nand.c | 5 ++- drivers/mtd/nand/raw/cmx270_nand.c | 4 +-- drivers/mtd/nand/raw/cs553x_nand.c | 9 ++---- drivers/mtd/nand/raw/davinci_nand.c | 6 ++-- drivers/mtd/nand/raw/denali.c | 13 ++++---- drivers/mtd/nand/raw/diskonchip.c | 20 +++++------- drivers/mtd/nand/raw/docg4.c | 10 +++--- drivers/mtd/nand/raw/fsl_elbc_nand.c | 10 +++--- drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 ++-- drivers/mtd/nand/raw/fsl_upm.c | 4 +-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 3 +- drivers/mtd/nand/raw/hisi504_nand.c | 5 ++- drivers/mtd/nand/raw/lpc32xx_slc.c | 8 ++--- drivers/mtd/nand/raw/mpc5121_nfc.c | 6 ++-- drivers/mtd/nand/raw/mtk_nand.c | 8 ++--- drivers/mtd/nand/raw/mxc_nand.c | 8 ++--- drivers/mtd/nand/raw/nand_base.c | 41 ++++++++++-------------- drivers/mtd/nand/raw/nand_hynix.c | 2 +- drivers/mtd/nand/raw/nandsim.c | 9 +++--- drivers/mtd/nand/raw/ndfc.c | 3 +- drivers/mtd/nand/raw/nuc900_nand.c | 4 +-- drivers/mtd/nand/raw/omap2.c | 36 ++++++++++++--------- drivers/mtd/nand/raw/oxnas_nand.c | 4 +-- drivers/mtd/nand/raw/pasemi_nand.c | 5 ++- drivers/mtd/nand/raw/plat_nand.c | 12 +------ drivers/mtd/nand/raw/qcom_nandc.c | 3 +- drivers/mtd/nand/raw/r852.c | 4 +-- drivers/mtd/nand/raw/s3c2410.c | 6 ++-- drivers/mtd/nand/raw/sh_flctl.c | 6 ++-- drivers/mtd/nand/raw/socrates_nand.c | 7 ++-- drivers/mtd/nand/raw/sunxi_nand.c | 5 ++- drivers/mtd/nand/raw/tango_nand.c | 8 ++--- drivers/mtd/nand/raw/tmio_nand.c | 4 +-- drivers/mtd/nand/raw/txx9ndfmc.c | 4 +-- drivers/mtd/nand/raw/xway_nand.c | 4 +-- drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 +-- include/linux/mtd/rawnand.h | 4 +-- 42 files changed, 163 insertions(+), 203 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +4 -5
@@ -63,9 +63,8 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; -static void ams_delta_write_byte (struct mtd_info *mtd,u_char byte) +static void ams_delta_write_byte (struct nand_chip *this,u_char byte) { -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *io_base = (void __iomem *)nand_get_controller_data (this);writew (0 , io_base +OMAP_MPUIO_IO_CNTL );
@@ -89,13 +88,13 @@ static u_char ams_delta_read_byte(struct nand_chip *this)return res; } -static void ams_delta_write_buf (struct mtd_info *mtd,const u_char *buf, +static void ams_delta_write_buf (struct nand_chip *this,const u_char *buf,int len) {int i;for (i=0 ; i<len; i++) -ams_delta_write_byte (mtd, buf[i]); +ams_delta_write_byte (this, buf[i]); }static void ams_delta_read_buf (struct nand_chip *this,u_char *buf,int len)
@@ -128,7 +127,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, }if (cmd !=NAND_CMD_NONE ) -ams_delta_write_byte (mtd, cmd); +ams_delta_write_byte (mtd_to_nand (mtd), cmd); }static int ams_delta_nand_ready (struct mtd_info *mtd)
drivers/mtd/nand/raw/atmel/nand-controller.c +5 -7
@@ -417,9 +417,8 @@ static u8 atmel_nand_read_byte(struct nand_chip *chip)return ioread8 (nand->activecs->io.virt); } -static void atmel_nand_write_byte (struct mtd_info *mtd,u8 byte) +static void atmel_nand_write_byte (struct nand_chip *chip,u8 byte) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);if (chip->options &NAND_BUSWIDTH_16 )
@@ -452,9 +451,8 @@ static void atmel_nand_read_buf(struct nand_chip *chip, u8 *buf, int len)ioread8_rep (nand->activecs->io.virt, buf, len); } -static void atmel_nand_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void atmel_nand_write_buf (struct nand_chip *chip,const u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;
@@ -841,7 +839,7 @@ static int atmel_nand_pmecc_write_pg(struct nand_chip *chip, const u8 *buf,if (ret)return ret; -atmel_nand_write_buf (mtd, buf, mtd->writesize); +atmel_nand_write_buf (chip, buf, mtd->writesize); ret =atmel_nand_pmecc_generate_eccbytes (chip, raw);if (ret) {
@@ -851,7 +849,7 @@ static int atmel_nand_pmecc_write_pg(struct nand_chip *chip, const u8 *buf,atmel_nand_pmecc_disable (chip, raw); -atmel_nand_write_buf (mtd, chip->oob_poi, mtd->oobsize); +atmel_nand_write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
@@ -942,7 +940,7 @@ static int atmel_hsmc_nand_pmecc_write_pg(struct nand_chip *chip,if (ret)return ret; -atmel_nand_write_buf (mtd, chip->oob_poi, mtd->oobsize); +atmel_nand_write_buf (chip, chip->oob_poi, mtd->oobsize); nc->op.cmds[0 ] =NAND_CMD_PAGEPROG ; nc->op.ncmds =1 ;
drivers/mtd/nand/raw/au1550nd.c +15 -19
@@ -24,7 +24,7 @@ struct au1550nd_ctx {int cs;void __iomem *base; -void (*write_byte)(struct mtd_info *,u_char ); +void (*write_byte)(struct nand_chip *,u_char ); };/**
@@ -42,14 +42,13 @@ static u_char au_read_byte(struct nand_chip *this)/** * au_write_byte - write one byte to the chip -* @mtd: MTD device structure +* @this: NAND chip object * @byte: pointer to data byte to write * * write function for 8it buswidth */ -static void au_write_byte (struct mtd_info *mtd,u_char byte) +static void au_write_byte (struct nand_chip *this,u_char byte) { -struct nand_chip *this =mtd_to_nand (mtd);writeb (byte, this->IO_ADDR_W);wmb ();/* drain writebuffer */ }
@@ -69,30 +68,28 @@ static u_char au_read_byte16(struct nand_chip *this)/** * au_write_byte16 - write one byte endianness aware to the chip -* @mtd: MTD device structure +* @this: NAND chip object * @byte: pointer to data byte to write * * write function for 16bit buswidth with endianness conversion */ -static void au_write_byte16 (struct mtd_info *mtd,u_char byte) +static void au_write_byte16 (struct nand_chip *this,u_char byte) { -struct nand_chip *this =mtd_to_nand (mtd);writew (le16_to_cpu ((u16 ) byte), this->IO_ADDR_W);wmb ();/* drain writebuffer */ }/** * au_write_buf - write buffer to chip -* @mtd: MTD device structure +* @this: NAND chip object * @buf: data buffer * @len: number of bytes to write * * write function for 8bit buswidth */ -static void au_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void au_write_buf (struct nand_chip *this,const u_char *buf,int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) {writeb (buf[i], this->IO_ADDR_W);
@@ -120,16 +117,15 @@ static void au_read_buf(struct nand_chip *this, u_char *buf, int len)/** * au_write_buf16 - write buffer to chip -* @mtd: MTD device structure +* @this: NAND chip object * @buf: data buffer * @len: number of bytes to write * * write function for 16bit buswidth */ -static void au_write_buf16 (struct mtd_info *mtd,const u_char *buf,int len) +static void au_write_buf16 (struct nand_chip *this,const u_char *buf,int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);u16 *p = (u16 *) buf; len >>=1 ;
@@ -272,9 +268,9 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i column -=256 ; readcmd =NAND_CMD_READ1 ; } - ctx->write_byte (mtd, readcmd); + ctx->write_byte (this, readcmd); } - ctx->write_byte (mtd, command); + ctx->write_byte (this, command);/* Set ALE and clear CLE to start address cycle */ au1550_hwcontrol (mtd,NAND_CTL_CLRCLE );
@@ -288,10 +284,10 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, iif (this->options &NAND_BUSWIDTH_16 && !nand_opcode_8bits (command)) column >>=1 ; - ctx->write_byte (mtd, column); + ctx->write_byte (this, column); }if (page_addr !=-1 ) { - ctx->write_byte (mtd, (u8)(page_addr &0xff )); + ctx->write_byte (this, (u8)(page_addr &0xff )); if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 ||
@@ -309,10 +305,10 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, iau1550_hwcontrol (mtd,NAND_CTL_SETNCE ); } - ctx->write_byte (mtd, (u8)(page_addr >>8 )); + ctx->write_byte (this, (u8)(page_addr >>8 ));if (this->options &NAND_ROW_ADDR_3 ) - ctx->write_byte (mtd, + ctx->write_byte (this, ((page_addr >>16 ) &0x0f )); }/* Latch in address */
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +3 -3
@@ -354,15 +354,15 @@ static void bcm47xxnflash_ops_bcm4706_read_buf(struct nand_chip *nand_chip,pr_err ("Invalid command for buf read: 0x%X\n" , b47n->curr_command); } -static void bcm47xxnflash_ops_bcm4706_write_buf (struct mtd_info *mtd, +static void bcm47xxnflash_ops_bcm4706_write_buf (struct nand_chip *nand_chip,const uint8_t *buf,int len) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);switch (b47n->curr_command) {case NAND_CMD_SEQIN : -bcm47xxnflash_ops_bcm4706_write (mtd, buf, len); +bcm47xxnflash_ops_bcm4706_write (nand_to_mtd (nand_chip), buf, + len);return ; }
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -3
@@ -1481,11 +1481,10 @@ static void brcmnand_read_buf(struct nand_chip *chip, uint8_t *buf, int len) *buf =brcmnand_read_byte (chip); } -static void brcmnand_write_buf (struct mtd_info *mtd,const uint8_t *buf, -int len) +static void brcmnand_write_buf (struct nand_chip *chip,const uint8_t *buf, +int len) {int i; -struct nand_chip *chip =mtd_to_nand (mtd);struct brcmnand_host *host =nand_get_controller_data (chip);switch (host->last_cmd) {
drivers/mtd/nand/raw/cafe_nand.c +2 -3
@@ -117,9 +117,8 @@ static int cafe_device_ready(struct mtd_info *mtd) } -static void cafe_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void cafe_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct cafe_priv *cafe =nand_get_controller_data (chip);if (cafe->usedma)
@@ -540,7 +539,7 @@ static int cafe_nand_write_page_lowlevel(struct nand_chip *chip,struct cafe_priv *cafe =nand_get_controller_data (chip);nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize); - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);/* Set up ECC autogeneration */ cafe->ctl2 |= (1 <<30 );
drivers/mtd/nand/raw/cmx270_nand.c +2 -2
@@ -54,10 +54,10 @@ static u_char cmx270_read_byte(struct nand_chip *this)return (readl (this->IO_ADDR_R) >>16 ); } -static void cmx270_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void cmx270_write_buf (struct nand_chip *this,const u_char *buf, +int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);for (i=0 ; i<len; i++)writel ((*buf++ <<16 ), this->IO_ADDR_W);
drivers/mtd/nand/raw/cs553x_nand.c +3 -6
@@ -103,10 +103,8 @@ static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)memcpy_fromio (buf, this->IO_ADDR_R, len); } -static void cs553x_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void cs553x_write_buf (struct nand_chip *this,const u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd); -while (unlikely (len >0x800 )) {memcpy_toio (this->IO_ADDR_R, buf,0x800 ); buf +=0x800 ;
@@ -120,9 +118,8 @@ static unsigned char cs553x_read_byte(struct nand_chip *this)return readb (this->IO_ADDR_R); } -static void cs553x_write_byte (struct mtd_info *mtd,u_char byte) +static void cs553x_write_byte (struct nand_chip *this,u_char byte) { -struct nand_chip *this =mtd_to_nand (mtd);int i =100000 ;while (i &&readb (this->IO_ADDR_R +MM_NAND_STS ) &CS_NAND_CTLR_BUSY ) {
@@ -142,7 +139,7 @@ static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd,writeb (ctl, mmio_base +MM_NAND_CTL ); }if (cmd !=NAND_CMD_NONE ) -cs553x_write_byte (mtd, cmd); +cs553x_write_byte (this, cmd); }static int cs553x_device_ready (struct mtd_info *mtd)
drivers/mtd/nand/raw/davinci_nand.c +2 -4
@@ -446,11 +446,9 @@ static void nand_davinci_read_buf(struct nand_chip *chip, uint8_t *buf,ioread8_rep (chip->IO_ADDR_R, buf, len); } -static void nand_davinci_write_buf (struct mtd_info *mtd, -const uint8_t *buf,int len) +static void nand_davinci_write_buf (struct nand_chip *chip,const uint8_t *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd); -if ((0x03 & ((uintptr_t )buf)) ==0 && (0x03 & len) ==0 )iowrite32_rep (chip->IO_ADDR_R, buf, len >>2 );else if ((0x01 & ((uintptr_t )buf)) ==0 && (0x01 & len) ==0 )
drivers/mtd/nand/raw/denali.c +7 -6
@@ -226,9 +226,10 @@ static void denali_read_buf(struct nand_chip *chip, uint8_t *buf, int len) buf[i] = denali->host_read (denali, addr); } -static void denali_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void denali_write_buf (struct nand_chip *chip,const uint8_t *buf, +int len) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));u32 addr =DENALI_MAP11_DATA |DENALI_BANK (denali);int i;
@@ -247,10 +248,10 @@ static void denali_read_buf16(struct nand_chip *chip, uint8_t *buf, int len) buf16[i] = denali->host_read (denali, addr); } -static void denali_write_buf16 (struct mtd_info *mtd,const uint8_t *buf, +static void denali_write_buf16 (struct nand_chip *chip,const uint8_t *buf,int len) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));u32 addr =DENALI_MAP11_DATA |DENALI_BANK (denali);const uint16_t *buf16 = (const uint16_t *)buf;int i;
@@ -268,9 +269,9 @@ static uint8_t denali_read_byte(struct nand_chip *chip)return byte; } -static void denali_write_byte (struct mtd_info *mtd,uint8_t byte) +static void denali_write_byte (struct nand_chip *chip,uint8_t byte) { -denali_write_buf (mtd, &byte,1 ); +denali_write_buf (chip, &byte,1 ); }static void denali_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl)
drivers/mtd/nand/raw/diskonchip.c +8 -12
@@ -290,9 +290,8 @@ static inline int DoC_WaitReady(struct doc_priv *doc)return ret; } -static void doc2000_write_byte (struct mtd_info *mtd,u_char datum) +static void doc2000_write_byte (struct nand_chip *this,u_char datum) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
@@ -316,9 +315,9 @@ static u_char doc2000_read_byte(struct nand_chip *this)return ret; } -static void doc2000_writebuf (struct mtd_info *mtd,const u_char *buf,int len) +static void doc2000_writebuf (struct nand_chip *this,const u_char *buf, +int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -448,9 +447,8 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)return status; } -static void doc2001_write_byte (struct mtd_info *mtd,u_char datum) +static void doc2001_write_byte (struct nand_chip *this,u_char datum) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
@@ -472,9 +470,8 @@ static u_char doc2001_read_byte(struct nand_chip *this)return ReadDOC (docptr, LastDataRead); } -static void doc2001_writebuf (struct mtd_info *mtd,const u_char *buf,int len) +static void doc2001_writebuf (struct nand_chip *this,const u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -515,9 +512,8 @@ static u_char doc2001plus_read_byte(struct nand_chip *this)return ret; } -static void doc2001plus_writebuf (struct mtd_info *mtd,const u_char *buf,int len) +static void doc2001plus_writebuf (struct nand_chip *this,const u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int i;
@@ -638,9 +634,9 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd, }if (cmd !=NAND_CMD_NONE ) {if (DoC_is_2000 (doc)) -doc2000_write_byte (mtd, cmd); +doc2000_write_byte (this, cmd);else -doc2001_write_byte (mtd, cmd); +doc2001_write_byte (this, cmd); } }
drivers/mtd/nand/raw/docg4.c +5 -5
@@ -271,10 +271,10 @@ static void docg4_read_buf(struct nand_chip *nand, uint8_t *buf, int len) p[i] =readw (nand->IO_ADDR_R); } -static void docg4_write_buf16 (struct mtd_info *mtd,const uint8_t *buf,int len) +static void docg4_write_buf16 (struct nand_chip *nand,const uint8_t *buf, +int len) {int i; -struct nand_chip *nand =mtd_to_nand (mtd);uint16_t *p = (uint16_t *) buf; len >>=1 ;
@@ -964,10 +964,10 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *nand,write_nop (docptr);/* write the page data */ -docg4_write_buf16 (mtd, buf,DOCG4_PAGE_SIZE ); +docg4_write_buf16 (nand, buf,DOCG4_PAGE_SIZE );/* oob bytes 0 through 5 are written to I/O reg */ -docg4_write_buf16 (mtd, nand->oob_poi,6 ); +docg4_write_buf16 (nand, nand->oob_poi,6 );/* oob byte 6 written to a separate reg */ writew (nand->oob_poi[6 ], docptr +DOCG4_OOB_6_7 );
@@ -995,7 +995,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *nand,memcpy (ecc_buf, &nand->oob_poi[8 ],8 ); } -docg4_write_buf16 (mtd, ecc_buf,8 ); +docg4_write_buf16 (nand, ecc_buf,8 );write_nop (docptr);write_nop (docptr);writew (0 , docptr +DOC_DATAEND );
drivers/mtd/nand/raw/fsl_elbc_nand.c +5 -5
@@ -543,9 +543,9 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip)/* * Write buf to the FCM Controller Data Buffer */ -static void fsl_elbc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void fsl_elbc_write_buf (struct nand_chip *chip,const u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;unsigned int bufsize = mtd->writesize + mtd->oobsize;
@@ -735,7 +735,7 @@ static int fsl_elbc_write_page(struct nand_chip *chip, const uint8_t *buf,struct mtd_info *mtd =nand_to_mtd (chip);nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize); -fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_elbc_write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
@@ -750,8 +750,8 @@ static int fsl_elbc_write_subpage(struct nand_chip *chip, uint32_t offset,struct mtd_info *mtd =nand_to_mtd (chip);nand_prog_page_begin_op (chip, page,0 ,NULL ,0 ); -fsl_elbc_write_buf (mtd, buf, mtd->writesize); -fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_elbc_write_buf (chip, buf, mtd->writesize); +fsl_elbc_write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
drivers/mtd/nand/raw/fsl_ifc_nand.c +3 -3
@@ -519,9 +519,9 @@ static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip)/* * Write buf to the IFC NAND Controller Data Buffer */ -static void fsl_ifc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void fsl_ifc_write_buf (struct nand_chip *chip,const u8 *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);unsigned int bufsize = mtd->writesize + mtd->oobsize;
@@ -710,7 +710,7 @@ static int fsl_ifc_write_page(struct nand_chip *chip, const uint8_t *buf,struct mtd_info *mtd =nand_to_mtd (chip);nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize); -fsl_ifc_write_buf (mtd, chip->oob_poi, mtd->oobsize); +fsl_ifc_write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
drivers/mtd/nand/raw/fsl_upm.c +2 -2
@@ -140,9 +140,9 @@ static void fun_read_buf(struct nand_chip *chip, uint8_t *buf, int len) buf[i] =in_8 (fun->chip.IO_ADDR_R); } -static void fun_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void fun_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));int i;for (i =0 ; i < len; i++) {
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -2
@@ -868,9 +868,8 @@ static void gpmi_read_buf(struct nand_chip *chip, uint8_t *buf, int len)gpmi_read_data (this, buf, len); } -static void gpmi_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void gpmi_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);dev_dbg (this->dev,"len is %d\n" , len);
drivers/mtd/nand/raw/hisi504_nand.c +2 -3
@@ -380,9 +380,8 @@ static uint8_t hisi_nfc_read_byte(struct nand_chip *chip) }static void -hisi_nfc_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +hisi_nfc_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct hinfc_host *host =nand_get_controller_data (chip);memcpy (host->buffer + host->offset, buf, len);
@@ -583,7 +582,7 @@ static int hisi_nand_write_page_hwecc(struct nand_chip *chip,nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize);if (oob_required) - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
drivers/mtd/nand/raw/lpc32xx_slc.c +4 -4
@@ -381,9 +381,9 @@ static void lpc32xx_nand_read_buf(struct nand_chip *chip, u_char *buf, int len)/* * Simple device write without ECC */ -static void lpc32xx_nand_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void lpc32xx_nand_write_buf (struct nand_chip *chip,const uint8_t *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);/* Direct device write with no ECC */
@@ -706,7 +706,7 @@ static int lpc32xx_nand_write_page_syndrome(struct nand_chip *chip,lpc32xx_slc_ecc_copy (pb, (uint32_t *)host->ecc_buf, chip->ecc.steps);/* Write ECC data to device */ - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
@@ -724,7 +724,7 @@ static int lpc32xx_nand_write_page_raw_syndrome(struct nand_chip *chip,/* Raw writes can just use the FIFO interface */ nand_prog_page_begin_op (chip, page,0 , buf, chip->ecc.size * chip->ecc.steps); - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
drivers/mtd/nand/raw/mpc5121_nfc.c +3 -3
@@ -499,10 +499,10 @@ static void mpc5121_nfc_read_buf(struct nand_chip *chip, u_char *buf, int len) }/* Write data to NFC buffers */ -static void mpc5121_nfc_write_buf (struct mtd_info *mtd, -const u_char *buf,int len) +static void mpc5121_nfc_write_buf (struct nand_chip *chip,const u_char *buf, +int len) { -mpc5121_nfc_buf_copy (mtd, (u_char *)buf, len,1 ); +mpc5121_nfc_buf_copy (nand_to_mtd (chip), (u_char *)buf, len,1 ); }/* Read byte from NFC buffers */
drivers/mtd/nand/raw/mtk_nand.c +4 -4
@@ -474,9 +474,9 @@ static void mtk_nfc_read_buf(struct nand_chip *chip, u8 *buf, int len) buf[i] =mtk_nfc_read_byte (chip); } -static void mtk_nfc_write_byte (struct mtd_info *mtd,u8 byte) +static void mtk_nfc_write_byte (struct nand_chip *chip,u8 byte) { -struct mtk_nfc *nfc =nand_get_controller_data (mtd_to_nand (mtd)); +struct mtk_nfc *nfc =nand_get_controller_data (chip);u32 reg; reg =nfi_readl (nfc,NFI_STA ) &NFI_FSM_MASK ;
@@ -495,12 +495,12 @@ static void mtk_nfc_write_byte(struct mtd_info *mtd, u8 byte)nfi_writeb (nfc, byte,NFI_DATAW ); } -static void mtk_nfc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void mtk_nfc_write_buf (struct nand_chip *chip,const u8 *buf,int len) {int i;for (i =0 ; i < len; i++) -mtk_nfc_write_byte (mtd, buf[i]); +mtk_nfc_write_byte (chip, buf[i]); } static int mtk_nfc_setup_data_interface(struct mtd_info *mtd, int csline,
drivers/mtd/nand/raw/mxc_nand.c +4 -4
@@ -921,10 +921,10 @@ static u_char mxc_nand_read_byte(struct nand_chip *nand_chip)/* Write data of length len to buffer buf. The data to be * written on NAND Flash is first copied to RAMbuffer. After the Data Input * Operation by the NFC, the data is written to NAND Flash */ -static void mxc_nand_write_buf (struct mtd_info *mtd, -const u_char *buf,int len) +static void mxc_nand_write_buf (struct nand_chip *nand_chip,const u_char *buf, +int len) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand_chip);struct mxc_nand_host *host =nand_get_controller_data (nand_chip);u16 col = host->buf_start;int n = mtd->oobsize + mtd->writesize - col;
@@ -1405,7 +1405,7 @@ static int mxc_nand_set_features(struct mtd_info *mtd, struct nand_chip *chip, host->buf_start =0 ;for (i =0 ; i <ONFI_SUBFEATURE_PARAM_LEN ; ++i) - chip->write_byte (mtd, subfeature_param[i]); + chip->write_byte (chip, subfeature_param[i]);memcpy32_toio (host->main_area0, host->data_buf, mtd->writesize); host->devtype_data->send_cmd (host,NAND_CMD_SET_FEATURES , false);
drivers/mtd/nand/raw/nand_base.c +17 -24
126 lines not on this page · raw message
drivers/mtd/nand/raw/nand_hynix.c +1 -1
@@ -111,7 +111,7 @@ static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val) } chip->cmdfunc (mtd,NAND_CMD_NONE , column,-1 ); - chip->write_byte (mtd, val); + chip->write_byte (chip, val);return 0 ; }
drivers/mtd/nand/raw/nandsim.c +4 -5
@@ -1933,9 +1933,8 @@ static u_char ns_nand_read_byte(struct nand_chip *chip)return outb; } -static void ns_nand_write_byte (struct mtd_info *mtd,u_char byte) +static void ns_nand_write_byte (struct nand_chip *chip,u_char byte) { -struct nand_chip *chip =mtd_to_nand (mtd);struct nandsim *ns =nand_get_controller_data (chip);/* Sanity and correctness checks */
@@ -2098,7 +2097,7 @@ static void ns_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int bitmask) ns->lines.ce = bitmask &NAND_NCE ?1 :0 ;if (cmd !=NAND_CMD_NONE ) -ns_nand_write_byte (mtd, cmd); +ns_nand_write_byte (chip, cmd); }static int ns_device_ready (struct mtd_info *mtd)
@@ -2107,9 +2106,9 @@ static int ns_device_ready(struct mtd_info *mtd)return 1 ; } -static void ns_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void ns_nand_write_buf (struct nand_chip *chip,const u_char *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct nandsim *ns =nand_get_controller_data (chip);/* Check that chip is expecting data input */
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -125,9 +125,8 @@ static void ndfc_read_buf(struct nand_chip *chip, uint8_t *buf, int len) *p++ =in_be32 (ndfc->ndfcbase +NDFC_DATA ); } -static void ndfc_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void ndfc_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip);uint32_t *p = (uint32_t *) buf;
drivers/mtd/nand/raw/nuc900_nand.c +2 -2
@@ -99,11 +99,11 @@ static void nuc900_nand_read_buf(struct nand_chip *chip, buf[i] = (unsigned char )read_data_reg (nand); } -static void nuc900_nand_write_buf (struct mtd_info *mtd, +static void nuc900_nand_write_buf (struct nand_chip *chip,const unsigned char *buf,int len) {int i; -struct nuc900_nand *nand =mtd_to_nuc900 (mtd); +struct nuc900_nand *nand =mtd_to_nuc900 (nand_to_mtd (chip));for (i =0 ; i < len; i++)write_data_reg (nand, buf[i]);
drivers/mtd/nand/raw/omap2.c +20 -16
@@ -384,13 +384,14 @@ static void omap_read_buf_pref(struct nand_chip *chip, u_char *buf, int len)/** * omap_write_buf_pref - write buffer to NAND controller -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: data buffer * @len: number of bytes to write */ -static void omap_write_buf_pref (struct mtd_info *mtd, -const u_char *buf,int len) +static void omap_write_buf_pref (struct nand_chip *chip,const u_char *buf, +int len) { +struct mtd_info *mtd =nand_to_mtd (chip);struct omap_nand_info *info =mtd_to_omap (mtd);uint32_t w_count =0 ;int i =0 , ret =0 ;
@@ -547,18 +548,20 @@ static void omap_read_buf_dma_pref(struct nand_chip *chip, u_char *buf,/** * omap_write_buf_dma_pref - write buffer to NAND controller -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: data buffer * @len: number of bytes to write */ -static void omap_write_buf_dma_pref (struct mtd_info *mtd, -const u_char *buf,int len) +static void omap_write_buf_dma_pref (struct nand_chip *chip,const u_char *buf, +int len) { +struct mtd_info *mtd =nand_to_mtd (chip); +if (len <= mtd->oobsize) -omap_write_buf_pref (mtd, buf, len); +omap_write_buf_pref (chip, buf, len);else /* start transfer in DMA mode */ -omap_nand_dma_transfer (mtd, (u_char *) buf, len,0x1 ); +omap_nand_dma_transfer (mtd, (u_char *)buf, len,0x1 ); }/*
@@ -657,20 +660,21 @@ static void omap_read_buf_irq_pref(struct nand_chip *chip, u_char *buf,/* * omap_write_buf_irq_pref - write buffer to NAND controller -* @mtd: MTD device structure +* @chip: NAND chip object * @buf: data buffer * @len: number of bytes to write */ -static void omap_write_buf_irq_pref (struct mtd_info *mtd, -const u_char *buf,int len) +static void omap_write_buf_irq_pref (struct nand_chip *chip,const u_char *buf, +int len) { +struct mtd_info *mtd =nand_to_mtd (chip);struct omap_nand_info *info =mtd_to_omap (mtd);int ret =0 ;unsigned long tim, limit;u32 val;if (len <= mtd->oobsize) { -omap_write_buf_pref (mtd, buf, len); +omap_write_buf_pref (chip, buf, len);return ; }
@@ -1537,7 +1541,7 @@ static int omap_write_page_bch(struct nand_chip *chip, const uint8_t *buf, chip->ecc.hwctl (chip,NAND_ECC_WRITE );/* Write data */ - chip->write_buf (mtd, buf, mtd->writesize); + chip->write_buf (chip, buf, mtd->writesize);/* Update ecc vector from GPMC result registers */ omap_calculate_ecc_bch_multi (mtd, buf, &ecc_calc[0 ]);
@@ -1548,7 +1552,7 @@ static int omap_write_page_bch(struct nand_chip *chip, const uint8_t *buf,return ret;/* Write ecc vector to OOB area */ - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
@@ -1589,7 +1593,7 @@ static int omap_write_subpage_bch(struct nand_chip *chip, u32 offset, chip->ecc.hwctl (chip,NAND_ECC_WRITE );/* Write data */ - chip->write_buf (mtd, buf, mtd->writesize); + chip->write_buf (chip, buf, mtd->writesize);for (step =0 ; step < ecc_steps; step++) {/* mask ECC of un-touched subpages by padding 0xFF */
@@ -1614,7 +1618,7 @@ static int omap_write_subpage_bch(struct nand_chip *chip, u32 offset,return ret;/* write OOB buffer to NAND device */ - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
drivers/mtd/nand/raw/oxnas_nand.c +2 -2
@@ -52,9 +52,9 @@ static void oxnas_nand_read_buf(struct nand_chip *chip, u8 *buf, int len)ioread8_rep (oxnas->io_base, buf, len); } -static void oxnas_nand_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void oxnas_nand_write_buf (struct nand_chip *chip,const u8 *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct oxnas_nand_ctrl *oxnas =nand_get_controller_data (chip);iowrite8_rep (oxnas->io_base, buf, len);
drivers/mtd/nand/raw/pasemi_nand.c +2 -3
@@ -53,10 +53,9 @@ static void pasemi_read_buf(struct nand_chip *chip, u_char *buf, int len)memcpy_fromio (buf, chip->IO_ADDR_R, len); } -static void pasemi_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void pasemi_write_buf (struct nand_chip *chip,const u_char *buf, +int len) { -struct nand_chip *chip =mtd_to_nand (mtd); -while (len >0x800 ) {memcpy_toio (chip->IO_ADDR_R, buf,0x800 ); buf +=0x800 ;
drivers/mtd/nand/raw/plat_nand.c +1 -11
@@ -44,14 +44,6 @@ static void plat_nand_select_chip(struct mtd_info *mtd, int cs) pdata->ctrl.select_chip (mtd_to_nand (mtd), cs); } -static void plat_nand_write_buf (struct mtd_info *mtd,const uint8_t *buf, -int len) -{ -struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent); - - pdata->ctrl.write_buf (mtd_to_nand (mtd), buf, len); -} -/* * Probe for the NAND device. */
@@ -101,9 +93,7 @@ static int plat_nand_probe(struct platform_device *pdev)if (pdata->ctrl.select_chip) data->chip.select_chip = plat_nand_select_chip; -if (pdata->ctrl.write_buf) - data->chip.write_buf = plat_nand_write_buf; - + data->chip.write_buf = pdata->ctrl.write_buf; data->chip.read_buf = pdata->ctrl.read_buf; data->chip.chip_delay = pdata->chip.chip_delay; data->chip.options |= pdata->chip.options;
drivers/mtd/nand/raw/qcom_nandc.c +1 -2
@@ -2312,10 +2312,9 @@ static void qcom_nandc_read_buf(struct nand_chip *chip, uint8_t *buf, int len) nandc->buf_start += real_len; } -static void qcom_nandc_write_buf (struct mtd_info *mtd,const uint8_t *buf, +static void qcom_nandc_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);int real_len =min_t (size_t, len, nandc->buf_count - nandc->buf_start);
drivers/mtd/nand/raw/r852.c +2 -2
@@ -232,9 +232,9 @@ static void r852_do_dma(struct r852_device *dev, uint8_t *buf, int do_read)/* * Program data lines of the nand chip to send data to it */ -static void r852_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void r852_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));uint32_t reg;/* Don't allow any access to hardware if we suspect card removal */
drivers/mtd/nand/raw/s3c2410.c +3 -3
@@ -696,16 +696,16 @@ static void s3c2440_nand_read_buf(struct nand_chip *this, u_char *buf, int len) } } -static void s3c2410_nand_write_buf (struct mtd_info *mtd,const u_char *buf, +static void s3c2410_nand_write_buf (struct nand_chip *this,const u_char *buf,int len) { -struct nand_chip *this =mtd_to_nand (mtd);writesb (this->IO_ADDR_W, buf, len); } -static void s3c2440_nand_write_buf (struct mtd_info *mtd,const u_char *buf, +static void s3c2440_nand_write_buf (struct nand_chip *this,const u_char *buf,int len) { +struct mtd_info *mtd =nand_to_mtd (this);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);writesl (info->regs +S3C2440_NFDATA , buf, len >>2 );
drivers/mtd/nand/raw/sh_flctl.c +3 -3
@@ -628,7 +628,7 @@ static int flctl_write_page_hwecc(struct nand_chip *chip, const uint8_t *buf,struct mtd_info *mtd =nand_to_mtd (chip);nand_prog_page_begin_op (chip, page,0 , buf, mtd->writesize); - chip->write_buf (mtd, chip->oob_poi, mtd->oobsize); + chip->write_buf (chip, chip->oob_poi, mtd->oobsize);return nand_prog_page_end_op (chip); }
@@ -970,9 +970,9 @@ static void flctl_select_chip(struct mtd_info *mtd, int chipnr) } } -static void flctl_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) +static void flctl_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct sh_flctl *flctl =mtd_to_flctl (mtd); +struct sh_flctl *flctl =mtd_to_flctl (nand_to_mtd (chip));memcpy (&flctl->done_buff[flctl->index], buf, len); flctl->index += len;
drivers/mtd/nand/raw/socrates_nand.c +3 -4
@@ -34,15 +34,14 @@ struct socrates_nand_host {/** * socrates_nand_write_buf - write buffer to chip -* @mtd: MTD device structure +* @this: NAND chip object * @buf: data buffer * @len: number of bytes to write */ -static void socrates_nand_write_buf (struct mtd_info *mtd, -const uint8_t *buf,int len) +static void socrates_nand_write_buf (struct nand_chip *this,const uint8_t *buf, +int len) {int i; -struct nand_chip *this =mtd_to_nand (mtd);struct socrates_nand_host *host =nand_get_controller_data (this);for (i =0 ; i < len; i++) {
drivers/mtd/nand/raw/sunxi_nand.c +2 -3
@@ -501,10 +501,9 @@ static void sunxi_nfc_read_buf(struct nand_chip *nand, uint8_t *buf, int len) } } -static void sunxi_nfc_write_buf (struct mtd_info *mtd,const uint8_t *buf, +static void sunxi_nfc_write_buf (struct nand_chip *nand,const uint8_t *buf,int len) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);int ret;
@@ -760,7 +759,7 @@ static void sunxi_nfc_randomizer_write_buf(struct mtd_info *mtd, {sunxi_nfc_randomizer_config (mtd, page, ecc);sunxi_nfc_randomizer_enable (mtd); -sunxi_nfc_write_buf (mtd, buf, len); +sunxi_nfc_write_buf (mtd_to_nand (mtd), buf, len);sunxi_nfc_randomizer_disable (mtd); }
drivers/mtd/nand/raw/tango_nand.c +3 -5
@@ -149,9 +149,9 @@ static void tango_read_buf(struct nand_chip *chip, u8 *buf, int len)ioread8_rep (tchip->base +PBUS_DATA , buf, len); } -static void tango_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void tango_write_buf (struct nand_chip *chip,const u8 *buf,int len) { -struct tango_chip *tchip =to_tango_chip (mtd_to_nand (mtd)); +struct tango_chip *tchip =to_tango_chip (chip);iowrite8_rep (tchip->base +PBUS_DATA , buf, len); }
@@ -338,15 +338,13 @@ static void aux_read(struct nand_chip *chip, u8 **buf, int len, int *pos)static void aux_write (struct nand_chip *chip,const u8 **buf,int len,int *pos) { -struct mtd_info *mtd =nand_to_mtd (chip); - *pos += len;if (!*buf) {/* skip over "len" bytes */ nand_change_write_column_op (chip, *pos,NULL ,0 , false); }else { -tango_write_buf (mtd, *buf, len); +tango_write_buf (chip, *buf, len); *buf += len; } }
drivers/mtd/nand/raw/tmio_nand.c +2 -2
@@ -245,9 +245,9 @@ static u_char tmio_nand_read_byte(struct nand_chip *chip)*buffer functions. */ static void -tmio_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +tmio_nand_write_buf (struct nand_chip *chip,const u_char *buf,int len) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));tmio_iowrite16_rep (tmio->fcr +FCR_DATA , buf, len >>1 ); }
drivers/mtd/nand/raw/txx9ndfmc.c +2 -2
@@ -109,10 +109,10 @@ static uint8_t txx9ndfmc_read_byte(struct nand_chip *chip)return txx9ndfmc_read (dev,TXX9_NDFDTR ); } -static void txx9ndfmc_write_buf (struct mtd_info *mtd,const uint8_t *buf, +static void txx9ndfmc_write_buf (struct nand_chip *chip,const uint8_t *buf,int len) { -struct platform_device *dev =mtd_to_platdev (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));void __iomem *ndfdtr =ndregaddr (dev,TXX9_NDFDTR );u32 mcr =txx9ndfmc_read (dev,TXX9_NDFMCR );
drivers/mtd/nand/raw/xway_nand.c +2 -2
@@ -138,12 +138,12 @@ static void xway_read_buf(struct nand_chip *chip, u_char *buf, int len) buf[i] =xway_readb (nand_to_mtd (chip),NAND_WRITE_DATA ); } -static void xway_write_buf (struct mtd_info *mtd,const u_char *buf,int len) +static void xway_write_buf (struct nand_chip *chip,const u_char *buf,int len) {int i;for (i =0 ; i < len; i++) -xway_writeb (mtd,NAND_WRITE_DATA , buf[i]); +xway_writeb (nand_to_mtd (chip),NAND_WRITE_DATA , buf[i]); }/*
drivers/staging/mt29f_spinand/mt29f_spinand.c +2 -2
@@ -724,9 +724,9 @@ static int spinand_wait(struct mtd_info *mtd, struct nand_chip *chip)return 0 ; } -static void spinand_write_buf (struct mtd_info *mtd,const u8 *buf,int len) +static void spinand_write_buf (struct nand_chip *chip,const u8 *buf,int len) { -struct spinand_state *state =mtd_to_state (mtd); +struct spinand_state *state =mtd_to_state (nand_to_mtd (chip));memcpy (state->buf + state->buf_ptr, buf, len); state->buf_ptr += len;
include/linux/mtd/rawnand.h +2 -2
@@ -1284,8 +1284,8 @@ struct nand_chip {void __iomem *IO_ADDR_W ;uint8_t (*read_byte)(struct nand_chip *chip); -void (*write_byte)(struct mtd_info *mtd,uint8_t byte); -void (*write_buf)(struct mtd_info *mtd,const uint8_t *buf,int len); +void (*write_byte)(struct nand_chip *chip,uint8_t byte); +void (*write_buf)(struct nand_chip *chip,const uint8_t *buf,int len);void (*read_buf)(struct nand_chip *chip,uint8_t *buf,int len);void (*select_chip)(struct mtd_info *mtd,int chip);int (*block_bad)(struct mtd_info *mtd,loff_t ofs);
Signature · 1 line
2.14.1
PATCH v2 12/23 mtd: rawnand: Pass a nand_chip object to chip->select_chip()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->select_chip() hook.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 9 ++- drivers/mtd/nand/raw/au1550nd.c | 4 +- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 4 +- drivers/mtd/nand/raw/cafe_nand.c | 3 +- drivers/mtd/nand/raw/davinci_nand.c | 4 +- drivers/mtd/nand/raw/denali.c | 6 +- drivers/mtd/nand/raw/diskonchip.c | 11 ++- drivers/mtd/nand/raw/docg4.c | 3 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +- drivers/mtd/nand/raw/fsl_upm.c | 4 +- drivers/mtd/nand/raw/fsmc_nand.c | 4 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 20 +++--- drivers/mtd/nand/raw/hisi504_nand.c | 3 +- drivers/mtd/nand/raw/jz4740_nand.c | 9 ++- drivers/mtd/nand/raw/jz4780_nand.c | 4 +- drivers/mtd/nand/raw/marvell_nand.c | 3 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 12 ++-- drivers/mtd/nand/raw/mtk_nand.c | 5 +- drivers/mtd/nand/raw/mxc_nand.c | 8 +-- drivers/mtd/nand/raw/nand_base.c | 86 ++++++++++++------------ drivers/mtd/nand/raw/ndfc.c | 3 +- drivers/mtd/nand/raw/plat_nand.c | 11 +-- drivers/mtd/nand/raw/qcom_nandc.c | 3 +- drivers/mtd/nand/raw/r852.c | 5 +- drivers/mtd/nand/raw/s3c2410.c | 5 +- drivers/mtd/nand/raw/sh_flctl.c | 4 +- drivers/mtd/nand/raw/sunxi_nand.c | 4 +- drivers/mtd/nand/raw/tango_nand.c | 3 +- drivers/mtd/nand/raw/tegra_nand.c | 3 +- drivers/mtd/nand/raw/vf610_nfc.c | 8 +-- drivers/mtd/nand/raw/xway_nand.c | 3 +- drivers/staging/mt29f_spinand/mt29f_spinand.c | 2 +- include/linux/mtd/rawnand.h | 2 +- 34 files changed, 117 insertions(+), 145 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -5
@@ -483,9 +483,8 @@ static int atmel_nand_dev_ready(struct mtd_info *mtd)return gpiod_get_value (nand->activecs->rb.gpio); } -static void atmel_nand_select_chip (struct mtd_info *mtd,int cs) +static void atmel_nand_select_chip (struct nand_chip *chip,int cs) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);if (cs <0 || cs >= nand->numcs) {
@@ -514,15 +513,15 @@ static int atmel_hsmc_nand_dev_ready(struct mtd_info *mtd)return status &ATMEL_HSMC_NFC_SR_RBEDGE (nand->activecs->rb.id); } -static void atmel_hsmc_nand_select_chip (struct mtd_info *mtd,int cs) +static void atmel_hsmc_nand_select_chip (struct nand_chip *chip,int cs) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_hsmc_nand_controller *nc; nc =to_hsmc_nand_controller (chip->controller); -atmel_nand_select_chip (mtd, cs); +atmel_nand_select_chip (chip, cs);if (!nand->activecs) { regmap_write(nc->base.smc, ATMEL_HSMC_NFC_CTRL,
drivers/mtd/nand/raw/au1550nd.c +2 -2
@@ -227,10 +227,10 @@ int au1550_device_ready(struct mtd_info *mtd)* chip needs it to be asserted during chip not ready time but the NAND * controller keeps it released. * -* @mtd: MTD device structure +* @this: NAND chip object * @chip: chipnumber to select, -1 for deselect */ -static void au1550_select_chip (struct mtd_info *mtd,int chip) +static void au1550_select_chip (struct nand_chip *this,int chip) { }
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +2 -2
@@ -191,8 +191,8 @@ static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, }/* Default nand_select_chip calls cmd_ctrl, which is not used in BCM4706 */ -static void bcm47xxnflash_ops_bcm4706_select_chip (struct mtd_info *mtd, -int chip) +static void bcm47xxnflash_ops_bcm4706_select_chip (struct nand_chip *chip, +int cs) {return ; }
drivers/mtd/nand/raw/cafe_nand.c +1 -2
@@ -314,9 +314,8 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,cafe_writel (cafe, cafe->ctl2,NAND_CTRL2 ); } -static void cafe_select_chip (struct mtd_info *mtd,int chipnr) +static void cafe_select_chip (struct nand_chip *chip,int chipnr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct cafe_priv *cafe =nand_get_controller_data (chip);cafe_dev_dbg (&cafe->pdev->dev,"select_chip %d\n" , chipnr);
drivers/mtd/nand/raw/davinci_nand.c +2 -2
@@ -118,9 +118,9 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd,iowrite8 (cmd, nand->IO_ADDR_W); } -static void nand_davinci_select_chip (struct mtd_info *mtd,int chip) +static void nand_davinci_select_chip (struct nand_chip *nand,int chip) { -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (nand)); info->current_cs = info->vaddr;
drivers/mtd/nand/raw/denali.c +3 -3
@@ -897,11 +897,11 @@ static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, page, 0, 1); } -static void denali_select_chip (struct mtd_info *mtd,int chip) +static void denali_select_chip (struct nand_chip *chip,int cs) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip)); - denali->active_bank = chip; + denali->active_bank = cs; }static int denali_waitfunc (struct mtd_info *mtd,struct nand_chip *chip)
drivers/mtd/nand/raw/diskonchip.c +5 -6
@@ -85,7 +85,7 @@ static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 };static void doc200x_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int bitmask); -static void doc200x_select_chip (struct mtd_info *mtd,int chip); +static void doc200x_select_chip (struct nand_chip *this,int chip);static int debug =0 ;module_param (debug, int,0 );
@@ -371,7 +371,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)struct doc_priv *doc =nand_get_controller_data (this);uint16_t ret; -doc200x_select_chip (mtd, nr); +doc200x_select_chip (this, nr);doc200x_hwcontrol (mtd,NAND_CMD_READID ,NAND_CTRL_CLE |NAND_CTRL_CHANGE );doc200x_hwcontrol (mtd,0 ,NAND_CTRL_ALE |NAND_CTRL_CHANGE );
@@ -559,9 +559,8 @@ static void doc2001plus_readbuf(struct nand_chip *this, u_char *buf, int len)printk ("\n" ); } -static void doc2001plus_select_chip (struct mtd_info *mtd,int chip) +static void doc2001plus_select_chip (struct nand_chip *this,int chip) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int floor =0 ;
@@ -586,9 +585,9 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) doc->curfloor = floor; } -static void doc200x_select_chip (struct mtd_info *mtd,int chip) +static void doc200x_select_chip (struct nand_chip *this,int chip) { -struct nand_chip *this =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (this);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int floor =0 ;
drivers/mtd/nand/raw/docg4.c +1 -2
@@ -333,13 +333,12 @@ static int docg4_wait(struct mtd_info *mtd, struct nand_chip *nand)return status; } -static void docg4_select_chip (struct mtd_info *mtd,int chip) +static void docg4_select_chip (struct nand_chip *nand,int chip) {/* * Select among multiple cascaded chips ("floors"). Multiple floors are * not yet supported, so the only valid non-negative value is 0. */ -struct nand_chip *nand =mtd_to_nand (mtd);struct docg4_priv *doc =nand_get_controller_data (nand);void __iomem *docptr = doc->virtadr;
drivers/mtd/nand/raw/fsl_elbc_nand.c +1 -1
@@ -533,7 +533,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, } } -static void fsl_elbc_select_chip (struct mtd_info *mtd,int chip) +static void fsl_elbc_select_chip (struct nand_chip *chip,int cs) {/* The hardware does not seem to support multiple * chips per bank.
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -1
@@ -509,7 +509,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, } } -static void fsl_ifc_select_chip (struct mtd_info *mtd,int chip) +static void fsl_ifc_select_chip (struct nand_chip *chip,int cs) {/* The hardware does not seem to support multiple * chips per bank.
drivers/mtd/nand/raw/fsl_upm.c +2 -2
@@ -108,9 +108,9 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)fun_wait_rnb (fun); } -static void fun_select_chip (struct mtd_info *mtd,int mchip_nr) +static void fun_select_chip (struct nand_chip *chip,int mchip_nr) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd);if (mchip_nr ==-1 ) {
drivers/mtd/nand/raw/fsmc_nand.c +2 -2
@@ -610,9 +610,9 @@ static void fsmc_write_buf_dma(struct mtd_info *mtd, const uint8_t *buf, }/* fsmc_select_chip - assert or deassert nCE */ -static void fsmc_select_chip (struct mtd_info *mtd,int chipnr) +static void fsmc_select_chip (struct nand_chip *chip,int chipnr) { -struct fsmc_nand_data *host =mtd_to_fsmc (mtd); +struct fsmc_nand_data *host =mtd_to_fsmc (nand_to_mtd (chip));u32 pc;/* Support only one CS */
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +9 -11
@@ -825,9 +825,8 @@ static int gpmi_dev_ready(struct mtd_info *mtd)return gpmi_is_ready (this, this->current_chip); } -static void gpmi_select_chip (struct mtd_info *mtd,int chipnr) +static void gpmi_select_chip (struct nand_chip *chip,int chipnr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);int ret;
@@ -1552,7 +1551,7 @@ static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs)int column, page, chipnr; chipnr = (int )(ofs >> chip->chip_shift); - chip->select_chip (mtd, chipnr); + chip->select_chip (chip, chipnr); column = !GPMI_IS_MX23 (this) ? mtd->writesize :0 ;
@@ -1565,7 +1564,7 @@ static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs) ret =nand_prog_page_op (chip, page, column, block_mark,1 ); - chip->select_chip (mtd,-1 ); + chip->select_chip (chip,-1 );return ret; }
@@ -1602,7 +1601,6 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)struct boot_rom_geometry *rom_geo = &this->rom_geometry;struct device *dev = this->dev;struct nand_chip *chip = &this->nand; -struct mtd_info *mtd =nand_to_mtd (chip);unsigned int search_area_size_in_strides;unsigned int stride;unsigned int page;
@@ -1614,7 +1612,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) search_area_size_in_strides =1 << rom_geo->search_area_stride_exponent; saved_chip_number = this->current_chip; - chip->select_chip (mtd,0 ); + chip->select_chip (chip,0 );/* * Loop through the first search area, looking for the NCB fingerprint.
@@ -1642,7 +1640,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this) } - chip->select_chip (mtd, saved_chip_number); + chip->select_chip (chip, saved_chip_number);if (found_an_ncb_fingerprint)dev_dbg (dev,"\tFound a fingerprint\n" );
@@ -1685,7 +1683,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)/* Select chip 0. */ saved_chip_number = this->current_chip; - chip->select_chip (mtd,0 ); + chip->select_chip (chip,0 );/* Loop over blocks in the first search area, erasing them. */ dev_dbg (dev,"Erasing the search area...\n" );
@@ -1717,7 +1715,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this) }/* Deselect chip 0. */ - chip->select_chip (mtd, saved_chip_number); + chip->select_chip (chip, saved_chip_number);return 0 ; }
@@ -1766,10 +1764,10 @@ static int mx23_boot_init(struct gpmi_nand_data *this) byte = block << chip->phys_erase_shift;/* Send the command to read the conventional block mark. */ - chip->select_chip (mtd, chipnr); + chip->select_chip (chip, chipnr);nand_read_page_op (chip, page, mtd->writesize,NULL ,0 ); block_mark = chip->read_byte (chip); - chip->select_chip (mtd,-1 ); + chip->select_chip (chip,-1 );/* * Check if the block is marked bad. If so, we need to mark it
drivers/mtd/nand/raw/hisi504_nand.c +1 -2
@@ -353,9 +353,8 @@ static int hisi_nfc_send_cmd_reset(struct hinfc_host *host, int chipselect)return 0 ; } -static void hisi_nfc_select_chip (struct mtd_info *mtd,int chipselect) +static void hisi_nfc_select_chip (struct nand_chip *chip,int chipselect) { -struct nand_chip *chip =mtd_to_nand (mtd);struct hinfc_host *host =nand_get_controller_data (chip);if (chipselect <0 )
drivers/mtd/nand/raw/jz4740_nand.c +4 -5
@@ -78,10 +78,9 @@ static inline struct jz_nand *mtd_to_jz_nand(struct mtd_info *mtd) return container_of(mtd_to_nand(mtd), struct jz_nand, chip); } -static void jz_nand_select_chip (struct mtd_info *mtd,int chipnr) +static void jz_nand_select_chip (struct nand_chip *chip,int chipnr) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));uint32_t ctrl;int banknr;
@@ -336,14 +335,14 @@ static int jz_nand_detect_bank(struct platform_device *pdev, goto notfound_id;/* Retrieve the IDs from the first chip. */ - chip->select_chip (mtd,0 ); + chip->select_chip (chip,0 );nand_reset_op (chip);nand_readid_op (chip,0 , id,sizeof (id)); *nand_maf_id = id[0 ]; *nand_dev_id = id[1 ]; }else {/* Detect additional chip. */ - chip->select_chip (mtd, chipnr); + chip->select_chip (chip, chipnr);nand_reset_op (chip);nand_readid_op (chip,0 , id,sizeof (id));if (*nand_maf_id != id[0 ] || *nand_dev_id != id[1 ]) {
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -71,9 +71,9 @@ static inline struct jz4780_nand_controller return container_of(ctrl, struct jz4780_nand_controller, controller); } -static void jz4780_nand_select_chip (struct mtd_info *mtd,int chipnr) +static void jz4780_nand_select_chip (struct nand_chip *chip,int chipnr) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip));struct jz4780_nand_controller *nfc =to_jz4780_nand_controller (nand->chip.controller);struct jz4780_nand_cs *cs;
drivers/mtd/nand/raw/marvell_nand.c +1 -2
@@ -701,9 +701,8 @@ static int marvell_nfc_wait_op(struct nand_chip *chip, unsigned int timeout_ms)return 0 ; } -static void marvell_nfc_select_chip (struct mtd_info *mtd,int die_nr) +static void marvell_nfc_select_chip (struct nand_chip *chip,int die_nr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct marvell_nand_chip *marvell_nand =to_marvell_nand (chip);struct marvell_nfc *nfc =to_marvell_nfc (chip->controller);u32 ndcr_generic;
drivers/mtd/nand/raw/mpc5121_nfc.c +7 -5
@@ -263,8 +263,10 @@ static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) }/* Control chip select signals */ -static void mpc5121_nfc_select_chip (struct mtd_info *mtd,int chip) +static void mpc5121_nfc_select_chip (struct nand_chip *nand,int chip) { +struct mtd_info *mtd =nand_to_mtd (nand); +if (chip <0 ) {nfc_clear (mtd,NFC_CONFIG1 ,NFC_CE );return ;
@@ -299,9 +301,9 @@ static int ads5121_chipselect_init(struct mtd_info *mtd) }/* Control chips select signal on ADS5121 board */ -static void ads5121_select_chip (struct mtd_info *mtd,int chip) +static void ads5121_select_chip (struct nand_chip *nand,int chip) { -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct mpc5121_nfc_prv *prv =nand_get_controller_data (nand);u8 v;
@@ -309,10 +311,10 @@ static void ads5121_select_chip(struct mtd_info *mtd, int chip) v |=0x0F ;if (chip >=0 ) { -mpc5121_nfc_select_chip (mtd,0 ); +mpc5121_nfc_select_chip (nand,0 ); v &= ~(1 << chip); }else -mpc5121_nfc_select_chip (mtd,-1 ); +mpc5121_nfc_select_chip (nand,-1 );out_8 (prv->csreg, v); }
drivers/mtd/nand/raw/mtk_nand.c +2 -3
@@ -389,16 +389,15 @@ static int mtk_nfc_hw_runtime_config(struct mtd_info *mtd)return 0 ; } -static void mtk_nfc_select_chip (struct mtd_info *mtd,int chip) +static void mtk_nfc_select_chip (struct nand_chip *nand,int chip) { -struct nand_chip *nand =mtd_to_nand (mtd);struct mtk_nfc *nfc =nand_get_controller_data (nand);struct mtk_nfc_nand_chip *mtk_nand =to_mtk_nand (nand);if (chip <0 )return ; -mtk_nfc_hw_runtime_config (mtd); +mtk_nfc_hw_runtime_config (nand_to_mtd (nand));nfi_writel (nfc, mtk_nand->sels[chip],NFI_CSEL ); }
drivers/mtd/nand/raw/mxc_nand.c +3 -5
@@ -136,7 +136,7 @@ struct mxc_nand_devtype_data {void (*irq_control)(struct mxc_nand_host *,int );u32 (*get_ecc_status)(struct mxc_nand_host *);const struct mtd_ooblayout_ops *ooblayout; -void (*select_chip)(struct mtd_info *mtd,int chip); +void (*select_chip)(struct nand_chip *chip,int cs);int (*setup_data_interface)(struct mtd_info *mtd,int csline,const struct nand_data_interface *conf);void (*enable_hwecc)(struct nand_chip *chip,bool enable);
@@ -957,9 +957,8 @@ static void mxc_nand_read_buf(struct nand_chip *nand_chip, u_char *buf,/* This function is used by upper layer for select and * deselect of the NAND chip */ -static void mxc_nand_select_chip_v1_v3 (struct mtd_info *mtd,int chip) +static void mxc_nand_select_chip_v1_v3 (struct nand_chip *nand_chip,int chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct mxc_nand_host *host =nand_get_controller_data (nand_chip);if (chip ==-1 ) {
@@ -978,9 +977,8 @@ static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip) } } -static void mxc_nand_select_chip_v2 (struct mtd_info *mtd,int chip) +static void mxc_nand_select_chip_v2 (struct nand_chip *nand_chip,int chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct mxc_nand_host *host =nand_get_controller_data (nand_chip);if (chip ==-1 ) {
drivers/mtd/nand/raw/nand_base.c +42 -44
269 lines not on this page · raw message
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -44,10 +44,9 @@ struct ndfc_controller {static struct ndfc_controller ndfc_ctrl[NDFC_MAX_CS ]; -static void ndfc_select_chip (struct mtd_info *mtd,int chip) +static void ndfc_select_chip (struct nand_chip *nchip,int chip) {uint32_t ccr; -struct nand_chip *nchip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (nchip); ccr =in_be32 (ndfc->ndfcbase +NDFC_CCR );
drivers/mtd/nand/raw/plat_nand.c +1 -10
@@ -37,13 +37,6 @@ static int plat_nand_dev_ready(struct mtd_info *mtd)return pdata->ctrl.dev_ready (mtd_to_nand (mtd)); } -static void plat_nand_select_chip (struct mtd_info *mtd,int cs) -{ -struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent); - - pdata->ctrl.select_chip (mtd_to_nand (mtd), cs); -} -/* * Probe for the NAND device. */
@@ -90,9 +83,7 @@ static int plat_nand_probe(struct platform_device *pdev)if (pdata->ctrl.dev_ready) data->chip.dev_ready = plat_nand_dev_ready; -if (pdata->ctrl.select_chip) - data->chip.select_chip = plat_nand_select_chip; - + data->chip.select_chip = pdata->ctrl.select_chip; data->chip.write_buf = pdata->ctrl.write_buf; data->chip.read_buf = pdata->ctrl.read_buf; data->chip.chip_delay = pdata->chip.chip_delay;
drivers/mtd/nand/raw/qcom_nandc.c +1 -2
@@ -2324,9 +2324,8 @@ static void qcom_nandc_write_buf(struct nand_chip *chip, const uint8_t *buf, }/* we support only one external chip for now */ -static void qcom_nandc_select_chip (struct mtd_info *mtd,int chipnr) +static void qcom_nandc_select_chip (struct nand_chip *chip,int chipnr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);if (chipnr <=0 )
drivers/mtd/nand/raw/r852.c +2 -3
@@ -1026,7 +1026,6 @@ static int r852_suspend(struct device *device)static int r852_resume (struct device *device) {struct r852_device *dev =pci_get_drvdata (to_pci_dev (device)); -struct mtd_info *mtd =nand_to_mtd (dev->chip);r852_disable_irqs (dev);r852_card_update_present (dev);
@@ -1046,9 +1045,9 @@ static int r852_resume(struct device *device)/* Otherwise, initialize the card */ if (dev->card_registred) {r852_engine_enable (dev); - dev->chip->select_chip (mtd,0 ); + dev->chip->select_chip (dev->chip,0 );nand_reset_op (dev->chip); - dev->chip->select_chip (mtd,-1 ); + dev->chip->select_chip (dev->chip,-1 ); }/* Program card detection IRQ */
drivers/mtd/nand/raw/s3c2410.c +2 -3
@@ -404,7 +404,7 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info)/** * s3c2410_nand_select_chip - select the given nand chip -* @mtd: The MTD instance for this chip. +* @this: NAND chip object. * @chip: The chip number. * * This is called by the MTD layer to either select a given chip for the
@@ -415,11 +415,10 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info)* platform specific selection code is called to route nFCE to the specific * chip. */ -static void s3c2410_nand_select_chip (struct mtd_info *mtd,int chip) +static void s3c2410_nand_select_chip (struct nand_chip *this,int chip) {struct s3c2410_nand_info *info;struct s3c2410_nand_mtd *nmtd; -struct nand_chip *this =mtd_to_nand (mtd);unsigned long cur; nmtd =nand_get_controller_data (this);
drivers/mtd/nand/raw/sh_flctl.c +2 -2
@@ -926,9 +926,9 @@ static void flctl_cmdfunc(struct mtd_info *mtd, unsigned int command,return ; } -static void flctl_select_chip (struct mtd_info *mtd,int chipnr) +static void flctl_select_chip (struct nand_chip *chip,int chipnr) { -struct sh_flctl *flctl =mtd_to_flctl (mtd); +struct sh_flctl *flctl =mtd_to_flctl (nand_to_mtd (chip));int ret;switch (chipnr) {
drivers/mtd/nand/raw/sunxi_nand.c +2 -2
@@ -420,9 +420,9 @@ static int sunxi_nfc_dev_ready(struct mtd_info *mtd)return !!(readl (nfc->regs +NFC_REG_ST ) & mask); } -static void sunxi_nfc_select_chip (struct mtd_info *mtd,int chip) +static void sunxi_nfc_select_chip (struct nand_chip *nand,int chip) { -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);struct sunxi_nand_chip_sel *sel;
drivers/mtd/nand/raw/tango_nand.c +1 -2
@@ -156,9 +156,8 @@ static void tango_write_buf(struct nand_chip *chip, const u8 *buf, int len)iowrite8_rep (tchip->base +PBUS_DATA , buf, len); } -static void tango_select_chip (struct mtd_info *mtd,int idx) +static void tango_select_chip (struct nand_chip *chip,int idx) { -struct nand_chip *chip =mtd_to_nand (mtd);struct tango_nfc *nfc =to_tango_nfc (chip->controller);struct tango_chip *tchip =to_tango_chip (chip);
drivers/mtd/nand/raw/tegra_nand.c +1 -2
@@ -462,9 +462,8 @@ static int tegra_nand_exec_op(struct nand_chip *chip, check_only); } -static void tegra_nand_select_chip (struct mtd_info *mtd,int die_nr) +static void tegra_nand_select_chip (struct nand_chip *chip,int die_nr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct tegra_nand_chip *nand =to_tegra_chip (chip);struct tegra_nand_controller *ctrl =to_tegra_ctrl (chip->controller);
drivers/mtd/nand/raw/vf610_nfc.c +4 -4
@@ -498,9 +498,9 @@ static int vf610_nfc_exec_op(struct nand_chip *chip,/* * This function supports Vybrid only (MPC5125 would have full RB and four CS) */ -static void vf610_nfc_select_chip (struct mtd_info *mtd,int chip) +static void vf610_nfc_select_chip (struct nand_chip *chip,int cs) { -struct vf610_nfc *nfc =mtd_to_nfc (mtd); +struct vf610_nfc *nfc =mtd_to_nfc (nand_to_mtd (chip));u32 tmp =vf610_nfc_read (nfc,NFC_ROW_ADDR );/* Vybrid only (MPC5125 would have full RB and four CS) */
@@ -509,9 +509,9 @@ static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) tmp &= ~(ROW_ADDR_CHIP_SEL_RB_MASK |ROW_ADDR_CHIP_SEL_MASK ); -if (chip >=0 ) { +if (cs >=0 ) { tmp |=1 <<ROW_ADDR_CHIP_SEL_RB_SHIFT ; - tmp |=BIT (chip) <<ROW_ADDR_CHIP_SEL_SHIFT ; + tmp |=BIT (cs) <<ROW_ADDR_CHIP_SEL_SHIFT ; }vf610_nfc_write (nfc,NFC_ROW_ADDR , tmp);
drivers/mtd/nand/raw/xway_nand.c +1 -2
@@ -85,9 +85,8 @@ static void xway_writeb(struct mtd_info *mtd, int op, u8 value)writeb (value, data->nandaddr + op); } -static void xway_select_chip (struct mtd_info *mtd,int select) +static void xway_select_chip (struct nand_chip *chip,int select) { -struct nand_chip *chip =mtd_to_nand (mtd);struct xway_nand_data *data =nand_get_controller_data (chip);switch (select) {
drivers/staging/mt29f_spinand/mt29f_spinand.c +1 -1
@@ -681,7 +681,7 @@ static int spinand_read_page_hwecc(struct nand_chip *chip, u8 *buf, }#endif -static void spinand_select_chip (struct mtd_info *mtd,int dev) +static void spinand_select_chip (struct nand_chip *chip,int dev) { }
include/linux/mtd/rawnand.h +1 -1
@@ -1287,7 +1287,7 @@ struct nand_chip {void (*write_byte)(struct nand_chip *chip,uint8_t byte);void (*write_buf)(struct nand_chip *chip,const uint8_t *buf,int len);void (*read_buf)(struct nand_chip *chip,uint8_t *buf,int len); -void (*select_chip)(struct mtd_info *mtd,int chip); +void (*select_chip)(struct nand_chip *chip,int cs);int (*block_bad)(struct mtd_info *mtd,loff_t ofs);int (*block_markbad)(struct mtd_info *mtd,loff_t ofs);void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl);
Signature · 1 line
2.14.1
PATCH v2 13/23 mtd: rawnand: Pass a nand_chip object to chip->block_xxx() hooks
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle all chip->block_xxx() hooks at once.
--- drivers/mtd/nand/raw/cafe_nand.c | 2 +- drivers/mtd/nand/raw/diskonchip.c | 2 +- drivers/mtd/nand/raw/docg4.c | 6 +++--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 6 +++--- drivers/mtd/nand/raw/nand_base.c | 16 ++++++++-------- drivers/mtd/nand/raw/nand_bbt.c | 3 +-- drivers/mtd/nand/raw/qcom_nandc.c | 7 +++---- drivers/mtd/nand/raw/sm_common.c | 3 ++- include/linux/mtd/rawnand.h | 4 ++-- 9 files changed, 24 insertions(+), 25 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +1 -1
@@ -546,7 +546,7 @@ static int cafe_nand_write_page_lowlevel(struct nand_chip *chip,return nand_prog_page_end_op (chip); } -static int cafe_nand_block_bad (struct mtd_info *mtd,loff_t ofs) +static int cafe_nand_block_bad (struct nand_chip *chip,loff_t ofs) {return 0 ; }
drivers/mtd/nand/raw/diskonchip.c +1 -1
@@ -777,7 +777,7 @@ static int doc200x_dev_ready(struct mtd_info *mtd) } } -static int doc200x_block_bad (struct mtd_info *mtd,loff_t ofs) +static int doc200x_block_bad (struct nand_chip *this,loff_t ofs) {/* This is our last resort if we couldn't find or create a BBT. Just pretend all blocks are good. */
drivers/mtd/nand/raw/docg4.c +3 -3
@@ -1102,7 +1102,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)return 0 ; } -static int docg4_block_markbad (struct mtd_info *mtd,loff_t ofs) +static int docg4_block_markbad (struct nand_chip *nand,loff_t ofs) {/* * Mark a block as bad. Bad blocks are marked in the oob area of the
@@ -1115,7 +1115,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)int ret, i;uint8_t *buf; -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct docg4_priv *doc =nand_get_controller_data (nand);struct nand_bbt_descr *bbtd = nand->badblock_pattern;int page = (int )(ofs >> nand->page_shift);
@@ -1147,7 +1147,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)return ret; } -static int docg4_block_neverbad (struct mtd_info *mtd,loff_t ofs) +static int docg4_block_neverbad (struct nand_chip *nand,loff_t ofs) {/* only called when module_param ignore_badblocks is set */ return 0 ;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +3 -3
@@ -1542,9 +1542,9 @@ static int gpmi_ecc_write_oob_raw(struct nand_chip *chip, int page)return gpmi_ecc_write_page_raw (chip,NULL ,1 , page); } -static int gpmi_block_markbad (struct mtd_info *mtd,loff_t ofs) +static int gpmi_block_markbad (struct nand_chip *chip,loff_t ofs) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct gpmi_nand_data *this =nand_get_controller_data (chip);int ret =0 ;uint8_t *block_mark;
@@ -1776,7 +1776,7 @@ static int mx23_boot_init(struct gpmi_nand_data *this)*/ if (block_mark !=0xff ) {dev_dbg (dev,"Transcribing mark in block %u\n" , block); - ret = chip->block_markbad (mtd, byte); + ret = chip->block_markbad (chip, byte);if (ret) dev_err(dev, "Failed to mark block bad with ret %d\n",
drivers/mtd/nand/raw/nand_base.c +8 -8
@@ -398,15 +398,15 @@ static void nand_read_buf16(struct nand_chip *chip, uint8_t *buf, int len)/** * nand_block_bad - [DEFAULT] Read bad block marker from the chip -* @mtd: MTD device structure +* @chip: NAND chip object * @ofs: offset from device start * * Check, if the block is bad. */ -static int nand_block_bad (struct mtd_info *mtd,loff_t ofs) +static int nand_block_bad (struct nand_chip *chip,loff_t ofs) { +struct mtd_info *mtd =nand_to_mtd (chip);int page, page_end, res; -struct nand_chip *chip =mtd_to_nand (mtd);u8 bad;if (chip->bbt_options &NAND_BBT_SCANLASTPAGE )
@@ -435,16 +435,16 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)/** * nand_default_block_markbad - [DEFAULT] mark a block bad via bad block marker -* @mtd: MTD device structure +* @chip: NAND chip object * @ofs: offset from device start * * This is the default implementation, which can be overridden by a hardware * specific driver. It provides the details for writing a bad block marker to a * block. */ -static int nand_default_block_markbad (struct mtd_info *mtd,loff_t ofs) +static int nand_default_block_markbad (struct nand_chip *chip,loff_t ofs) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct mtd_oob_ops ops;uint8_t buf[2 ] = {0 ,0 };int ret =0 , res, i =0 ;
@@ -510,7 +510,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)/* Write bad block marker to OOB */ nand_get_device (mtd,FL_WRITING ); - ret = chip->block_markbad (mtd, ofs); + ret = chip->block_markbad (chip, ofs);nand_release_device (mtd); }
@@ -583,7 +583,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt)struct nand_chip *chip =mtd_to_nand (mtd);if (!chip->bbt) -return chip->block_bad (mtd, ofs); +return chip->block_bad (chip, ofs);/* Return info from the table */ return nand_isbad_bbt (mtd, ofs, allowbbt);
drivers/mtd/nand/raw/nand_bbt.c +1 -2
@@ -683,14 +683,13 @@ static void mark_bbt_block_bad(struct nand_chip *this,struct nand_bbt_descr *td, int chip, int block) { - struct mtd_info *mtd = nand_to_mtd(this); loff_t to;int res;bbt_mark_entry (this, block,BBT_BLOCK_WORN ); to = (loff_t )block << this->bbt_erase_shift; - res = this->block_markbad (mtd, to); + res = this->block_markbad (this, to);if (res)pr_warn ("nand_bbt: error %d while marking block %d bad\n" , res, block);
drivers/mtd/nand/raw/qcom_nandc.c +3 -4
@@ -2196,9 +2196,9 @@ static int qcom_nandc_write_oob(struct nand_chip *chip, int page)return nand_prog_page_end_op (chip); } -static int qcom_nandc_block_bad (struct mtd_info *mtd,loff_t ofs) +static int qcom_nandc_block_bad (struct nand_chip *chip,loff_t ofs) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;
@@ -2234,9 +2234,8 @@ static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs)return bad; } -static int qcom_nandc_block_markbad (struct mtd_info *mtd,loff_t ofs) +static int qcom_nandc_block_markbad (struct nand_chip *chip,loff_t ofs) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;
drivers/mtd/nand/raw/sm_common.c +2 -1
@@ -99,8 +99,9 @@ static const struct mtd_ooblayout_ops oob_sm_small_ops = { .free = oob_sm_small_ooblayout_free, }; -static int sm_block_markbad (struct mtd_info *mtd,loff_t ofs) +static int sm_block_markbad (struct nand_chip *chip,loff_t ofs) { +struct mtd_info *mtd =nand_to_mtd (chip);struct mtd_oob_ops ops;struct sm_oob oob;int ret;
include/linux/mtd/rawnand.h +2 -2
@@ -1288,8 +1288,8 @@ struct nand_chip {void (*write_buf)(struct nand_chip *chip,const uint8_t *buf,int len);void (*read_buf)(struct nand_chip *chip,uint8_t *buf,int len);void (*select_chip)(struct nand_chip *chip,int cs); -int (*block_bad)(struct mtd_info *mtd,loff_t ofs); -int (*block_markbad)(struct mtd_info *mtd,loff_t ofs); +int (*block_bad)(struct nand_chip *chip,loff_t ofs); +int (*block_markbad)(struct nand_chip *chip,loff_t ofs);void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl);int (*dev_ready)(struct mtd_info *mtd); void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column,
Signature · 1 line
2.14.1
PATCH v2 14/23 mtd: rawnand: Pass a nand_chip object to chip->cmd_ctrl()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->cmd_ctrl() hook.
--- drivers/mtd/nand/raw/ams-delta.c | 4 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 6 +-- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 7 ++-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 +- drivers/mtd/nand/raw/cmx270_nand.c | 3 +- drivers/mtd/nand/raw/cs553x_nand.c | 3 +- drivers/mtd/nand/raw/davinci_nand.c | 5 +-- drivers/mtd/nand/raw/denali.c | 4 +- drivers/mtd/nand/raw/diskonchip.c | 22 +++++------ drivers/mtd/nand/raw/fsl_upm.c | 10 ++--- drivers/mtd/nand/raw/gpio.c | 5 ++- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 3 +- drivers/mtd/nand/raw/jz4740_nand.c | 6 +-- drivers/mtd/nand/raw/jz4780_nand.c | 4 +- drivers/mtd/nand/raw/lpc32xx_mlc.c | 3 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 5 +-- drivers/mtd/nand/raw/mtk_nand.c | 5 ++- drivers/mtd/nand/raw/nand_base.c | 47 ++++++++++++------------ drivers/mtd/nand/raw/nandsim.c | 3 +- drivers/mtd/nand/raw/ndfc.c | 3 +- drivers/mtd/nand/raw/omap2.c | 6 +-- drivers/mtd/nand/raw/orion_nand.c | 4 +- drivers/mtd/nand/raw/oxnas_nand.c | 3 +- drivers/mtd/nand/raw/pasemi_nand.c | 4 +- drivers/mtd/nand/raw/plat_nand.c | 11 +----- drivers/mtd/nand/raw/r852.c | 4 +- drivers/mtd/nand/raw/s3c2410.c | 6 ++- drivers/mtd/nand/raw/sharpsl.c | 5 +-- drivers/mtd/nand/raw/socrates_nand.c | 5 +-- drivers/mtd/nand/raw/sunxi_nand.c | 3 +- drivers/mtd/nand/raw/tango_nand.c | 4 +- drivers/mtd/nand/raw/tmio_nand.c | 7 ++-- drivers/mtd/nand/raw/txx9ndfmc.c | 3 +- drivers/mtd/nand/raw/xway_nand.c | 4 +- include/linux/mtd/rawnand.h | 2 +- 35 files changed, 98 insertions(+), 125 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +2 -2
@@ -113,7 +113,7 @@ static void ams_delta_read_buf(struct nand_chip *this, u_char *buf, int len)* NAND_CLE: bit 1 -> bit 7 * NAND_ALE: bit 2 -> bit 6 */ -static void ams_delta_hwcontrol (struct mtd_info *mtd,int cmd, +static void ams_delta_hwcontrol (struct nand_chip *this,int cmd,unsigned int ctrl) {
@@ -127,7 +127,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, }if (cmd !=NAND_CMD_NONE ) -ams_delta_write_byte (mtd_to_nand (mtd), cmd); +ams_delta_write_byte (this, cmd); }static int ams_delta_nand_ready (struct mtd_info *mtd)
drivers/mtd/nand/raw/atmel/nand-controller.c +2 -4
@@ -594,10 +594,9 @@ static int atmel_nfc_exec_op(struct atmel_hsmc_nand_controller *nc, bool poll)return ret; } -static void atmel_hsmc_nand_cmd_ctrl (struct mtd_info *mtd,int dat, +static void atmel_hsmc_nand_cmd_ctrl (struct nand_chip *chip,int dat,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_hsmc_nand_controller *nc;
@@ -621,10 +620,9 @@ static void atmel_hsmc_nand_cmd_ctrl(struct mtd_info *mtd, int dat, } } -static void atmel_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void atmel_nand_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_nand_controller *nc;
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +3 -4
@@ -170,10 +170,9 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd,* NAND chip ops **************************************************/ -static void bcm47xxnflash_ops_bcm4706_cmd_ctrl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void bcm47xxnflash_ops_bcm4706_cmd_ctrl (struct nand_chip *nand_chip, +int cmd,unsigned int ctrl) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);u32 code =0 ;
@@ -229,7 +228,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,switch (command) {case NAND_CMD_RESET : - nand_chip->cmd_ctrl (mtd, command,NAND_CTRL_CLE ); + nand_chip->cmd_ctrl (nand_chip, command,NAND_CTRL_CLE );ndelay (100 );nand_wait_ready (nand_chip);
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -2
@@ -1231,8 +1231,8 @@ static void brcmnand_send_cmd(struct brcmnand_host *host, int cmd)* NAND MTD API: read/program/erase ***********************************************************************/ -static void brcmnand_cmd_ctrl (struct mtd_info *mtd,int dat, -unsigned int ctrl) +static void brcmnand_cmd_ctrl (struct nand_chip *chip,int dat, +unsigned int ctrl) {/* intentionally left blank */ }
drivers/mtd/nand/raw/cmx270_nand.c +1 -2
@@ -86,10 +86,9 @@ static void nand_cs_off(void)/* * hardware specific access to control-lines */ -static void cmx270_hwcontrol (struct mtd_info *mtd,int dat, +static void cmx270_hwcontrol (struct nand_chip *this,int dat,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);unsigned int nandaddr = (unsigned int )this->IO_ADDR_W;dsb ();
drivers/mtd/nand/raw/cs553x_nand.c +1 -2
@@ -129,10 +129,9 @@ static void cs553x_write_byte(struct nand_chip *this, u_char byte)writeb (byte, this->IO_ADDR_W +0x801 ); } -static void cs553x_hwcontrol (struct mtd_info *mtd,int cmd, +static void cs553x_hwcontrol (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *mmio_base = this->IO_ADDR_R;if (ctrl &NAND_CTRL_CHANGE ) {unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^0x01 ;
drivers/mtd/nand/raw/davinci_nand.c +2 -3
@@ -97,12 +97,11 @@ static inline void davinci_nand_writel(struct davinci_nand_info *info,* Access to hardware control lines: ALE, CLE, secondary chipselect. */ -static void nand_davinci_hwcontrol (struct mtd_info *mtd,int cmd, +static void nand_davinci_hwcontrol (struct nand_chip *nand,int cmd,unsigned int ctrl) { -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (nand));void __iomem *addr = info->current_cs; -struct nand_chip *nand =mtd_to_nand (mtd);/* Did the control lines change? */ if (ctrl &NAND_CTRL_CHANGE ) {
drivers/mtd/nand/raw/denali.c +2 -2
@@ -274,9 +274,9 @@ static void denali_write_byte(struct nand_chip *chip, uint8_t byte)denali_write_buf (chip, &byte,1 ); } -static void denali_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl) +static void denali_cmd_ctrl (struct nand_chip *chip,int dat,unsigned int ctrl) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));uint32_t type;if (ctrl &NAND_CLE )
drivers/mtd/nand/raw/diskonchip.c +10 -12
@@ -83,7 +83,7 @@ static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 };#define DoC_is_Millennium (doc) ((doc)->ChipID == DOC_ChipID_DocMil)#define DoC_is_2000 (doc) ((doc)->ChipID == DOC_ChipID_Doc2k) -static void doc200x_hwcontrol (struct mtd_info *mtd,int cmd, +static void doc200x_hwcontrol (struct nand_chip *this,int cmd,unsigned int bitmask);static void doc200x_select_chip (struct nand_chip *this,int chip);
@@ -372,10 +372,10 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)uint16_t ret;doc200x_select_chip (this, nr); -doc200x_hwcontrol (mtd,NAND_CMD_READID , +doc200x_hwcontrol (this,NAND_CMD_READID ,NAND_CTRL_CLE |NAND_CTRL_CHANGE ); -doc200x_hwcontrol (mtd,0 ,NAND_CTRL_ALE |NAND_CTRL_CHANGE ); -doc200x_hwcontrol (mtd,NAND_CMD_NONE ,NAND_NCE |NAND_CTRL_CHANGE ); +doc200x_hwcontrol (this,0 ,NAND_CTRL_ALE |NAND_CTRL_CHANGE ); +doc200x_hwcontrol (this,NAND_CMD_NONE ,NAND_NCE |NAND_CTRL_CHANGE );/* We can't use dev_ready here, but at least we wait for the * command to complete
@@ -393,10 +393,10 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) } ident;void __iomem *docptr = doc->virtadr; -doc200x_hwcontrol (mtd,NAND_CMD_READID , +doc200x_hwcontrol (this,NAND_CMD_READID ,NAND_CTRL_CLE |NAND_CTRL_CHANGE ); -doc200x_hwcontrol (mtd,0 ,NAND_CTRL_ALE |NAND_CTRL_CHANGE ); -doc200x_hwcontrol (mtd,NAND_CMD_NONE , +doc200x_hwcontrol (this,0 ,NAND_CTRL_ALE |NAND_CTRL_CHANGE ); +doc200x_hwcontrol (this,NAND_CMD_NONE ,NAND_NCE |NAND_CTRL_CHANGE );udelay (50 );
@@ -587,7 +587,6 @@ static void doc2001plus_select_chip(struct nand_chip *this, int chip)static void doc200x_select_chip (struct nand_chip *this,int chip) { -struct mtd_info *mtd =nand_to_mtd (this);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;int floor =0 ;
@@ -602,12 +601,12 @@ static void doc200x_select_chip(struct nand_chip *this, int chip) chip -= (floor * doc->chips_per_floor);/* 11.4.4 -- deassert CE before changing chip */ -doc200x_hwcontrol (mtd,NAND_CMD_NONE ,0 |NAND_CTRL_CHANGE ); +doc200x_hwcontrol (this,NAND_CMD_NONE ,0 |NAND_CTRL_CHANGE );WriteDOC (floor, docptr, FloorSelect);WriteDOC (chip, docptr, CDSNDeviceSelect); -doc200x_hwcontrol (mtd,NAND_CMD_NONE ,NAND_NCE |NAND_CTRL_CHANGE ); +doc200x_hwcontrol (this,NAND_CMD_NONE ,NAND_NCE |NAND_CTRL_CHANGE ); doc->curchip = chip; doc->curfloor = floor;
@@ -615,10 +614,9 @@ static void doc200x_select_chip(struct nand_chip *this, int chip)#define CDSN_CTRL_MSK (CDSN_CTRL_CE | CDSN_CTRL_CLE | CDSN_CTRL_ALE) -static void doc200x_hwcontrol (struct mtd_info *mtd,int cmd, +static void doc200x_hwcontrol (struct nand_chip *this,int cmd,unsigned int ctrl) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
drivers/mtd/nand/raw/fsl_upm.c +4 -6
@@ -78,10 +78,9 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun) } } -static void fun_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void fun_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd); -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));u32 mar;if (!(ctrl & fun->last_ctrl)) {
@@ -110,11 +109,10 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)static void fun_select_chip (struct nand_chip *chip,int mchip_nr) { -struct mtd_info *mtd =nand_to_mtd (chip); -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));if (mchip_nr ==-1 ) { - chip->cmd_ctrl (mtd,NAND_CMD_NONE ,0 |NAND_CTRL_CHANGE ); + chip->cmd_ctrl (chip,NAND_CMD_NONE ,0 |NAND_CTRL_CHANGE ); }else if (mchip_nr >=0 && mchip_nr <NAND_MAX_CHIPS ) { fun->mchip_number = mchip_nr; chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
drivers/mtd/nand/raw/gpio.c +3 -2
@@ -73,9 +73,10 @@ static void gpio_nand_dosync(struct gpiomtd *gpiomtd)static inline void gpio_nand_dosync (struct gpiomtd *gpiomtd) {}#endif -static void gpio_nand_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void gpio_nand_cmd_ctrl (struct nand_chip *chip,int cmd, +unsigned int ctrl) { -struct gpiomtd *gpiomtd =gpio_nand_getpriv (mtd); +struct gpiomtd *gpiomtd =gpio_nand_getpriv (nand_to_mtd (chip));gpio_nand_dosync (gpiomtd);
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -2
@@ -783,9 +783,8 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this)return -ENOMEM ; } -static void gpmi_cmd_ctrl (struct mtd_info *mtd,int data,unsigned int ctrl) +static void gpmi_cmd_ctrl (struct nand_chip *chip,int data,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);int ret;
drivers/mtd/nand/raw/jz4740_nand.c +3 -3
@@ -99,10 +99,10 @@ static void jz_nand_select_chip(struct nand_chip *chip, int chipnr) nand->selected_bank = banknr; } -static void jz_nand_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl) +static void jz_nand_cmd_ctrl (struct nand_chip *chip,int dat, +unsigned int ctrl) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));uint32_t reg;void __iomem *bank_base = nand->bank_base[nand->selected_bank];
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -86,10 +86,10 @@ static void jz4780_nand_select_chip(struct nand_chip *chip, int chipnr) nfc->selected = chipnr; } -static void jz4780_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void jz4780_nand_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip));struct jz4780_nand_controller *nfc =to_jz4780_nand_controller (nand->chip.controller);struct jz4780_nand_cs *cs;
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -2
@@ -286,10 +286,9 @@ static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)/* * Hardware specific access to control lines */ -static void lpc32xx_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void lpc32xx_nand_cmd_ctrl (struct nand_chip *nand_chip,int cmd,unsigned int ctrl) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (nand_chip);if (cmd !=NAND_CMD_NONE ) {
drivers/mtd/nand/raw/lpc32xx_slc.c +2 -3
@@ -278,11 +278,10 @@ static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)/* * Hardware specific access to control lines */ -static void lpc32xx_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void lpc32xx_nand_cmd_ctrl (struct nand_chip *chip,int cmd, +unsigned int ctrl) {uint32_t tmp; -struct nand_chip *chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);/* Does CE state need to be changed? */
drivers/mtd/nand/raw/mtk_nand.c +3 -2
@@ -412,9 +412,10 @@ static int mtk_nfc_dev_ready(struct mtd_info *mtd)return 1 ; } -static void mtk_nfc_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl) +static void mtk_nfc_cmd_ctrl (struct nand_chip *chip,int dat, +unsigned int ctrl) { -struct mtk_nfc *nfc =nand_get_controller_data (mtd_to_nand (mtd)); +struct mtk_nfc *nfc =nand_get_controller_data (chip);if (ctrl &NAND_ALE ) {mtk_nfc_send_address (nfc, dat);
drivers/mtd/nand/raw/nand_base.c +23 -24
125 lines not on this page · raw message
drivers/mtd/nand/raw/nandsim.c +1 -2
@@ -2087,9 +2087,8 @@ static void ns_nand_write_byte(struct nand_chip *chip, u_char byte)return ; } -static void ns_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int bitmask) +static void ns_hwcontrol (struct nand_chip *chip,int cmd,unsigned int bitmask) { -struct nand_chip *chip =mtd_to_nand (mtd);struct nandsim *ns =nand_get_controller_data (chip); ns->lines.cle = bitmask &NAND_CLE ?1 :0 ;
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -58,9 +58,8 @@ static void ndfc_select_chip(struct nand_chip *nchip, int chip)out_be32 (ndfc->ndfcbase +NDFC_CCR , ccr); } -static void ndfc_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void ndfc_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip);if (cmd ==NAND_CMD_NONE )
drivers/mtd/nand/raw/omap2.c +3 -3
@@ -240,7 +240,7 @@ static int omap_prefetch_reset(int cs, struct omap_nand_info *info)/** * omap_hwcontrol - hardware specific access to control-lines -* @mtd: MTD device structure +* @chip: NAND chip object * @cmd: command to device * @ctrl: * NAND_NCE: bit 0 -> don't care
@@ -249,9 +249,9 @@ static int omap_prefetch_reset(int cs, struct omap_nand_info *info)* * NOTE: boards may use different bits for these!! */ -static void omap_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void omap_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));if (cmd !=NAND_CMD_NONE ) {if (ctrl &NAND_CLE )
drivers/mtd/nand/raw/orion_nand.c +2 -2
@@ -26,9 +26,9 @@ struct orion_nand_info {struct clk *clk; }; -static void orion_nand_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void orion_nand_cmd_ctrl (struct nand_chip *nc,int cmd, +unsigned int ctrl) { -struct nand_chip *nc =mtd_to_nand (mtd);struct orion_nand_data *board =nand_get_controller_data (nc);u32 offs;
drivers/mtd/nand/raw/oxnas_nand.c +1 -2
@@ -61,10 +61,9 @@ static void oxnas_nand_write_buf(struct nand_chip *chip, const u8 *buf, }/* Single CS command control */ -static void oxnas_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void oxnas_nand_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct oxnas_nand_ctrl *oxnas =nand_get_controller_data (chip);if (ctrl &NAND_CLE )
drivers/mtd/nand/raw/pasemi_nand.c +1 -3
@@ -64,11 +64,9 @@ static void pasemi_write_buf(struct nand_chip *chip, const u_char *buf,memcpy_toio (chip->IO_ADDR_R, buf, len); } -static void pasemi_hwcontrol (struct mtd_info *mtd,int cmd, +static void pasemi_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd); -if (cmd ==NAND_CMD_NONE )return ;
drivers/mtd/nand/raw/plat_nand.c +1 -10
@@ -23,13 +23,6 @@ struct plat_nand_data {void __iomem *io_base; }; -static void plat_nand_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl) -{ -struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent); - - pdata->ctrl.cmd_ctrl (mtd_to_nand (mtd), dat, ctrl); -} -static int plat_nand_dev_ready (struct mtd_info *mtd) {struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent);
@@ -76,9 +69,7 @@ static int plat_nand_probe(struct platform_device *pdev) data->chip.IO_ADDR_R = data->io_base; data->chip.IO_ADDR_W = data->io_base; - -if (pdata->ctrl.cmd_ctrl) - data->chip.cmd_ctrl = plat_nand_cmd_ctrl; + data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl;if (pdata->ctrl.dev_ready) data->chip.dev_ready = plat_nand_dev_ready;
drivers/mtd/nand/raw/r852.c +2 -2
@@ -317,9 +317,9 @@ static uint8_t r852_read_byte(struct nand_chip *chip)/* * Control several chip lines & send commands */ -static void r852_cmdctl (struct mtd_info *mtd,int dat,unsigned int ctrl) +static void r852_cmdctl (struct nand_chip *chip,int dat,unsigned int ctrl) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));if (dev->card_unstable)return ;
drivers/mtd/nand/raw/s3c2410.c +4 -2
@@ -456,9 +456,10 @@ static void s3c2410_nand_select_chip(struct nand_chip *this, int chip)* Issue command and address cycles to the chip */ -static void s3c2410_nand_hwcontrol (struct mtd_info *mtd,int cmd, +static void s3c2410_nand_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);if (cmd ==NAND_CMD_NONE )
@@ -472,9 +473,10 @@ static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd,/* command and control functions */ -static void s3c2440_nand_hwcontrol (struct mtd_info *mtd,int cmd, +static void s3c2440_nand_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);if (cmd ==NAND_CMD_NONE )
drivers/mtd/nand/raw/sharpsl.c +2 -3
@@ -59,11 +59,10 @@ static inline struct sharpsl_nand *mtd_to_sharpsl(struct mtd_info *mtd)* NAND_ALE: bit 2 -> bit 2 * */ -static void sharpsl_nand_hwcontrol (struct mtd_info *mtd,int cmd, +static void sharpsl_nand_hwcontrol (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct sharpsl_nand *sharpsl =mtd_to_sharpsl (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct sharpsl_nand *sharpsl =mtd_to_sharpsl (nand_to_mtd (chip));if (ctrl &NAND_CTRL_CHANGE ) {unsigned char bits = ctrl &0x07 ;
drivers/mtd/nand/raw/socrates_nand.c +2 -3
@@ -87,10 +87,9 @@ static uint8_t socrates_nand_read_byte(struct nand_chip *this)/* * Hardware specific access to control-lines */ -static void socrates_nand_cmd_ctrl (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void socrates_nand_cmd_ctrl (struct nand_chip *nand_chip,int cmd, +unsigned int ctrl) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct socrates_nand_host *host =nand_get_controller_data (nand_chip);uint32_t val;
drivers/mtd/nand/raw/sunxi_nand.c +1 -2
@@ -547,10 +547,9 @@ static uint8_t sunxi_nfc_read_byte(struct nand_chip *nand)return ret; } -static void sunxi_nfc_cmd_ctrl (struct mtd_info *mtd,int dat, +static void sunxi_nfc_cmd_ctrl (struct nand_chip *nand,int dat,unsigned int ctrl) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);int ret;
drivers/mtd/nand/raw/tango_nand.c +2 -2
@@ -116,9 +116,9 @@ struct tango_chip {#define TIMING (t0, t1, t2, t3) ((t0) << 24 | (t1) << 16 | (t2) << 8 | (t3)) -static void tango_cmd_ctrl (struct mtd_info *mtd,int dat,unsigned int ctrl) +static void tango_cmd_ctrl (struct nand_chip *chip,int dat,unsigned int ctrl) { -struct tango_chip *tchip =to_tango_chip (mtd_to_nand (mtd)); +struct tango_chip *tchip =to_tango_chip (chip);if (ctrl &NAND_CLE )writeb_relaxed (dat, tchip->base +PBUS_CMD );
drivers/mtd/nand/raw/tmio_nand.c +3 -4
@@ -126,11 +126,10 @@ static inline struct tmio_nand *mtd_to_tmio(struct mtd_info *mtd)/*--------------------------------------------------------------------------*/ -static void tmio_nand_hwcontrol (struct mtd_info *mtd,int cmd, -unsigned int ctrl) +static void tmio_nand_hwcontrol (struct nand_chip *chip,int cmd, +unsigned int ctrl) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); -struct nand_chip *chip =mtd_to_nand (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));if (ctrl &NAND_CTRL_CHANGE ) {u8 mode;
drivers/mtd/nand/raw/txx9ndfmc.c +1 -2
@@ -131,10 +131,9 @@ static void txx9ndfmc_read_buf(struct nand_chip *chip, uint8_t *buf, int len) *buf++ =__raw_readl (ndfdtr); } -static void txx9ndfmc_cmd_ctrl (struct mtd_info *mtd,int cmd, +static void txx9ndfmc_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { -struct nand_chip *chip =mtd_to_nand (mtd);struct txx9ndfmc_priv *txx9_priv =nand_get_controller_data (chip);struct platform_device *dev = txx9_priv->dev;struct txx9ndfmc_platform_data *plat =dev_get_platdata (&dev->dev);
drivers/mtd/nand/raw/xway_nand.c +3 -1
@@ -105,8 +105,10 @@ static void xway_select_chip(struct nand_chip *chip, int select) } } -static void xway_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) +static void xway_cmd_ctrl (struct nand_chip *chip,int cmd,unsigned int ctrl) { +struct mtd_info *mtd =nand_to_mtd (chip); +if (cmd ==NAND_CMD_NONE )return ;
include/linux/mtd/rawnand.h +1 -1
@@ -1290,7 +1290,7 @@ struct nand_chip {void (*select_chip)(struct nand_chip *chip,int cs);int (*block_bad)(struct nand_chip *chip,loff_t ofs);int (*block_markbad)(struct nand_chip *chip,loff_t ofs); -void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl); +void (*cmd_ctrl)(struct nand_chip *chip,int dat,unsigned int ctrl);int (*dev_ready)(struct mtd_info *mtd);void (*cmdfunc)(struct mtd_info *mtd,unsigned command,int column,int page_addr);
Signature · 1 line
2.14.1
PATCH v2 15/23 mtd: rawnand: Pass a nand_chip object to chip->dev_ready()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->dev_ready() hook.
--- drivers/mtd/nand/raw/ams-delta.c | 2 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 6 ++---- drivers/mtd/nand/raw/au1550nd.c | 6 +++--- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 3 +-- drivers/mtd/nand/raw/cafe_nand.c | 3 +-- drivers/mtd/nand/raw/cmx270_nand.c | 2 +- drivers/mtd/nand/raw/cs553x_nand.c | 3 +-- drivers/mtd/nand/raw/davinci_nand.c | 4 ++-- drivers/mtd/nand/raw/denali.c | 4 ++-- drivers/mtd/nand/raw/diskonchip.c | 5 ++--- drivers/mtd/nand/raw/fsl_upm.c | 6 +++--- drivers/mtd/nand/raw/gpio.c | 4 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 3 +-- drivers/mtd/nand/raw/jz4740_nand.c | 4 ++-- drivers/mtd/nand/raw/jz4780_nand.c | 4 ++-- drivers/mtd/nand/raw/lpc32xx_mlc.c | 3 +-- drivers/mtd/nand/raw/lpc32xx_slc.c | 3 +-- drivers/mtd/nand/raw/mpc5121_nfc.c | 2 +- drivers/mtd/nand/raw/mtk_nand.c | 4 ++-- drivers/mtd/nand/raw/mxc_nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 10 +++++----- drivers/mtd/nand/raw/nandsim.c | 2 +- drivers/mtd/nand/raw/ndfc.c | 3 +-- drivers/mtd/nand/raw/nuc900_nand.c | 6 +++--- drivers/mtd/nand/raw/omap2.c | 4 ++-- drivers/mtd/nand/raw/pasemi_nand.c | 2 +- drivers/mtd/nand/raw/plat_nand.c | 12 +----------- drivers/mtd/nand/raw/r852.c | 6 +++--- drivers/mtd/nand/raw/s3c2410.c | 9 ++++++--- drivers/mtd/nand/raw/sharpsl.c | 4 ++-- drivers/mtd/nand/raw/socrates_nand.c | 3 +-- drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- drivers/mtd/nand/raw/tango_nand.c | 3 +-- drivers/mtd/nand/raw/tmio_nand.c | 8 ++++---- drivers/mtd/nand/raw/txx9ndfmc.c | 4 ++-- drivers/mtd/nand/raw/xway_nand.c | 2 +- include/linux/mtd/rawnand.h | 2 +- 37 files changed, 68 insertions(+), 88 deletions(-)
drivers/mtd/nand/raw/ams-delta.c +1 -1
@@ -130,7 +130,7 @@ static void ams_delta_hwcontrol(struct nand_chip *this, int cmd,ams_delta_write_byte (this, cmd); } -static int ams_delta_nand_ready (struct mtd_info *mtd) +static int ams_delta_nand_ready (struct nand_chip *this) {return gpio_get_value (AMS_DELTA_GPIO_PIN_NAND_RB ); }
drivers/mtd/nand/raw/atmel/nand-controller.c +2 -4
@@ -475,9 +475,8 @@ static void atmel_nand_write_buf(struct nand_chip *chip, const u8 *buf, int len)iowrite8_rep (nand->activecs->io.virt, buf, len); } -static int atmel_nand_dev_ready (struct mtd_info *mtd) +static int atmel_nand_dev_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);return gpiod_get_value (nand->activecs->rb.gpio);
@@ -499,9 +498,8 @@ static void atmel_nand_select_chip(struct nand_chip *chip, int cs) chip->dev_ready = atmel_nand_dev_ready; } -static int atmel_hsmc_nand_dev_ready (struct mtd_info *mtd) +static int atmel_hsmc_nand_dev_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct atmel_nand *nand =to_atmel_nand (chip);struct atmel_hsmc_nand_controller *nc;u32 status;
drivers/mtd/nand/raw/au1550nd.c +3 -3
@@ -213,7 +213,7 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)wmb ();/* Drain the writebuffer */ } -int au1550_device_ready (struct mtd_info *mtd) +int au1550_device_ready (struct nand_chip *this) {return (alchemy_rdsmem (AU1000_MEM_STSTAT ) &0x1 ) ?1 :0 ; }
@@ -341,7 +341,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i/* Apply a short delay always to ensure that we do wait tWB. */ ndelay (100 );/* Wait for a chip to become ready... */ -for (i = this->chip_delay; !this->dev_ready (mtd) && i >0 ; --i) +for (i = this->chip_delay; !this->dev_ready (this) && i >0 ; --i)udelay (1 );/* Release -CE and re-enable interrupts. */
@@ -352,7 +352,7 @@ static void au1550_command(struct mtd_info *mtd, unsigned command, int column, i/* Apply this short delay always to ensure that we do wait tWB. */ ndelay (100 ); -while (!this->dev_ready (mtd)); +while (!this->dev_ready (this)); }static int find_nand_cs (unsigned long nand_base)
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +1 -2
@@ -196,9 +196,8 @@ static void bcm47xxnflash_ops_bcm4706_select_chip(struct nand_chip *chip,return ; } -static int bcm47xxnflash_ops_bcm4706_dev_ready (struct mtd_info *mtd) +static int bcm47xxnflash_ops_bcm4706_dev_ready (struct nand_chip *nand_chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);return !!(bcma_cc_read32 (b47n->cc,BCMA_CC_NFLASH_CTL ) &NCTL_READY );
drivers/mtd/nand/raw/cafe_nand.c +1 -2
@@ -100,9 +100,8 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };#define cafe_readl (cafe, addr) readl((cafe)->mmio + CAFE_##addr)#define cafe_writel (cafe, datum, addr) writel(datum, (cafe)->mmio + CAFE_##addr) -static int cafe_device_ready (struct mtd_info *mtd) +static int cafe_device_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct cafe_priv *cafe =nand_get_controller_data (chip);int result = !!(cafe_readl (cafe,NAND_STATUS ) &0x40000000 );uint32_t irqs =cafe_readl (cafe,NAND_IRQ );
drivers/mtd/nand/raw/cmx270_nand.c +1 -1
@@ -119,7 +119,7 @@ static void cmx270_hwcontrol(struct nand_chip *this, int dat,/* * read device ready pin */ -static int cmx270_device_ready (struct mtd_info *mtd) +static int cmx270_device_ready (struct nand_chip *this) {dsb ();
drivers/mtd/nand/raw/cs553x_nand.c +1 -2
@@ -141,9 +141,8 @@ static void cs553x_hwcontrol(struct nand_chip *this, int cmd,cs553x_write_byte (this, cmd); } -static int cs553x_device_ready (struct mtd_info *mtd) +static int cs553x_device_ready (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);void __iomem *mmio_base = this->IO_ADDR_R;unsigned char foo =readb (mmio_base +MM_NAND_STS );
drivers/mtd/nand/raw/davinci_nand.c +2 -2
@@ -460,9 +460,9 @@ static void nand_davinci_write_buf(struct nand_chip *chip, const uint8_t *buf,* Check hardware register for wait status. Returns 1 if device is ready, * 0 if it is still busy. */ -static int nand_davinci_dev_ready (struct mtd_info *mtd) +static int nand_davinci_dev_ready (struct nand_chip *chip) { -struct davinci_nand_info *info =to_davinci_nand (mtd); +struct davinci_nand_info *info =to_davinci_nand (nand_to_mtd (chip));return davinci_nand_readl (info,NANDFSR_OFFSET ) &BIT (0 ); }
drivers/mtd/nand/raw/denali.c +2 -2
@@ -296,9 +296,9 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl) denali->host_write (denali,DENALI_BANK (denali) | type, dat); } -static int denali_dev_ready (struct mtd_info *mtd) +static int denali_dev_ready (struct nand_chip *chip) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));return !!(denali_check_irq (denali) &INTR__INT_ACT ); }
drivers/mtd/nand/raw/diskonchip.c +2 -3
@@ -739,12 +739,11 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu* any case on any machine. */ ndelay (100 );/* wait until command is processed */ -while (!this->dev_ready (mtd)) ; +while (!this->dev_ready (this)) ; } -static int doc200x_dev_ready (struct mtd_info *mtd) +static int doc200x_dev_ready (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
drivers/mtd/nand/raw/fsl_upm.c +3 -3
@@ -52,9 +52,9 @@ static inline struct fsl_upm_nand *to_fsl_upm_nand(struct mtd_info *mtdinfo) chip); } -static int fun_chip_ready (struct mtd_info *mtd) +static int fun_chip_ready (struct nand_chip *chip) { -struct fsl_upm_nand *fun =to_fsl_upm_nand (mtd); +struct fsl_upm_nand *fun =to_fsl_upm_nand (nand_to_mtd (chip));if (gpio_get_value (fun->rnb_gpio[fun->mchip_number]))return 1 ;
@@ -69,7 +69,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)struct mtd_info *mtd =nand_to_mtd (&fun->chip);int cnt =1000000 ; -while (--cnt && !fun_chip_ready (mtd)) +while (--cnt && !fun_chip_ready (&fun->chip))cpu_relax ();if (!cnt)dev_err (fun->dev,"tired waiting for RNB\n" );
drivers/mtd/nand/raw/gpio.c +2 -2
@@ -94,9 +94,9 @@ static void gpio_nand_cmd_ctrl(struct nand_chip *chip, int cmd,gpio_nand_dosync (gpiomtd); } -static int gpio_nand_devready (struct mtd_info *mtd) +static int gpio_nand_devready (struct nand_chip *chip) { -struct gpiomtd *gpiomtd =gpio_nand_getpriv (mtd); +struct gpiomtd *gpiomtd =gpio_nand_getpriv (nand_to_mtd (chip));return gpiod_get_value (gpiomtd->rdy); }
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -2
@@ -816,9 +816,8 @@ static void gpmi_cmd_ctrl(struct nand_chip *chip, int data, unsigned int ctrl) this->command_length =0 ; } -static int gpmi_dev_ready (struct mtd_info *mtd) +static int gpmi_dev_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct gpmi_nand_data *this =nand_get_controller_data (chip);return gpmi_is_ready (this, this->current_chip);
drivers/mtd/nand/raw/jz4740_nand.c +2 -2
@@ -127,9 +127,9 @@ static void jz_nand_cmd_ctrl(struct nand_chip *chip, int dat,writeb (dat, chip->IO_ADDR_W); } -static int jz_nand_dev_ready (struct mtd_info *mtd) +static int jz_nand_dev_ready (struct nand_chip *chip) { -struct jz_nand *nand =mtd_to_jz_nand (mtd); +struct jz_nand *nand =mtd_to_jz_nand (nand_to_mtd (chip));return gpiod_get_value_cansleep (nand->busy_gpio); }
drivers/mtd/nand/raw/jz4780_nand.c +2 -2
@@ -109,9 +109,9 @@ static void jz4780_nand_cmd_ctrl(struct nand_chip *chip, int cmd,writeb (cmd, cs->base +OFFSET_CMD ); } -static int jz4780_nand_dev_ready (struct mtd_info *mtd) +static int jz4780_nand_dev_ready (struct nand_chip *chip) { -struct jz4780_nand_chip *nand =to_jz4780_nand_chip (mtd); +struct jz4780_nand_chip *nand =to_jz4780_nand_chip (nand_to_mtd (chip));return !gpiod_get_value_cansleep (nand->busy_gpio); }
drivers/mtd/nand/raw/lpc32xx_mlc.c +1 -2
@@ -302,9 +302,8 @@ static void lpc32xx_nand_cmd_ctrl(struct nand_chip *nand_chip, int cmd,/* * Read Device Ready (NAND device _and_ controller ready) */ -static int lpc32xx_nand_device_ready (struct mtd_info *mtd) +static int lpc32xx_nand_device_ready (struct nand_chip *nand_chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (nand_chip); if ((readb(MLC_ISR(host->io_base)) &
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -2
@@ -303,9 +303,8 @@ static void lpc32xx_nand_cmd_ctrl(struct nand_chip *chip, int cmd,/* * Read the Device Ready pin */ -static int lpc32xx_nand_device_ready (struct mtd_info *mtd) +static int lpc32xx_nand_device_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);int rdy =0 ;
drivers/mtd/nand/raw/mpc5121_nfc.c +1 -1
@@ -320,7 +320,7 @@ static void ads5121_select_chip(struct nand_chip *nand, int chip) }/* Read NAND Ready/Busy signal */ -static int mpc5121_nfc_dev_ready (struct mtd_info *mtd) +static int mpc5121_nfc_dev_ready (struct nand_chip *nand) {/* * NFC handles ready/busy signal internally. Therefore, this function
drivers/mtd/nand/raw/mtk_nand.c +2 -2
@@ -402,9 +402,9 @@ static void mtk_nfc_select_chip(struct nand_chip *nand, int chip)nfi_writel (nfc, mtk_nand->sels[chip],NFI_CSEL ); } -static int mtk_nfc_dev_ready (struct mtd_info *mtd) +static int mtk_nfc_dev_ready (struct nand_chip *nand) { -struct mtk_nfc *nfc =nand_get_controller_data (mtd_to_nand (mtd)); +struct mtk_nfc *nfc =nand_get_controller_data (nand);if (nfi_readl (nfc,NFI_STA ) &STA_BUSY )return 0 ;
drivers/mtd/nand/raw/mxc_nand.c +1 -1
@@ -701,7 +701,7 @@ static void mxc_nand_enable_hwecc_v3(struct nand_chip *chip, bool enable) }/* This functions is used by upper layer to checks if device is ready */ -static int mxc_nand_dev_ready (struct mtd_info *mtd) +static int mxc_nand_dev_ready (struct nand_chip *chip) {/* * NFC handles R/B internally. Therefore, this function
drivers/mtd/nand/raw/nand_base.c +5 -5
@@ -603,7 +603,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)/* Wait for the device to get ready */ for (i =0 ; i < timeo; i++) { -if (chip->dev_ready (mtd)) +if (chip->dev_ready (chip))break ;touch_softlockup_watchdog ();mdelay (1 );
@@ -627,12 +627,12 @@ void nand_wait_ready(struct nand_chip *chip)/* Wait until command is processed or timeout occurs */ timeo = jiffies +msecs_to_jiffies (timeo);do { -if (chip->dev_ready (mtd)) +if (chip->dev_ready (chip))return ;cond_resched (); }while (time_before (jiffies, timeo)); -if (!chip->dev_ready (mtd)) +if (!chip->dev_ready (chip))pr_warn_ratelimited ("timeout while waiting for chip to become ready\n" ); }EXPORT_SYMBOL_GPL (nand_wait_ready);
@@ -1068,7 +1068,7 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,int i;for (i =0 ; i < timeo; i++) {if (chip->dev_ready) { -if (chip->dev_ready (mtd)) +if (chip->dev_ready (chip))break ; }else {int ret;
@@ -1116,7 +1116,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) timeo = jiffies +msecs_to_jiffies (timeo); do { if (chip->dev_ready) { - if (chip->dev_ready(mtd)) + if (chip->dev_ready(chip)) break; } else { ret = nand_read_data_op(chip, &status,
drivers/mtd/nand/raw/nandsim.c +1 -1
@@ -2099,7 +2099,7 @@ static void ns_hwcontrol(struct nand_chip *chip, int cmd, unsigned int bitmask)ns_nand_write_byte (chip, cmd); } -static int ns_device_ready (struct mtd_info *mtd) +static int ns_device_ready (struct nand_chip *chip) {NS_DBG ("device_ready\n" );return 1 ;
drivers/mtd/nand/raw/ndfc.c +1 -2
@@ -71,9 +71,8 @@ static void ndfc_hwcontrol(struct nand_chip *chip, int cmd, unsigned int ctrl)writel (cmd &0xFF , ndfc->ndfcbase +NDFC_ALE ); } -static int ndfc_ready (struct mtd_info *mtd) +static int ndfc_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct ndfc_controller *ndfc =nand_get_controller_data (chip);return in_be32 (ndfc->ndfcbase +NDFC_STAT ) &NDFC_STAT_IS_READY ;
drivers/mtd/nand/raw/nuc900_nand.c +3 -3
@@ -120,9 +120,9 @@ static int nuc900_check_rb(struct nuc900_nand *nand)return val; } -static int nuc900_nand_devready (struct mtd_info *mtd) +static int nuc900_nand_devready (struct nand_chip *chip) { -struct nuc900_nand *nand =mtd_to_nuc900 (mtd); +struct nuc900_nand *nand =mtd_to_nuc900 (nand_to_mtd (chip));int ready; ready = (nuc900_check_rb (nand)) ?1 :0 ;
@@ -205,7 +205,7 @@ static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command,* any case on any machine. */ ndelay (100 ); -while (!chip->dev_ready (mtd)) +while (!chip->dev_ready (chip)) ; }
drivers/mtd/nand/raw/omap2.c +2 -2
@@ -1021,9 +1021,9 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)* * Returns true if ready and false if busy. */ -static int omap_dev_ready (struct mtd_info *mtd) +static int omap_dev_ready (struct nand_chip *chip) { -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (chip));return gpiod_get_value (info->ready_gpiod); }
drivers/mtd/nand/raw/pasemi_nand.c +1 -1
@@ -80,7 +80,7 @@ static void pasemi_hwcontrol(struct nand_chip *chip, int cmd,inl (lpcctl); } -int pasemi_device_ready (struct mtd_info *mtd) +int pasemi_device_ready (struct nand_chip *chip) {return !!(inl (lpcctl) &LBICTRL_LPCCTL_NR ); }
drivers/mtd/nand/raw/plat_nand.c +1 -11
@@ -23,13 +23,6 @@ struct plat_nand_data {void __iomem *io_base; }; -static int plat_nand_dev_ready (struct mtd_info *mtd) -{ -struct platform_nand_data *pdata =dev_get_platdata (mtd->dev.parent); - -return pdata->ctrl.dev_ready (mtd_to_nand (mtd)); -} -/* * Probe for the NAND device. */
@@ -70,10 +63,7 @@ static int plat_nand_probe(struct platform_device *pdev) data->chip.IO_ADDR_R = data->io_base; data->chip.IO_ADDR_W = data->io_base; data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl; - -if (pdata->ctrl.dev_ready) - data->chip.dev_ready = plat_nand_dev_ready; - + data->chip.dev_ready = pdata->ctrl.dev_ready; data->chip.select_chip = pdata->ctrl.select_chip; data->chip.write_buf = pdata->ctrl.write_buf; data->chip.read_buf = pdata->ctrl.read_buf;
drivers/mtd/nand/raw/r852.c +3 -3
@@ -373,7 +373,7 @@ static int r852_wait(struct mtd_info *mtd, struct nand_chip *chip) msecs_to_jiffies(400) : msecs_to_jiffies(20));while (time_before (jiffies, timeout)) -if (chip->dev_ready (mtd)) +if (chip->dev_ready (chip))break ;nand_status_op (chip, &status);
@@ -390,9 +390,9 @@ static int r852_wait(struct mtd_info *mtd, struct nand_chip *chip)* Check if card is ready */ -static int r852_ready (struct mtd_info *mtd) +static int r852_ready (struct nand_chip *chip) { -struct r852_device *dev =r852_get_dev (mtd); +struct r852_device *dev =r852_get_dev (nand_to_mtd (chip));return !(r852_read_reg (dev,R852_CARD_STA ) &R852_CARD_STA_BUSY ); }
drivers/mtd/nand/raw/s3c2410.c +6 -3
@@ -493,20 +493,23 @@ static void s3c2440_nand_hwcontrol(struct nand_chip *chip, int cmd,* returns 0 if the nand is busy, 1 if it is ready */ -static int s3c2410_nand_devready (struct mtd_info *mtd) +static int s3c2410_nand_devready (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);return readb (info->regs +S3C2410_NFSTAT ) &S3C2410_NFSTAT_BUSY ; } -static int s3c2440_nand_devready (struct mtd_info *mtd) +static int s3c2440_nand_devready (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);return readb (info->regs +S3C2440_NFSTAT ) &S3C2440_NFSTAT_READY ; } -static int s3c2412_nand_devready (struct mtd_info *mtd) +static int s3c2412_nand_devready (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct s3c2410_nand_info *info =s3c2410_nand_mtd_toinfo (mtd);return readb (info->regs +S3C2412_NFSTAT ) &S3C2412_NFSTAT_READY ; }
drivers/mtd/nand/raw/sharpsl.c +2 -2
@@ -78,9 +78,9 @@ static void sharpsl_nand_hwcontrol(struct nand_chip *chip, int cmd,writeb (cmd, chip->IO_ADDR_W); } -static int sharpsl_nand_dev_ready (struct mtd_info *mtd) +static int sharpsl_nand_dev_ready (struct nand_chip *chip) { -struct sharpsl_nand *sharpsl =mtd_to_sharpsl (mtd); +struct sharpsl_nand *sharpsl =mtd_to_sharpsl (nand_to_mtd (chip));return !((readb (sharpsl->io +FLASHCTL ) &FLRYBY ) ==0 ); }
drivers/mtd/nand/raw/socrates_nand.c +1 -2
@@ -112,9 +112,8 @@ static void socrates_nand_cmd_ctrl(struct nand_chip *nand_chip, int cmd,/* * Read the Device Ready pin. */ -static int socrates_nand_device_ready (struct mtd_info *mtd) +static int socrates_nand_device_ready (struct nand_chip *nand_chip) { -struct nand_chip *nand_chip =mtd_to_nand (mtd);struct socrates_nand_host *host =nand_get_controller_data (nand_chip);if (in_be32 (host->io_base) &FPGA_NAND_BUSY )
drivers/mtd/nand/raw/sunxi_nand.c +1 -2
@@ -400,9 +400,8 @@ static void sunxi_nfc_dma_op_cleanup(struct mtd_info *mtd, nfc->regs + NFC_REG_CTL); } -static int sunxi_nfc_dev_ready (struct mtd_info *mtd) +static int sunxi_nfc_dev_ready (struct nand_chip *nand) { -struct nand_chip *nand =mtd_to_nand (mtd);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);struct sunxi_nfc *nfc =to_sunxi_nfc (sunxi_nand->nand.controller);u32 mask;
drivers/mtd/nand/raw/tango_nand.c +1 -2
@@ -127,9 +127,8 @@ static void tango_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl)writeb_relaxed (dat, tchip->base +PBUS_ADDR ); } -static int tango_dev_ready (struct mtd_info *mtd) +static int tango_dev_ready (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct tango_nfc *nfc =to_tango_nfc (chip->controller);return readl_relaxed (nfc->pbus_base +PBUS_CS_CTRL ) &PBUS_IORDY ;
drivers/mtd/nand/raw/tmio_nand.c +4 -4
@@ -158,9 +158,9 @@ static void tmio_nand_hwcontrol(struct nand_chip *chip, int cmd,tmio_iowrite8 (cmd, chip->IO_ADDR_W); } -static int tmio_nand_dev_ready (struct mtd_info *mtd) +static int tmio_nand_dev_ready (struct nand_chip *chip) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (chip));return !(tmio_ioread8 (tmio->fcr +FCR_STATUS ) &FCR_STATUS_BUSY ); }
@@ -198,10 +198,10 @@ tmio_nand_wait(struct mtd_info *mtd, struct nand_chip *nand_chip)tmio_iowrite8 (0x81 , tmio->fcr +FCR_IMR ); timeout =wait_event_timeout (nand_chip->controller->wq, -tmio_nand_dev_ready (mtd), +tmio_nand_dev_ready (nand_chip),msecs_to_jiffies (nand_chip->state ==FL_ERASING ?400 :20 )); -if (unlikely (!tmio_nand_dev_ready (mtd))) { +if (unlikely (!tmio_nand_dev_ready (nand_chip))) {tmio_iowrite8 (0x00 , tmio->fcr +FCR_IMR ); dev_warn(&tmio->dev->dev, "still busy with %s after %d ms\n", nand_chip->state == FL_ERASING ? "erase" : "program",
drivers/mtd/nand/raw/txx9ndfmc.c +2 -2
@@ -162,9 +162,9 @@ static void txx9ndfmc_cmd_ctrl(struct nand_chip *chip, int cmd,mmiowb (); } -static int txx9ndfmc_dev_ready (struct mtd_info *mtd) +static int txx9ndfmc_dev_ready (struct nand_chip *chip) { -struct platform_device *dev =mtd_to_platdev (mtd); +struct platform_device *dev =mtd_to_platdev (nand_to_mtd (chip));return !(txx9ndfmc_read (dev,TXX9_NDFSR ) &TXX9_NDFSR_BUSY ); }
drivers/mtd/nand/raw/xway_nand.c +1 -1
@@ -121,7 +121,7 @@ static void xway_cmd_ctrl(struct nand_chip *chip, int cmd, unsigned int ctrl) ; } -static int xway_dev_ready (struct mtd_info *mtd) +static int xway_dev_ready (struct nand_chip *chip) {return ltq_ebu_r32 (EBU_NAND_WAIT ) &NAND_WAIT_RD ; }
include/linux/mtd/rawnand.h +1 -1
@@ -1291,7 +1291,7 @@ struct nand_chip {int (*block_bad)(struct nand_chip *chip,loff_t ofs);int (*block_markbad)(struct nand_chip *chip,loff_t ofs);void (*cmd_ctrl)(struct nand_chip *chip,int dat,unsigned int ctrl); -int (*dev_ready)(struct mtd_info *mtd); +int (*dev_ready)(struct nand_chip *chip);void (*cmdfunc)(struct mtd_info *mtd,unsigned command,int column,int page_addr);int (*waitfunc)(struct mtd_info *mtd,struct nand_chip *this);
Signature · 1 line
2.14.1
PATCH v2 16/23 mtd: rawnand: Pass a nand_chip object to chip->cmdfunc()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->cmdfunc() hook.
--- drivers/mtd/nand/raw/au1550nd.c | 7 ++-- drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c | 4 +-- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 +-- drivers/mtd/nand/raw/cafe_nand.c | 4 +-- drivers/mtd/nand/raw/diskonchip.c | 5 +-- drivers/mtd/nand/raw/docg4.c | 4 +-- drivers/mtd/nand/raw/fsl_elbc_nand.c | 4 +-- drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 ++-- drivers/mtd/nand/raw/hisi504_nand.c | 6 ++-- drivers/mtd/nand/raw/mpc5121_nfc.c | 8 ++--- drivers/mtd/nand/raw/mxc_nand.c | 6 ++-- drivers/mtd/nand/raw/nand_base.c | 46 ++++++++++++------------ drivers/mtd/nand/raw/nand_hynix.c | 7 ++-- drivers/mtd/nand/raw/nuc900_nand.c | 5 +-- drivers/mtd/nand/raw/qcom_nandc.c | 3 +- drivers/mtd/nand/raw/sh_flctl.c | 3 +- drivers/staging/mt29f_spinand/mt29f_spinand.c | 4 +-- include/linux/mtd/rawnand.h | 2 +- 18 files changed, 64 insertions(+), 64 deletions(-)
drivers/mtd/nand/raw/au1550nd.c +4 -3
@@ -236,14 +236,15 @@ static void au1550_select_chip(struct nand_chip *this, int chip)/** * au1550_command - Send command to NAND device -* @mtd: MTD device structure +* @this: NAND chip object * @command: the command to be sent * @column: the column address for this command, -1 if none * @page_addr: the page address for this command, -1 if none */ -static void au1550_command (struct mtd_info *mtd,unsigned command,int column,int page_addr) +static void au1550_command (struct nand_chip *this,unsigned command, +int column,int page_addr) { -struct nand_chip *this =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (this); struct au1550nd_ctx *ctx = container_of(this, struct au1550nd_ctx, chip);int ce_override =0 , i;
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c +2 -2
@@ -210,11 +210,11 @@ static int bcm47xxnflash_ops_bcm4706_dev_ready(struct nand_chip *nand_chip)* registers of ChipCommon core. Hacking cmd_ctrl to understand and convert * standard commands would be much more complicated. */ -static void bcm47xxnflash_ops_bcm4706_cmdfunc (struct mtd_info *mtd, +static void bcm47xxnflash_ops_bcm4706_cmdfunc (struct nand_chip *nand_chip,unsigned command,int column,int page_addr) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand_chip);struct bcm47xxnflash *b47n =nand_get_controller_data (nand_chip);struct bcma_drv_cc *cc = b47n->cc;u32 ctlcode;
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -2
@@ -1310,10 +1310,10 @@ static int brcmnand_low_level_op(struct brcmnand_host *host,return brcmnand_waitfunc (mtd, chip); } -static void brcmnand_cmdfunc (struct mtd_info *mtd,unsigned command, +static void brcmnand_cmdfunc (struct nand_chip *chip,unsigned command,int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct brcmnand_host *host =nand_get_controller_data (chip);struct brcmnand_controller *ctrl = host->ctrl;u64 addr = (u64 )page_addr << chip->page_shift;
drivers/mtd/nand/raw/cafe_nand.c +2 -2
@@ -156,10 +156,10 @@ static uint8_t cafe_read_byte(struct nand_chip *chip)return d; } -static void cafe_nand_cmdfunc (struct mtd_info *mtd,unsigned command, +static void cafe_nand_cmdfunc (struct nand_chip *chip,unsigned command,int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct cafe_priv *cafe =nand_get_controller_data (chip);int adrbytes =0 ;uint32_t ctl1;
drivers/mtd/nand/raw/diskonchip.c +3 -2
@@ -637,9 +637,10 @@ static void doc200x_hwcontrol(struct nand_chip *this, int cmd, } } -static void doc2001plus_command (struct mtd_info *mtd,unsigned command,int column,int page_addr) +static void doc2001plus_command (struct nand_chip *this,unsigned command, +int column,int page_addr) { -struct nand_chip *this =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (this);struct doc_priv *doc =nand_get_controller_data (this);void __iomem *docptr = doc->virtadr;
drivers/mtd/nand/raw/docg4.c +2 -2
@@ -705,12 +705,12 @@ static uint32_t mtd_to_docg4_address(int page, int column)return (g4_page <<16 ) | g4_index;/* pack */ } -static void docg4_command (struct mtd_info *mtd,unsigned command,int column, +static void docg4_command (struct nand_chip *nand,unsigned command,int column,int page_addr) {/* handle standard nand commands */ -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct docg4_priv *doc =nand_get_controller_data (nand);uint32_t g4_addr =mtd_to_docg4_address (page_addr, column);
drivers/mtd/nand/raw/fsl_elbc_nand.c +2 -2
@@ -317,10 +317,10 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob) }/* cmdfunc send commands to the FCM */ -static void fsl_elbc_cmdfunc (struct mtd_info *mtd,unsigned int command, +static void fsl_elbc_cmdfunc (struct nand_chip *chip,unsigned int command,int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_lbc_ctrl *ctrl = priv->ctrl;struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
drivers/mtd/nand/raw/fsl_ifc_nand.c +3 -3
@@ -301,9 +301,9 @@ static void fsl_ifc_do_read(struct nand_chip *chip, }/* cmdfunc send commands to the IFC NAND Machine */ -static void fsl_ifc_cmdfunc (struct mtd_info *mtd,unsigned int command, -int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd); +static void fsl_ifc_cmdfunc (struct nand_chip *chip,unsigned int command, +int column,int page_addr) { +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
drivers/mtd/nand/raw/hisi504_nand.c +3 -3
@@ -429,10 +429,10 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr) } } -static void hisi_nfc_cmdfunc (struct mtd_info *mtd,unsigned command,int column, -int page_addr) +static void hisi_nfc_cmdfunc (struct nand_chip *chip,unsigned command, +int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct hinfc_host *host =nand_get_controller_data (chip);int is_cache_invalid =1 ;unsigned int flag =0 ;
drivers/mtd/nand/raw/mpc5121_nfc.c +4 -4
@@ -330,10 +330,10 @@ static int mpc5121_nfc_dev_ready(struct nand_chip *nand) }/* Write command to NAND flash */ -static void mpc5121_nfc_command (struct mtd_info *mtd,unsigned command, -int column,int page) +static void mpc5121_nfc_command (struct nand_chip *chip,unsigned command, +int column,int page) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip); prv->column = (column >=0 ) ? column :0 ;
@@ -364,7 +364,7 @@ static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command,break ;case NAND_CMD_SEQIN : -mpc5121_nfc_command (mtd,NAND_CMD_READ0 , column, page); +mpc5121_nfc_command (chip,NAND_CMD_READ0 , column, page); column =0 ;break ;
drivers/mtd/nand/raw/mxc_nand.c +3 -3
@@ -1333,10 +1333,10 @@ static void preset_v3(struct mtd_info *mtd)/* Used by the upper layer to write command to NAND Flash for * different operations to be carried out on NAND Flash */ -static void mxc_nand_command (struct mtd_info *mtd,unsigned command, -int column,int page_addr) +static void mxc_nand_command (struct nand_chip *nand_chip,unsigned command, +int column,int page_addr) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand_chip);struct mxc_nand_host *host =nand_get_controller_data (nand_chip); dev_dbg(host->dev, "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
drivers/mtd/nand/raw/nand_base.c +23 -23
165 lines not on this page · raw message
drivers/mtd/nand/raw/nand_hynix.c +2 -5
@@ -79,8 +79,6 @@ static bool hynix_nand_has_valid_jedecid(struct nand_chip *chip)static int hynix_nand_cmd_op (struct nand_chip *chip,u8 cmd) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (chip->exec_op) {struct nand_op_instr instrs[] = { NAND_OP_CMD(cmd, 0),
@@ -90,14 +88,13 @@ static int hynix_nand_cmd_op(struct nand_chip *chip, u8 cmd)return nand_exec_op (chip, &op); } - chip->cmdfunc (mtd, cmd,-1 ,-1 ); + chip->cmdfunc (chip, cmd,-1 ,-1 );return 0 ; }static int hynix_nand_reg_write_op (struct nand_chip *chip,u8 addr,u8 val) { -struct mtd_info *mtd =nand_to_mtd (chip);u16 column = ((u16 )addr <<8 ) | addr;if (chip->exec_op) {
@@ -110,7 +107,7 @@ static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val)return nand_exec_op (chip, &op); } - chip->cmdfunc (mtd,NAND_CMD_NONE , column,-1 ); + chip->cmdfunc (chip,NAND_CMD_NONE , column,-1 ); chip->write_byte (chip, val);return 0 ;
drivers/mtd/nand/raw/nuc900_nand.c +3 -2
@@ -129,10 +129,11 @@ static int nuc900_nand_devready(struct nand_chip *chip)return ready; } -static void nuc900_nand_command_lp (struct mtd_info *mtd,unsigned int command, +static void nuc900_nand_command_lp (struct nand_chip *chip, +unsigned int command,int column,int page_addr) { - registerstruct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct nuc900_nand *nand =mtd_to_nuc900 (mtd);if (command ==NAND_CMD_READOOB ) {
drivers/mtd/nand/raw/qcom_nandc.c +1 -2
@@ -1440,10 +1440,9 @@ static void post_command(struct qcom_nand_host *host, int command)* NAND_CMD_READOOB would never be called because we have our own versions * of read_oob ops for nand_ecc_ctrl. */ -static void qcom_nandc_command (struct mtd_info *mtd,unsigned int command, +static void qcom_nandc_command (struct nand_chip *chip,unsigned int command,int column,int page_addr) { -struct nand_chip *chip =mtd_to_nand (mtd);struct qcom_nand_host *host =to_qcom_nand_host (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;struct qcom_nand_controller *nandc =get_qcom_nand_controller (chip);
drivers/mtd/nand/raw/sh_flctl.c +2 -1
@@ -750,9 +750,10 @@ static void execmd_write_oob(struct mtd_info *mtd) } } -static void flctl_cmdfunc (struct mtd_info *mtd,unsigned int command, +static void flctl_cmdfunc (struct nand_chip *chip,unsigned int command,int column,int page_addr) { +struct mtd_info *mtd =nand_to_mtd (chip);struct sh_flctl *flctl =mtd_to_flctl (mtd);uint32_t read_cmd =0 ;
drivers/staging/mt29f_spinand/mt29f_spinand.c +2 -2
@@ -759,10 +759,10 @@ static void spinand_reset(struct spi_device *spi_nand)dev_err (&spi_nand->dev,"wait timedout!\n" ); } -static void spinand_cmdfunc (struct mtd_info *mtd,unsigned int command, +static void spinand_cmdfunc (struct nand_chip *chip,unsigned int command,int column,int page) { -struct nand_chip *chip =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (chip);struct spinand_info *info =nand_get_controller_data (chip);struct spinand_state *state = info->priv;
include/linux/mtd/rawnand.h +1 -1
@@ -1292,7 +1292,7 @@ struct nand_chip {int (*block_markbad)(struct nand_chip *chip,loff_t ofs);void (*cmd_ctrl)(struct nand_chip *chip,int dat,unsigned int ctrl);int (*dev_ready)(struct nand_chip *chip); -void (*cmdfunc)(struct mtd_info *mtd,unsigned command,int column, +void (*cmdfunc)(struct nand_chip *chip,unsigned command,int column,int page_addr);int (*waitfunc)(struct mtd_info *mtd,struct nand_chip *this); int (*exec_op)(struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH v2 17/23 mtd: rawnand: Pass a nand_chip object to chip->waitfunc()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->waitfunc() hook.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++------ drivers/mtd/nand/raw/denali.c | 4 ++-- drivers/mtd/nand/raw/diskonchip.c | 2 +- drivers/mtd/nand/raw/docg4.c | 4 ++-- drivers/mtd/nand/raw/fsl_elbc_nand.c | 4 ++-- drivers/mtd/nand/raw/fsl_ifc_nand.c | 3 ++- drivers/mtd/nand/raw/lpc32xx_mlc.c | 17 ++++++++-------- drivers/mtd/nand/raw/nand_base.c | 29 ++++++++------------------- drivers/mtd/nand/raw/omap2.c | 8 +++----- drivers/mtd/nand/raw/r852.c | 2 +- drivers/mtd/nand/raw/tango_nand.c | 2 +- drivers/mtd/nand/raw/tmio_nand.c | 5 ++--- drivers/staging/mt29f_spinand/mt29f_spinand.c | 3 ++- include/linux/mtd/rawnand.h | 2 +- 15 files changed, 42 insertions(+), 57 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
@@ -945,7 +945,7 @@ static int atmel_hsmc_nand_pmecc_write_pg(struct nand_chip *chip,dev_err (nc->base.dev,"Failed to program NAND page (err = %d)\n" , ret); - status = chip->waitfunc (mtd, chip); + status = chip->waitfunc (chip);if (status &NAND_STATUS_FAIL )return -EIO ;
drivers/mtd/nand/raw/brcmnand/brcmnand.c +5 -7
@@ -1237,9 +1237,8 @@ static void brcmnand_cmd_ctrl(struct nand_chip *chip, int dat,/* intentionally left blank */ } -static int brcmnand_waitfunc (struct mtd_info *mtd,struct nand_chip *this) +static int brcmnand_waitfunc (struct nand_chip *chip) { -struct nand_chip *chip =mtd_to_nand (mtd);struct brcmnand_host *host =nand_get_controller_data (chip);struct brcmnand_controller *ctrl = host->ctrl;unsigned long timeo =msecs_to_jiffies (100 );
@@ -1274,7 +1273,6 @@ static int brcmnand_low_level_op(struct brcmnand_host *host, enum brcmnand_llop_type type, u32 data, bool last_op) { - struct mtd_info *mtd = nand_to_mtd(&host->chip); struct nand_chip *chip = &host->chip;struct brcmnand_controller *ctrl = host->ctrl;u32 tmp;
@@ -1307,7 +1305,7 @@ static int brcmnand_low_level_op(struct brcmnand_host *host, (void )brcmnand_read_reg (ctrl,BRCMNAND_LL_OP );brcmnand_send_cmd (host,CMD_LOW_LEVEL_OP ); -return brcmnand_waitfunc (mtd, chip); +return brcmnand_waitfunc (chip); } static void brcmnand_cmdfunc(struct nand_chip *chip, unsigned command,
@@ -1383,7 +1381,7 @@ static void brcmnand_cmdfunc(struct nand_chip *chip, unsigned command, (void )brcmnand_read_reg (ctrl,BRCMNAND_CMD_ADDRESS );brcmnand_send_cmd (host, native_cmd); -brcmnand_waitfunc (mtd, chip); +brcmnand_waitfunc (chip);if (native_cmd ==CMD_PARAMETER_READ || native_cmd ==CMD_PARAMETER_CHANGE_COL ) {
@@ -1615,7 +1613,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, (void )brcmnand_read_reg (ctrl,BRCMNAND_CMD_ADDRESS );/* SPARE_AREA_READ does not use ECC, so just use PAGE_READ */ brcmnand_send_cmd (host,CMD_PAGE_READ ); -brcmnand_waitfunc (mtd, chip); +brcmnand_waitfunc (chip);if (likely (buf)) {brcmnand_soc_data_bus_prepare (ctrl->soc, false);
@@ -1893,7 +1891,7 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip,/* we cannot use SPARE_AREA_PROGRAM when PARTIAL_PAGE_EN=0 */ brcmnand_send_cmd (host,CMD_PROGRAM_PAGE ); - status =brcmnand_waitfunc (mtd, chip); + status =brcmnand_waitfunc (chip);if (status &NAND_STATUS_FAIL ) { dev_info(ctrl->dev, "program failed at %llx\n",
drivers/mtd/nand/raw/denali.c +2 -2
@@ -904,9 +904,9 @@ static void denali_select_chip(struct nand_chip *chip, int cs) denali->active_bank = cs; } -static int denali_waitfunc (struct mtd_info *mtd,struct nand_chip *chip) +static int denali_waitfunc (struct nand_chip *chip) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));uint32_t irq_status;/* R/B# pin transitioned from low to high? */
drivers/mtd/nand/raw/diskonchip.c +1 -1
@@ -433,7 +433,7 @@ static void __init doc2000_count_chips(struct mtd_info *mtd)pr_debug ("Detected %d chips per floor.\n" , i); } -static int doc200x_wait (struct mtd_info *mtd,struct nand_chip *this) +static int doc200x_wait (struct nand_chip *this) {struct doc_priv *doc =nand_get_controller_data (this);
drivers/mtd/nand/raw/docg4.c +2 -2
@@ -315,7 +315,7 @@ static int poll_status(struct docg4_priv *doc) } -static int docg4_wait (struct mtd_info *mtd,struct nand_chip *nand) +static int docg4_wait (struct nand_chip *nand) {struct docg4_priv *doc =nand_get_controller_data (nand);
@@ -938,7 +938,7 @@ static int docg4_erase_block(struct mtd_info *mtd, int page)poll_status (doc);write_nop (docptr); - status = nand->waitfunc (mtd, nand); + status = nand->waitfunc (nand);if (status <0 )return status;
drivers/mtd/nand/raw/fsl_elbc_nand.c +2 -2
@@ -621,7 +621,7 @@ static void fsl_elbc_read_buf(struct nand_chip *chip, u8 *buf, int len)/* This function is called after Program and Erase Operations to * check for success or failure. */ -static int fsl_elbc_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int fsl_elbc_wait (struct nand_chip *chip) {struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
@@ -720,7 +720,7 @@ static int fsl_elbc_read_page(struct nand_chip *chip, uint8_t *buf,if (oob_required)fsl_elbc_read_buf (chip, chip->oob_poi, mtd->oobsize); -if (fsl_elbc_wait (mtd, chip) &NAND_STATUS_FAIL ) +if (fsl_elbc_wait (chip) &NAND_STATUS_FAIL ) mtd->ecc_stats.failed++;return elbc_fcm_ctrl->max_bitflips;
drivers/mtd/nand/raw/fsl_ifc_nand.c +2 -1
@@ -614,8 +614,9 @@ static void fsl_ifc_read_buf(struct nand_chip *chip, u8 *buf, int len)* This function is called after Program and Erase Operations to * check for success or failure. */ -static int fsl_ifc_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int fsl_ifc_wait (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
drivers/mtd/nand/raw/lpc32xx_mlc.c +9 -8
@@ -328,8 +328,9 @@ static irqreturn_t lpc3xxx_nand_irq(int irq, struct lpc32xx_nand_host *host)return IRQ_HANDLED ; } -static int lpc32xx_waitfunc_nand (struct mtd_info *mtd,struct nand_chip *chip) +static int lpc32xx_waitfunc_nand (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);if (readb (MLC_ISR (host->io_base)) &MLCISR_NAND_READY )
@@ -347,9 +348,9 @@ static int lpc32xx_waitfunc_nand(struct mtd_info *mtd, struct nand_chip *chip)return NAND_STATUS_READY ; } -static int lpc32xx_waitfunc_controller (struct mtd_info *mtd, -struct nand_chip *chip) +static int lpc32xx_waitfunc_controller (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct lpc32xx_nand_host *host =nand_get_controller_data (chip);if (readb (MLC_ISR (host->io_base)) &MLCISR_CONTROLLER_READY )
@@ -367,10 +368,10 @@ static int lpc32xx_waitfunc_controller(struct mtd_info *mtd,return NAND_STATUS_READY ; } -static int lpc32xx_waitfunc (struct mtd_info *mtd,struct nand_chip *chip) +static int lpc32xx_waitfunc (struct nand_chip *chip) { -lpc32xx_waitfunc_nand (mtd, chip); -lpc32xx_waitfunc_controller (mtd, chip); +lpc32xx_waitfunc_nand (chip); +lpc32xx_waitfunc_controller (chip);return NAND_STATUS_READY ; }
@@ -469,7 +470,7 @@ static int lpc32xx_read_page(struct nand_chip *chip, uint8_t *buf,writeb (0x00 ,MLC_ECC_AUTO_DEC_REG (host->io_base));/* Wait for Controller Ready */ -lpc32xx_waitfunc_controller (mtd, chip); +lpc32xx_waitfunc_controller (chip);/* Check ECC Error status */ mlc_isr =readl (MLC_ISR (host->io_base));
@@ -550,7 +551,7 @@ static int lpc32xx_write_page_lowlevel(struct nand_chip *chip,writeb (0x00 ,MLC_ECC_AUTO_ENC_REG (host->io_base));/* Wait for Controller Ready */ -lpc32xx_waitfunc_controller (mtd, chip); +lpc32xx_waitfunc_controller (chip); }return nand_prog_page_end_op (chip);
drivers/mtd/nand/raw/nand_base.c +8 -21
@@ -1062,8 +1062,7 @@ nand_get_device(struct mtd_info *mtd, int new_state)* we are in interrupt context. May happen when in panic and trying to write * an oops through mtdoops. */ -static void panic_nand_wait (struct mtd_info *mtd,struct nand_chip *chip, -unsigned long timeo) +static void panic_nand_wait (struct nand_chip *chip,unsigned long timeo) {int i;for (i =0 ; i < timeo; i++) {
@@ -1093,7 +1092,7 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,* * Wait for command done. This applies to erase and program only. */ -static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int nand_wait (struct nand_chip *chip) {unsigned long timeo =400 ;
@@ -1111,7 +1110,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)return ret;if (in_interrupt () || oops_in_progress) -panic_nand_wait (mtd, chip, timeo); +panic_nand_wait (chip, timeo);else { timeo = jiffies +msecs_to_jiffies (timeo); do {
@@ -1553,7 +1552,6 @@ EXPORT_SYMBOL_GPL(nand_read_page_op);static int nand_read_param_page_op (struct nand_chip *chip,u8 page,void *buf,unsigned int len) { -struct mtd_info *mtd =nand_to_mtd (chip);unsigned int i;u8 *p = buf;
@@ -1811,7 +1809,6 @@ EXPORT_SYMBOL_GPL(nand_prog_page_begin_op);*/ int nand_prog_page_end_op (struct nand_chip *chip) { -struct mtd_info *mtd =nand_to_mtd (chip);int ret;u8 status;
@@ -1834,7 +1831,7 @@ int nand_prog_page_end_op(struct nand_chip *chip)return ret; }else { chip->cmdfunc (chip,NAND_CMD_PAGEPROG ,-1 ,-1 ); - ret = chip->waitfunc (mtd, chip); + ret = chip->waitfunc (chip);if (ret <0 )return ret;
@@ -1881,7 +1878,7 @@ int nand_prog_page_op(struct nand_chip *chip, unsigned int page, chip->cmdfunc (chip,NAND_CMD_SEQIN , offset_in_page, page); chip->write_buf (chip, buf, len); chip->cmdfunc (chip,NAND_CMD_PAGEPROG ,-1 ,-1 ); - status = chip->waitfunc (mtd, chip); + status = chip->waitfunc (chip); }if (status &NAND_STATUS_FAIL )
@@ -1970,7 +1967,6 @@ EXPORT_SYMBOL_GPL(nand_change_write_column_op);int nand_readid_op (struct nand_chip *chip,u8 addr,void *buf,unsigned int len) { -struct mtd_info *mtd =nand_to_mtd (chip);unsigned int i;u8 *id = buf;
@@ -2016,8 +2012,6 @@ EXPORT_SYMBOL_GPL(nand_readid_op);*/ int nand_status_op (struct nand_chip *chip,u8 *status) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (chip->exec_op) {const struct nand_sdr_timings *sdr =nand_get_sdr_timings (&chip->data_interface);
@@ -2055,8 +2049,6 @@ EXPORT_SYMBOL_GPL(nand_status_op);*/ int nand_exit_status_op (struct nand_chip *chip) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (chip->exec_op) {struct nand_op_instr instrs[] = { NAND_OP_CMD(NAND_CMD_READ0, 0),
@@ -2085,7 +2077,6 @@ EXPORT_SYMBOL_GPL(nand_exit_status_op);*/ int nand_erase_op (struct nand_chip *chip,unsigned int eraseblock) { -struct mtd_info *mtd =nand_to_mtd (chip);unsigned int page = eraseblock << (chip->phys_erase_shift - chip->page_shift);int ret;
@@ -2118,7 +2109,7 @@ int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock) chip->cmdfunc (chip,NAND_CMD_ERASE1 ,-1 , page); chip->cmdfunc (chip,NAND_CMD_ERASE2 ,-1 ,-1 ); - ret = chip->waitfunc (mtd, chip); + ret = chip->waitfunc (chip);if (ret <0 )return ret;
@@ -2147,7 +2138,6 @@ EXPORT_SYMBOL_GPL(nand_erase_op);static int nand_set_features_op (struct nand_chip *chip,u8 feature,const void *data) { -struct mtd_info *mtd =nand_to_mtd (chip);const u8 *params = data;int i, ret;
@@ -2170,7 +2160,7 @@ static int nand_set_features_op(struct nand_chip *chip, u8 feature,for (i =0 ; i <ONFI_SUBFEATURE_PARAM_LEN ; ++i) chip->write_byte (chip, params[i]); - ret = chip->waitfunc (mtd, chip); + ret = chip->waitfunc (chip);if (ret <0 )return ret;
@@ -2195,7 +2185,6 @@ static int nand_set_features_op(struct nand_chip *chip, u8 feature,static int nand_get_features_op (struct nand_chip *chip,u8 feature,void *data) { -struct mtd_info *mtd =nand_to_mtd (chip);u8 *params = data;int i;
@@ -2256,8 +2245,6 @@ static int nand_wait_rdy_op(struct nand_chip *chip, unsigned int timeout_ms,*/ int nand_reset_op (struct nand_chip *chip) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (chip->exec_op) {const struct nand_sdr_timings *sdr =nand_get_sdr_timings (&chip->data_interface);
@@ -4518,7 +4505,7 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, chip->select_chip (chip, chipnr);/* Wait for the device to get ready */ -panic_nand_wait (mtd, chip,400 ); +panic_nand_wait (chip,400 );memset (&ops,0 ,sizeof (ops)); ops.len = len;
drivers/mtd/nand/raw/omap2.c +3 -5
@@ -981,8 +981,7 @@ static void omap_enable_hwecc(struct nand_chip *chip, int mode)/** * omap_wait - wait until the command is done -* @mtd: MTD device structure -* @chip: NAND Chip structure +* @this: NAND Chip structure * * Wait function is called during Program and erase operations and * the way it is called from MTD layer, we should wait till the NAND
@@ -991,10 +990,9 @@ static void omap_enable_hwecc(struct nand_chip *chip, int mode)* Erase can take up to 400ms and program up to 20ms according to * general NAND and SmartMedia specs */ -static int omap_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int omap_wait (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd); -struct omap_nand_info *info =mtd_to_omap (mtd); +struct omap_nand_info *info =mtd_to_omap (nand_to_mtd (this));unsigned long timeo = jiffies;int status, state = this->state;
drivers/mtd/nand/raw/r852.c +1 -1
@@ -362,7 +362,7 @@ static void r852_cmdctl(struct nand_chip *chip, int dat, unsigned int ctrl)* Wait till card is ready. * based on nand_wait, but returns errors on DMA error */ -static int r852_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int r852_wait (struct nand_chip *chip) {struct r852_device *dev =nand_get_controller_data (chip);
drivers/mtd/nand/raw/tango_nand.c +1 -1
@@ -314,7 +314,7 @@ static int tango_write_page(struct nand_chip *chip, const u8 *buf,if (err)return err; - status = chip->waitfunc (mtd, chip); + status = chip->waitfunc (chip);if (status &NAND_STATUS_FAIL )return -EIO ;
drivers/mtd/nand/raw/tmio_nand.c +2 -3
@@ -186,10 +186,9 @@ static irqreturn_t tmio_irq(int irq, void *__tmio)*erase and write, we enable it to wake us up. The irq handler *disables the interrupt. */ -static int -tmio_nand_wait (struct mtd_info *mtd,struct nand_chip *nand_chip) +static int tmio_nand_wait (struct nand_chip *nand_chip) { -struct tmio_nand *tmio =mtd_to_tmio (mtd); +struct tmio_nand *tmio =mtd_to_tmio (nand_to_mtd (nand_chip));long timeout;u8 status;
drivers/staging/mt29f_spinand/mt29f_spinand.c +2 -1
@@ -695,8 +695,9 @@ static u8 spinand_read_byte(struct nand_chip *chip)return data; } -static int spinand_wait (struct mtd_info *mtd,struct nand_chip *chip) +static int spinand_wait (struct nand_chip *chip) { +struct mtd_info *mtd =nand_to_mtd (chip);struct spinand_info *info =nand_get_controller_data (chip);unsigned long timeo = jiffies;
include/linux/mtd/rawnand.h +1 -1
@@ -1294,7 +1294,7 @@ struct nand_chip {int (*dev_ready)(struct nand_chip *chip);void (*cmdfunc)(struct nand_chip *chip,unsigned command,int column,int page_addr); -int (*waitfunc)(struct mtd_info *mtd,struct nand_chip *this); +int (*waitfunc)(struct nand_chip *chip);int (*exec_op)(struct nand_chip *chip,const struct nand_operation *op,bool check_only);
Signature · 1 line
2.14.1
PATCH v2 18/23 mtd: rawnand: Pass a nand_chip object to chip->erase()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->erase() hook.
--- drivers/mtd/nand/raw/denali.c | 4 ++-- drivers/mtd/nand/raw/docg4.c | 4 ++-- drivers/mtd/nand/raw/nand_base.c | 7 +++---- include/linux/mtd/rawnand.h | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-)
drivers/mtd/nand/raw/denali.c +2 -2
@@ -915,9 +915,9 @@ static int denali_waitfunc(struct nand_chip *chip)return irq_status &INTR__INT_ACT ?0 :NAND_STATUS_FAIL ; } -static int denali_erase (struct mtd_info *mtd,int page) +static int denali_erase (struct nand_chip *chip,int page) { -struct denali_nand_info *denali =mtd_to_denali (mtd); +struct denali_nand_info *denali =mtd_to_denali (nand_to_mtd (chip));uint32_t irq_status;denali_reset_irq (denali);
drivers/mtd/nand/raw/docg4.c +2 -2
@@ -892,9 +892,9 @@ static int docg4_read_oob(struct nand_chip *nand, int page)return 0 ; } -static int docg4_erase_block (struct mtd_info *mtd,int page) +static int docg4_erase_block (struct nand_chip *nand,int page) { -struct nand_chip *nand =mtd_to_nand (mtd); +struct mtd_info *mtd =nand_to_mtd (nand);struct docg4_priv *doc =nand_get_controller_data (nand);void __iomem *docptr = doc->virtadr;uint16_t g4_page;
drivers/mtd/nand/raw/nand_base.c +3 -4
@@ -4623,14 +4623,13 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,/** * single_erase - [GENERIC] NAND standard block erase command function -* @mtd: MTD device structure +* @chip: NAND chip object * @page: the page address of the block which will be erased * * Standard erase command for NAND chips. Returns NAND status. */ -static int single_erase (struct mtd_info *mtd,int page) +static int single_erase (struct nand_chip *chip,int page) { -struct nand_chip *chip =mtd_to_nand (mtd);unsigned int eraseblock;/* Send commands to erase a block */
@@ -4715,7 +4714,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, (page + pages_per_block)) chip->pagebuf =-1 ; - status = chip->erase (mtd, page & chip->pagemask); + status = chip->erase (chip, page & chip->pagemask);/* See if block erase succeeded */ if (status) {
include/linux/mtd/rawnand.h +1 -1
@@ -1298,7 +1298,7 @@ struct nand_chip {int (*exec_op)(struct nand_chip *chip,const struct nand_operation *op,bool check_only); -int (*erase)(struct mtd_info *mtd,int page); +int (*erase)(struct nand_chip *chip,int page);int (*set_features)(struct mtd_info *mtd,struct nand_chip *chip,int feature_addr,uint8_t *subfeature_para); int (*get_features)(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH v2 19/23 mtd: rawnand: Pass a nand_chip object to chip->{get, set}_features()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->{get,set}_features() hooks.
--- drivers/mtd/nand/raw/mxc_nand.c | 16 ++++++++-------- drivers/mtd/nand/raw/nand_base.c | 21 ++++++--------------- include/linux/mtd/rawnand.h | 12 ++++++------ 3 files changed, 20 insertions(+), 29 deletions(-)
drivers/mtd/nand/raw/mxc_nand.c +8 -8
@@ -1393,11 +1393,11 @@ static void mxc_nand_command(struct nand_chip *nand_chip, unsigned command, } } -static int mxc_nand_set_features (struct mtd_info *mtd,struct nand_chip *chip, -int addr,u8 *subfeature_param) +static int mxc_nand_set_features (struct nand_chip *chip,int addr, +u8 *subfeature_param) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); -struct mxc_nand_host *host =nand_get_controller_data (nand_chip); +struct mtd_info *mtd =nand_to_mtd (chip); +struct mxc_nand_host *host =nand_get_controller_data (chip);int i; host->buf_start =0 ;
@@ -1413,11 +1413,11 @@ static int mxc_nand_set_features(struct mtd_info *mtd, struct nand_chip *chip,return 0 ; } -static int mxc_nand_get_features (struct mtd_info *mtd,struct nand_chip *chip, -int addr,u8 *subfeature_param) +static int mxc_nand_get_features (struct nand_chip *chip,int addr, +u8 *subfeature_param) { -struct nand_chip *nand_chip =mtd_to_nand (mtd); -struct mxc_nand_host *host =nand_get_controller_data (nand_chip); +struct mtd_info *mtd =nand_to_mtd (chip); +struct mxc_nand_host *host =nand_get_controller_data (chip);int i; host->devtype_data->send_cmd (host,NAND_CMD_GET_FEATURES , false);
drivers/mtd/nand/raw/nand_base.c +6 -15
@@ -1163,12 +1163,10 @@ static bool nand_supports_set_features(struct nand_chip *chip, int addr)int nand_get_features (struct nand_chip *chip,int addr,u8 *subfeature_param) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (!nand_supports_get_features (chip, addr))return -ENOTSUPP ; -return chip->get_features (mtd, chip, addr, subfeature_param); +return chip->get_features (chip, addr, subfeature_param); }EXPORT_SYMBOL_GPL (nand_get_features);
@@ -1184,12 +1182,10 @@ EXPORT_SYMBOL_GPL(nand_get_features);int nand_set_features (struct nand_chip *chip,int addr,u8 *subfeature_param) { -struct mtd_info *mtd =nand_to_mtd (chip); -if (!nand_supports_set_features (chip, addr))return -ENOTSUPP ; -return chip->set_features (mtd, chip, addr, subfeature_param); +return chip->set_features (chip, addr, subfeature_param); }EXPORT_SYMBOL_GPL (nand_set_features);
@@ -4846,13 +4842,11 @@ static int nand_max_bad_blocks(struct mtd_info *mtd, loff_t ofs, size_t len)/** * nand_default_set_features- [REPLACEABLE] set NAND chip features -* @mtd: MTD device structure * @chip: nand chip info structure * @addr: feature address. * @subfeature_param: the subfeature parameters, a four bytes array. */ -static int nand_default_set_features (struct mtd_info *mtd, -struct nand_chip *chip,int addr, +static int nand_default_set_features (struct nand_chip *chip,int addr,uint8_t *subfeature_param) {return nand_set_features_op (chip, addr, subfeature_param);
@@ -4860,13 +4854,11 @@ static int nand_default_set_features(struct mtd_info *mtd,/** * nand_default_get_features- [REPLACEABLE] get NAND chip features -* @mtd: MTD device structure * @chip: nand chip info structure * @addr: feature address. * @subfeature_param: the subfeature parameters, a four bytes array. */ -static int nand_default_get_features (struct mtd_info *mtd, -struct nand_chip *chip,int addr, +static int nand_default_get_features (struct nand_chip *chip,int addr,uint8_t *subfeature_param) {return nand_get_features_op (chip, addr, subfeature_param);
@@ -4874,7 +4866,6 @@ static int nand_default_get_features(struct mtd_info *mtd,/** * nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP -* @mtd: MTD device structure * @chip: nand chip info structure * @addr: feature address. * @subfeature_param: the subfeature parameters, a four bytes array.
@@ -4882,8 +4873,8 @@ static int nand_default_get_features(struct mtd_info *mtd,* Should be used by NAND controller drivers that do not support the SET/GET * FEATURES operations. */ -int nand_get_set_features_notsupp (struct mtd_info *mtd,struct nand_chip *chip, -int addr,u8 *subfeature_param) +int nand_get_set_features_notsupp (struct nand_chip *chip,int addr, +u8 *subfeature_param) {return -ENOTSUPP ; }
include/linux/mtd/rawnand.h +6 -6
@@ -1299,10 +1299,10 @@ struct nand_chip {const struct nand_operation *op, bool check_only);int (*erase)(struct nand_chip *chip,int page); -int (*set_features)(struct mtd_info *mtd,struct nand_chip *chip, -int feature_addr,uint8_t *subfeature_para); -int (*get_features)(struct mtd_info *mtd,struct nand_chip *chip, -int feature_addr,uint8_t *subfeature_para); +int (*set_features)(struct nand_chip *chip,int feature_addr, +uint8_t *subfeature_para); +int (*get_features)(struct nand_chip *chip,int feature_addr, +uint8_t *subfeature_para);int (*setup_read_retry)(struct mtd_info *mtd,int retry_mode);int (*setup_data_interface)(struct mtd_info *mtd,int chipnr,const struct nand_data_interface *conf);
@@ -1681,8 +1681,8 @@ int nand_read_oob_syndrome(struct nand_chip *chip, int page);int nand_get_features (struct nand_chip *chip,int addr,u8 *subfeature_param);int nand_set_features (struct nand_chip *chip,int addr,u8 *subfeature_param);/* Stub used by drivers that do not support GET/SET FEATURES operations */ -int nand_get_set_features_notsupp (struct mtd_info *mtd,struct nand_chip *chip, -int addr,u8 *subfeature_param); +int nand_get_set_features_notsupp (struct nand_chip *chip,int addr, +u8 *subfeature_param);/* Default read_page_raw implementation */ int nand_read_page_raw(struct nand_chip *chip, uint8_t *buf, int oob_required,
Signature · 1 line
2.14.1
PATCH v2 20/23 mtd: rawnand: Pass a nand_chip object to chip->setup_read_retry()
In reply to Boris BrezillonLet's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed.
Let's tackle the chip->setup_read_retry() hook.
--- drivers/mtd/nand/raw/nand_base.c | 12 +++++------- drivers/mtd/nand/raw/nand_hynix.c | 3 +-- drivers/mtd/nand/raw/nand_micron.c | 3 +-- include/linux/mtd/rawnand.h | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-)
drivers/mtd/nand/raw/nand_base.c +5 -7
@@ -3475,17 +3475,15 @@ static uint8_t *nand_transfer_oob(struct mtd_info *mtd, uint8_t *oob,/** * nand_setup_read_retry - [INTERN] Set the READ RETRY mode -* @mtd: MTD device structure +* @chip: NAND chip object * @retry_mode: the retry mode to use * * Some vendors supply a special command to shift the Vt threshold, to be used * when there are too many bitflips in a page (i.e., ECC error). After setting * a new threshold, the host should retry reading the page. */ -static int nand_setup_read_retry (struct mtd_info *mtd,int retry_mode) +static int nand_setup_read_retry (struct nand_chip *chip,int retry_mode) { -struct nand_chip *chip =mtd_to_nand (mtd); -pr_debug ("setting READ RETRY mode %d\n" , retry_mode);if (retry_mode >= chip->read_retries)
@@ -3494,7 +3492,7 @@ static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)if (!chip->setup_read_retry)return -EOPNOTSUPP ; -return chip->setup_read_retry (mtd, retry_mode); +return chip->setup_read_retry (chip, retry_mode); }static void nand_wait_readrdy (struct nand_chip *chip)
@@ -3619,7 +3617,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,if (mtd->ecc_stats.failed - ecc_failures) {if (retry_mode +1 < chip->read_retries) { retry_mode++; - ret =nand_setup_read_retry (mtd, + ret =nand_setup_read_retry (chip, retry_mode);if (ret <0 )break ;
@@ -3646,7 +3644,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,/* Reset to retry mode 0 */ if (retry_mode) { - ret =nand_setup_read_retry (mtd,0 ); + ret =nand_setup_read_retry (chip,0 );if (ret <0 )break ; retry_mode =0 ;
drivers/mtd/nand/raw/nand_hynix.c +1 -2
@@ -113,9 +113,8 @@ static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val)return 0 ; } -static int hynix_nand_setup_read_retry (struct mtd_info *mtd,int retry_mode) +static int hynix_nand_setup_read_retry (struct nand_chip *chip,int retry_mode) { -struct nand_chip *chip =mtd_to_nand (mtd);struct hynix_nand *hynix =nand_get_manufacturer_data (chip);const u8 *values;int i, ret;
drivers/mtd/nand/raw/nand_micron.c +1 -2
@@ -74,9 +74,8 @@ struct micron_nand {struct micron_on_die_ecc ecc; }; -static int micron_nand_setup_read_retry (struct mtd_info *mtd,int retry_mode) +static int micron_nand_setup_read_retry (struct nand_chip *chip,int retry_mode) { -struct nand_chip *chip =mtd_to_nand (mtd);u8 feature[ONFI_SUBFEATURE_PARAM_LEN ] = {retry_mode};return nand_set_features (chip,ONFI_FEATURE_ADDR_READ_RETRY , feature);
include/linux/mtd/rawnand.h +1 -1
@@ -1303,7 +1303,7 @@ struct nand_chip { uint8_t *subfeature_para);int (*get_features)(struct nand_chip *chip,int feature_addr,uint8_t *subfeature_para); -int (*setup_read_retry)(struct mtd_info *mtd,int retry_mode); +int (*setup_read_retry)(struct nand_chip *chip,int retry_mode);int (*setup_data_interface)(struct mtd_info *mtd,int chipnr,const struct nand_data_interface *conf);
Signature · 1 line
2.14.1