]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtd: rawnand: Pass a nand_chip object to chip->read_xxx() hooks
authorBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 6 Sep 2018 12:05:22 +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.

Let's tackle all chip->read_xxx() hooks at once.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
42 files changed:
drivers/mtd/nand/raw/ams-delta.c
drivers/mtd/nand/raw/atmel/nand-controller.c
drivers/mtd/nand/raw/au1550nd.c
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
drivers/mtd/nand/raw/brcmnand/brcmnand.c
drivers/mtd/nand/raw/cafe_nand.c
drivers/mtd/nand/raw/cmx270_nand.c
drivers/mtd/nand/raw/cs553x_nand.c
drivers/mtd/nand/raw/davinci_nand.c
drivers/mtd/nand/raw/denali.c
drivers/mtd/nand/raw/diskonchip.c
drivers/mtd/nand/raw/docg4.c
drivers/mtd/nand/raw/fsl_elbc_nand.c
drivers/mtd/nand/raw/fsl_ifc_nand.c
drivers/mtd/nand/raw/fsl_upm.c
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
drivers/mtd/nand/raw/hisi504_nand.c
drivers/mtd/nand/raw/lpc32xx_slc.c
drivers/mtd/nand/raw/mpc5121_nfc.c
drivers/mtd/nand/raw/mtk_nand.c
drivers/mtd/nand/raw/mxc_nand.c
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/nandsim.c
drivers/mtd/nand/raw/ndfc.c
drivers/mtd/nand/raw/nuc900_nand.c
drivers/mtd/nand/raw/omap2.c
drivers/mtd/nand/raw/orion_nand.c
drivers/mtd/nand/raw/oxnas_nand.c
drivers/mtd/nand/raw/pasemi_nand.c
drivers/mtd/nand/raw/plat_nand.c
drivers/mtd/nand/raw/qcom_nandc.c
drivers/mtd/nand/raw/r852.c
drivers/mtd/nand/raw/s3c2410.c
drivers/mtd/nand/raw/sh_flctl.c
drivers/mtd/nand/raw/socrates_nand.c
drivers/mtd/nand/raw/sunxi_nand.c
drivers/mtd/nand/raw/tango_nand.c
drivers/mtd/nand/raw/tmio_nand.c
drivers/mtd/nand/raw/txx9ndfmc.c
drivers/mtd/nand/raw/xway_nand.c
drivers/staging/mt29f_spinand/mt29f_spinand.c
include/linux/mtd/rawnand.h

index acf7971e815dfb5548ef91809ed8dc861e2bc980..eb48c939c4ae77900a3c56821998c58852c9e9b9 100644 (file)
@@ -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);
 }
 
 /*
index 3ebe9b727315a447f28c20bc646eb012e2f9f5be..371223e19dcc3c3242e498061ed284a00ab1f978 100644 (file)
@@ -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);
 
index d277a141c7d36cb4937b690ed833c9190c4e5ed3..76ea4141eb1056b2fb8925871a70a8959094557c 100644 (file)
@@ -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);
index 7022ffd271ad09a82680145e817721642b80d586..cf3e45358c60480777e28c83f9efcd5584afc7bf 100644 (file)
@@ -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;
        }
 
index d8fb2b5c19c9c07a42937834a3541396227da78d..7cbc6045f16d97516906a2a96e16f330745d5016 100644 (file)
@@ -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,
index fe7c7db3cfe7d2878df086ed988532badbc202ca..97d835f88b86f8afb864ecf684c2bb82e4be8e79 100644 (file)
@@ -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];
index 2eb933a8f99eb77028cafcf9194e28ced5b95f31..232d32391b1f298ad2fbdffa89fdc64392a9f7a1 100644 (file)
@@ -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;
index 193c3e8fa118bf325d1e10bbbc6d2cbc25438c5c..4394eeebec7ff8d8003fe31d880f14c38703741b 100644 (file)
 #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);
 }
 
index c80b6c6da4aa82c1dfa67612a7da8f5773e0cb44..b879049e51c6064eb3f85c91ae40eb8e6d2c3063 100644 (file)
@@ -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)
index 52fe5115ed6e6bbc5493235a37302f4fb45c3b3d..6e5be3efcb5d670045c4d0574bd7a81eba1a222f 100644 (file)
@@ -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;
 }
index 142d21be874eb6955df1f027f3d31e4c52ea6205..de1059069e8fbd3b4f32af91474f6394c30cd7ce 100644 (file)
@@ -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 le
                printk("\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 colu
                WriteDOC(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 */
index 37935fd0402068d9a021beeae7e2245366e55e0c..284bc96dacd30eaf59900003edafb15591a47131 100644 (file)
@@ -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);
index c992d7ad39d9e8adab8fbce96b1c310b712d445a..22326bcb8b62258cabd8c5fa45bcdd82b13f35d2 100644 (file)
@@ -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++;
index 945f3dab7ebfb9075e3dc4dace50374e38ad06e5..7b6d0913a5bb6d3150e947bb93f64a740e9cbde7 100644 (file)
@@ -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);
        }
index ffddfc9721ac4dc900a946b477bcd51a8d2aaaea..340547f1b6c7dc94bdc3f30f1955377da6f98162 100644 (file)
@@ -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++)
index 09f33f6006a3c7a083fc49129a23ac45a5c9fdaf..d0d5caa1b7a6a3fe5a0b28073225f18c34bb7ab8 100644 (file)
@@ -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);
 
                /*
index fab3c7fcf77b49e60cb9e51f24c3f1abb93f7683..e1fe6963c90861cc010cc8dba812b17a66afab9f 100644 (file)
@@ -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) {
index 6e4017ddacad7d4930115c6827bb4ac83905e11e..5820c86cb1f1e4d145bc83c109f002eb40ebc92f 100644 (file)
@@ -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;
 }
index 3c90d6955476408d696ba6c496725d117c9bbb09..49031f5a3b6d63b9285ae815b9bb7835ada5ed0b 100644 (file)
@@ -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;
 }
index c338a964643384533db2c583e638f17fc32c6a45..1c7392242d4d463be0f3924be37463727693e53f 100644 (file)
@@ -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)
index 597c74ea7e5e217192ffdceb4df192d27aab4c9b..8fed2919f35eaf869388ab7b69495c0babe5f3a5 100644 (file)
@@ -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;
 }
index cc386ee64a1b379933434e736896f55f7932d74a..e4686078011d2c7e1327d7dda139f1ab164ff767 100644 (file)
@@ -254,26 +254,24 @@ static void nand_release_device(struct mtd_info *mtd)
 
 /**
  * nand_read_byte - [DEFAULT] read one byte from the chip
- * @mtd: MTD device structure
+ * @chip: NAND chip object
  *
  * Default read function for 8bit buswidth
  */
-static uint8_t nand_read_byte(struct mtd_info *mtd)
+static uint8_t nand_read_byte(struct nand_chip *chip)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        return readb(chip->IO_ADDR_R);
 }
 
 /**
  * nand_read_byte16 - [DEFAULT] read one byte endianness aware from the chip
- * @mtd: MTD device structure
+ * @chip: NAND chip object
  *
  * Default read function for 16bit buswidth with endianness conversion.
  *
  */
-static uint8_t nand_read_byte16(struct mtd_info *mtd)
+static uint8_t nand_read_byte16(struct nand_chip *chip)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R));
 }
 
@@ -362,16 +360,14 @@ static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 
 /**
  * nand_read_buf - [DEFAULT] read chip data into buffer
- * @mtd: MTD device structure
+ * @chip: NAND chip object
  * @buf: buffer to store date
  * @len: number of bytes to read
  *
  * Default read function for 8bit buswidth.
  */
-static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+static void nand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
-
        ioread8_rep(chip->IO_ADDR_R, buf, len);
 }
 
@@ -393,15 +389,14 @@ static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
 
 /**
  * nand_read_buf16 - [DEFAULT] read chip data into buffer
- * @mtd: MTD device structure
+ * @chip: NAND chip object
  * @buf: buffer to store date
  * @len: number of bytes to read
  *
  * Default read function for 16bit buswidth.
  */
-static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
+static void nand_read_buf16(struct nand_chip *chip, uint8_t *buf, int len)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        u16 *p = (u16 *) buf;
 
        ioread16_rep(chip->IO_ADDR_R, p, len >> 1);
@@ -1544,7 +1539,7 @@ int nand_read_page_op(struct nand_chip *chip, unsigned int page,
 
        chip->cmdfunc(mtd, NAND_CMD_READ0, offset_in_page, page);
        if (len)
-               chip->read_buf(mtd, buf, len);
+               chip->read_buf(chip, buf, len);
 
        return 0;
 }
@@ -1593,7 +1588,7 @@ static int nand_read_param_page_op(struct nand_chip *chip, u8 page, void *buf,
 
        chip->cmdfunc(mtd, NAND_CMD_PARAM, page, -1);
        for (i = 0; i < len; i++)
-               p[i] = chip->read_byte(mtd);
+               p[i] = chip->read_byte(chip);
 
        return 0;
 }
@@ -1656,7 +1651,7 @@ int nand_change_read_column_op(struct nand_chip *chip,
 
        chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset_in_page, -1);
        if (len)
-               chip->read_buf(mtd, buf, len);
+               chip->read_buf(chip, buf, len);
 
        return 0;
 }
@@ -1693,7 +1688,7 @@ int nand_read_oob_op(struct nand_chip *chip, unsigned int page,
 
        chip->cmdfunc(mtd, NAND_CMD_READOOB, offset_in_oob, page);
        if (len)
-               chip->read_buf(mtd, buf, len);
+               chip->read_buf(chip, buf, len);
 
        return 0;
 }
@@ -2009,7 +2004,7 @@ int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf,
        chip->cmdfunc(mtd, NAND_CMD_READID, addr, -1);
 
        for (i = 0; i < len; i++)
-               id[i] = chip->read_byte(mtd);
+               id[i] = chip->read_byte(chip);
 
        return 0;
 }
@@ -2048,7 +2043,7 @@ int nand_status_op(struct nand_chip *chip, u8 *status)
 
        chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
        if (status)
-               *status = chip->read_byte(mtd);
+               *status = chip->read_byte(chip);
 
        return 0;
 }
@@ -2229,7 +2224,7 @@ static int nand_get_features_op(struct nand_chip *chip, u8 feature,
 
        chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, feature, -1);
        for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
-               params[i] = chip->read_byte(mtd);
+               params[i] = chip->read_byte(chip);
 
        return 0;
 }
@@ -2304,8 +2299,6 @@ EXPORT_SYMBOL_GPL(nand_reset_op);
 int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
                      bool force_8bit)
 {
-       struct mtd_info *mtd = nand_to_mtd(chip);
-
        if (!len || !buf)
                return -EINVAL;
 
@@ -2325,9 +2318,9 @@ int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
                unsigned int i;
 
                for (i = 0; i < len; i++)
-                       p[i] = chip->read_byte(mtd);
+                       p[i] = chip->read_byte(chip);
        } else {
-               chip->read_buf(mtd, buf, len);
+               chip->read_buf(chip, buf, len);
        }
 
        return 0;
index e9f7b9e1aead24f46c586e87b56adce1df70e70b..04feb4e8d1126c1228686f0f9e8bf06535746388 100644 (file)
@@ -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;
        }
index 9241cfaab5acd35dabd7bb5224ac180f56ebdcfd..56bb1eaa5ef3ab7447d75c0350f9f0ef6d217dda 100644 (file)
@@ -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;
 
index 0c675b6c0b6ef92bc062b10497a1e99f2a2ebc63..3a88da5ec97f64c5f4882ec6c978d18b3d00eb67 100644 (file)
@@ -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);
index f1f8b6c1d6548fe3cf407444197458c89735b559..4f2e5cd8605063827e275e5b9d6d8d8242e9f65c 100644 (file)
@@ -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,
index 5c58d91ffaee62f8a2ebdf9e7cdf8e8d55bca67f..870eabe6fff834be058fbbdae38969f34e2e0131 100644 (file)
@@ -48,9 +48,8 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl
        writeb(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;
index 5bc180536320da2bf02b0247331a26ab2447ace7..6156abb30b7ad11d0a423565dfbf79ed5db13fa8 100644 (file)
@@ -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);
index c8e2ac04fb86f6ecda2c2c795c8f95b2b719d9e2..551e5db670bea5c3e336df596a2c5cfac3af1dd3 100644 (file)
@@ -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;
index 80e1a44f04650ab2220bca96b61c67796b1a1568..5193806923ba44a351d0e4db706c02b6cd59892b 100644 (file)
@@ -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;
index e0cec027572c503c98f23e86bd78909aa031be7b..63bb9f3fe23b3f7baa4e7286747b09f4df64dea7 100644 (file)
@@ -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);
 
index aa5516b3b45fdf1850659c3938f33de23afbd43c..07055bd657cda0bce803bc9c4eab74eedfb1e51f 100644 (file)
@@ -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)
index d57201d118d870997bfc2f41008b6fbc0438ac55..54c86ec612dd85bc14d8752b7003551e92def855 100644 (file)
@@ -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);
index bb58edd2bdf067a0f65af3c62e02fe93d7d536a1..6966a18f8ac46861cfc9114bbba1fdfe2fdee5d5 100644 (file)
@@ -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;
index 82ba371a8e18f47add5e4d8386956755e7656073..007e37680b88041a00285f35427e1062b65dfd07 100644 (file)
@@ -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;
 }
 
index 86d666c0c03c45dd2b6c941fae7faea09ed816c9..2a0e624eca6ce4e18f04548ef6d9a2129b605757 100644 (file)
@@ -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);
index 7c8f4754600211eec253dc7c025568d2f43144a1..20d6fa983a6b0e45c4dcab53436ad61dc14ee221 100644 (file)
@@ -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;
        }
 }
index 734ff29705ce0ad4013b935dc0398bc2fd2ff299..570ea045fbcef9a1cb3da984ca6a5d6a4053fd50 100644 (file)
@@ -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);
 }
index 3c69d834de62ace4dee2f554cef8e1cfb100cf89..c68b638c4fe849dd7b3dd48a0a08dcc6b475b06f 100644 (file)
@@ -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--)
index 1adb41acebfc3558ff779bc6b7a45c2ef3f5da2b..edbcfaa85ed88eae7ca33a0b11ae91447701c259 100644 (file)
@@ -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)
index 2b2f98efdb545614095ff00f957565d9884a27aa..644c91ff2734d0a9f9ccc893fc6cacf5f60e099f 100644 (file)
@@ -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;
index 527947e81447cedf688014161f1b27e3e2590c6a..f324a82fe6a218c02db09f9ceca752e58241f44c 100644 (file)
@@ -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);