mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks
authorBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 6 Sep 2018 12:05:13 +0000 (14:05 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 3 Oct 2018 09:12:25 +0000 (11:12 +0200)
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.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Krzysztof Halasa <khalasa@piap.pl>
Acked-by: Paul Burton <paul.burton@mips.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
23 files changed:
arch/arm/mach-ep93xx/snappercl15.c
arch/arm/mach-ep93xx/ts72xx.c
arch/arm/mach-imx/mach-qong.c
arch/arm/mach-ixp4xx/ixdp425-setup.c
arch/arm/mach-omap1/board-fsample.c
arch/arm/mach-omap1/board-h2.c
arch/arm/mach-omap1/board-h3.c
arch/arm/mach-omap1/board-nand.c
arch/arm/mach-omap1/board-perseus2.c
arch/arm/mach-omap1/common.h
arch/arm/mach-orion5x/ts78xx-setup.c
arch/arm/mach-pxa/balloon3.c
arch/arm/mach-pxa/em-x270.c
arch/arm/mach-pxa/palmtx.c
arch/mips/alchemy/devboards/db1200.c
arch/mips/alchemy/devboards/db1300.c
arch/mips/alchemy/devboards/db1550.c
arch/mips/netlogic/xlr/platform-flash.c
arch/mips/pnx833x/common/platform.c
arch/mips/rb532/devices.c
arch/sh/boards/mach-migor/setup.c
drivers/mtd/nand/raw/plat_nand.c
include/linux/mtd/rawnand.h

index 45940c1d778789f3b76a5e465c787ab05b22682f..aa03ea79c5f53b4146954f16c60bce0e6c17b0ba 100644 (file)
 
 #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);
 }
 
index c089a2a4fe307150a3b4066b9bc7447aae8788bd..26259dd9e9511017422868a6c5ce0f5748547472 100644 (file)
@@ -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);
index 42a700053103ebf57b9682a5e6dc9da05629d8a7..ff015f603ac981239ffdd4d41e0cc8853d92baed 100644 (file)
@@ -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);
index 3ec829d52cdd2143a76113f9380cd54696b23395..7c39edc121ba25b2593962695f1b9707800581df 100644 (file)
@@ -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) {
index 69bd601feb83d8ff04e1b8f6bbf24bc3fd86b217..e9f512a0602e51555885e811969072e40153aab6 100644 (file)
@@ -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);
 }
index 9aeb8ad8c3270cb5761f2a82408f2ba96e9c1a63..d5dd2acd6f7840fb27bb4bd527ca03c3d7c8299e 100644 (file)
@@ -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);
 }
index 2edcd6356f2d635011d55b1e77f04ef44aa1cd13..a75856fe4259ecc2cf1df14839f189ddf060695a 100644 (file)
@@ -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);
 }
index 1bffbb4e050f2c1823cfaa18c7829deecad3c634..59d56a30bc63103c84d2862f3e31cc19561d579f 100644 (file)
@@ -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)
index b4951eb8289884549bb67f00e5a17bf8a05cab5e..c61c7c7520ca8833f539a8a7acc7b74fd11eb9d9 100644 (file)
@@ -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);
 }
index c6537d2c28597ac1f8296322085d591198d508f4..504b959ba5cfc8378bd54caf9d11bcb8a86591e3 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __ARCH_ARM_MACH_OMAP1_COMMON_H
 #define __ARCH_ARM_MACH_OMAP1_COMMON_H
 
-#include <linux/mtd/mtd.h>
 #include <linux/platform_data/i2c-omap.h>
 #include <linux/reboot.h>
 
@@ -82,7 +81,8 @@ 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,
+struct nand_chip;
+extern void omap1_nand_cmd_ctl(struct nand_chip *this, int cmd,
                               unsigned int ctrl);
 
 extern void omap1_timer_init(void);
index 94778739e38f0cbf85535525c478a19b2c12fbad..48d85ddf7c311234e2bc16797a2bffb24285d5d7 100644 (file)
@@ -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;
index af46d21825331ea5662a8aa042e814c93070f5e8..71fda90b95997a05102bffac70d1136a0ff853d8 100644 (file)
@@ -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 ct
                writeb(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;
 }
index 29be04c6cc4858f3e93b73a8083643578cbc51bc..ba1ec999283077e2bde1f3b990ba70bbce55ccf9 100644 (file)
@@ -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();
 
index 47e3e38e9becd229ad88b38ce90dcbeff1fa6035..ed9661e70b83eb420f60e02fd8645039d4c3af12 100644 (file)
@@ -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)
index da76637704253e3610f4f15b69a42e75af99d516..f043615c1a99e067936345b9a8e8d3636d89be4e 100644 (file)
@@ -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;
 }
index efb318e03e0a3d53163307d84c0d850c6a747869..1201fa655e78b0dc161d20601925f80859b87b89 100644 (file)
@@ -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;
 }
index 7d3dfaa10231754e8d3eb683c8ab2439e1192a9b..cae39cde5de6bd0b23fc62d28f1fa43267572c0e 100644 (file)
@@ -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;
 }
index 4d1b4c003376d1d0d196c623738e60f8d07826e4..4f76b85b44c9ab57c1dce6bfcf6e6d9925dac495 100644 (file)
@@ -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,
index a7a4e9f5146d8264fa5452ed744f3331345e810e..ca8a2889431e525121052d2ee5328ee55fee5559 100644 (file)
@@ -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)
index 354d258396ff993f32878941d8c01621b887c8d7..9173949892edb9bd64d17d75a00fb227ee06ebd3 100644 (file)
@@ -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) {
index 254f2c66270362845524352e5ad73a1b6bdecf9b..833f3e49027b63f5ae23a78d1f5623f40e11efc3 100644 (file)
@@ -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 */
 }
index 222626df4b96d396a3b7e23da144cc2bf7661ebe..24f904300c44f0cad6b5ff1b566bad87b0a9a651 100644 (file)
@@ -23,6 +23,42 @@ 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);
+
+       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);
+}
+
+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);
+}
+
+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.
  */
@@ -62,11 +98,22 @@ 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;
-       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;
+
+       if (pdata->ctrl.cmd_ctrl)
+               data->chip.cmd_ctrl = plat_nand_cmd_ctrl;
+
+       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;
+
+       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.chip_delay = pdata->chip.chip_delay;
        data->chip.options |= pdata->chip.options;
        data->chip.bbt_options |= pdata->chip.bbt_options;
index d155470f53c8a5c78ec0c370c60db583cf006baa..818cdc0a4dbbee2fda070276e1558fdc9b4ab219 100644 (file)
@@ -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;
 };