]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
mtd: nand: Add page argument to write_page() etc.
authorScott Wood <oss@buserror.net>
Mon, 30 May 2016 18:57:57 +0000 (13:57 -0500)
committerScott Wood <oss@buserror.net>
Sat, 4 Jun 2016 01:27:48 +0000 (20:27 -0500)
This change is part of the Linux 4.6 sync.  It is being done before the
main sync patch in order to make it easier to address the issue across
all NAND drivers (many/most of which do not closely track their Linux
counterparts) separately from other merge issues.

Signed-off-by: Scott Wood <oss@buserror.net>
15 files changed:
drivers/mtd/nand/arasan_nfc.c
drivers/mtd/nand/atmel_nand.c
drivers/mtd/nand/davinci_nand.c
drivers/mtd/nand/denali.c
drivers/mtd/nand/fsl_elbc_nand.c
drivers/mtd/nand/fsl_ifc_nand.c
drivers/mtd/nand/lpc32xx_nand_mlc.c
drivers/mtd/nand/lpc32xx_nand_slc.c
drivers/mtd/nand/mxc_nand.c
drivers/mtd/nand/mxs_nand.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/pxa3xx_nand.c
drivers/mtd/nand/tegra_nand.c
drivers/mtd/nand/vf610_nfc.c
include/linux/mtd/nand.h

index 6f3b71e0563d0c6abaa8fd7840c9353c11945803..320cbaa859a1fb3fde9afecfc50fd94c0ad26eb3 100644 (file)
@@ -433,7 +433,8 @@ static void arasan_nand_fill_tx(const u8 *buf, int len)
 }
 
 static int arasan_nand_write_page_hwecc(struct mtd_info *mtd,
-               struct nand_chip *chip, const u8 *buf, int oob_required)
+               struct nand_chip *chip, const u8 *buf, int oob_required,
+               int page)
 {
        u32 reg_val, i, pktsize, pktnum;
        const u32 *bufptr = (const u32 *)buf;
index b1adff0e8069ec36fcd850c569d17450d1f43cc1..a81b96d28136f3f41979a688a2b25fed95235e23 100644 (file)
@@ -569,7 +569,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
 
 static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
                struct nand_chip *chip, const uint8_t *buf,
-               int oob_required)
+               int oob_required, int page)
 {
        struct atmel_nand_host *host = nand_get_controller_data(chip);
        uint32_t *eccpos = chip->ecc.layout->eccpos;
index 5e0c7bf503fb185e6afafb573c95f60088936655..be9d666b6824eb8bdeaae3168e0d68ca2ef7162b 100644 (file)
@@ -380,10 +380,13 @@ static int nand_davinci_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 
        chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
 
-       if (unlikely(raw))
-               status = chip->ecc.write_page_raw(mtd, chip, buf, oob_required);
-       else
-               status = chip->ecc.write_page(mtd, chip, buf, oob_required);
+       if (unlikely(raw)) {
+               status = chip->ecc.write_page_raw(mtd, chip, buf,
+                                                 oob_required, page);
+       } else {
+               status = chip->ecc.write_page(mtd, chip, buf,
+                                             oob_required, page);
+       }
 
        if (status < 0) {
                ret = status;
index d9bcd721f09e30f42ecea7cdea936015b6001838..3ae75451bea86acdc21a1f2d17948f88608fbbab 100644 (file)
@@ -866,7 +866,8 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * by write_page above.
  */
 static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-                               const uint8_t *buf, int oob_required)
+                               const uint8_t *buf, int oob_required,
+                               int page)
 {
        struct denali_nand_info *denali = mtd_to_denali(mtd);
 
@@ -890,7 +891,8 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * write_page() function above.
  */
 static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-                                       const uint8_t *buf, int oob_required)
+                                       const uint8_t *buf, int oob_required,
+                                       int page)
 {
        struct denali_nand_info *denali = mtd_to_denali(mtd);
 
index aafff67a5fbcc2dece5a2d59c9d1071e17028da0..f621f141223360a263d0727c907adc13685e9f06 100644 (file)
@@ -611,7 +611,8 @@ static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  * waitfunc.
  */
 static int fsl_elbc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-                               const uint8_t *buf, int oob_required)
+                               const uint8_t *buf, int oob_required,
+                               int page)
 {
        fsl_elbc_write_buf(mtd, buf, mtd->writesize);
        fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -626,7 +627,7 @@ static struct fsl_elbc_ctrl *elbc_ctrl;
  */
 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)
+                               const uint8_t *buf, int oob_required, int page)
 {
        fsl_elbc_write_buf(mtd, buf, mtd->writesize);
        fsl_elbc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
index f28602e14fbc26ca8c58fb5088c3ad01f4894ab2..7001cbd62d0dc3b28530e9f2091d433f8eeb943b 100644 (file)
@@ -755,7 +755,7 @@ static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  * waitfunc.
  */
 static int fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-                              const uint8_t *buf, int oob_required)
+                              const uint8_t *buf, int oob_required, int page)
 {
        fsl_ifc_write_buf(mtd, buf, mtd->writesize);
        fsl_ifc_write_buf(mtd, chip->oob_poi, mtd->oobsize);
index 9475208918939e54b2342e8ac97aa3957d5bccc1..426202981960be206665abdb6027e1c5d152322d 100644 (file)
@@ -378,7 +378,8 @@ static int lpc32xx_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
  */
 
 static int lpc32xx_write_page_hwecc(struct mtd_info *mtd,
-       struct nand_chip *chip, const uint8_t *buf, int oob_required)
+       struct nand_chip *chip, const uint8_t *buf, int oob_required,
+       int page)
 {
        unsigned int i, status, timeout;
        struct lpc32xx_oob *oob = (struct lpc32xx_oob *)chip->oob_poi;
@@ -435,7 +436,8 @@ static int lpc32xx_write_page_hwecc(struct mtd_info *mtd,
  */
 
 static int lpc32xx_write_page_raw(struct mtd_info *mtd,
-       struct nand_chip *chip, const uint8_t *buf, int oob_required)
+       struct nand_chip *chip, const uint8_t *buf, int oob_required,
+       int page)
 {
        unsigned int i;
        struct lpc32xx_oob *oob = (struct lpc32xx_oob *)chip->oob_poi;
index 89b48cbed01636edcb3c5ed869ec28252709eb36..daa1e7a501dd547effe937b4d33cb55b3e517e9e 100644 (file)
@@ -486,7 +486,8 @@ static int lpc32xx_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
 /* Reuse the logic from "nand_write_page_hwecc()" */
 static int lpc32xx_write_page_hwecc(struct mtd_info *mtd,
                                    struct nand_chip *chip,
-                                   const uint8_t *buf, int oob_required)
+                                   const uint8_t *buf, int oob_required,
+                                   int page)
 {
        int i;
        uint8_t *ecc_calc = chip->buffers->ecccalc;
index f935055afd6038cb598f3a600a065fe8d4693d0c..d4e14b590a2a3e1c3f32b9c0816b690b8d4b62f0 100644 (file)
@@ -576,7 +576,7 @@ static int mxc_nand_write_oob_syndrome(struct mtd_info *mtd,
 static int mxc_nand_write_page_raw_syndrome(struct mtd_info *mtd,
                                             struct nand_chip *chip,
                                             const uint8_t *buf,
-                                            int oob_required)
+                                            int oob_required, int page)
 {
        struct mxc_nand_host *host = nand_get_controller_data(chip);
        int eccsize = chip->ecc.size;
@@ -616,7 +616,7 @@ static int mxc_nand_write_page_raw_syndrome(struct mtd_info *mtd,
 static int mxc_nand_write_page_syndrome(struct mtd_info *mtd,
                                         struct nand_chip *chip,
                                         const uint8_t *buf,
-                                        int oob_required)
+                                        int oob_required, int page)
 {
        struct mxc_nand_host *host = nand_get_controller_data(chip);
        int i, n, eccsize = chip->ecc.size;
index 7053ff263042d643bb564672dfbf930df521feea..5291330b911c9824f587b6fc714e269bb31766ca 100644 (file)
@@ -707,7 +707,7 @@ rtn:
  */
 static int mxs_nand_ecc_write_page(struct mtd_info *mtd,
                                struct nand_chip *nand, const uint8_t *buf,
-                               int oob_required)
+                               int oob_required, int page)
 {
        struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
index 92f581edd949dcb7c49a301712d73d95f8918116..62e70a72aa68ed980a61d6a5a945329221c2b1c1 100644 (file)
@@ -1840,11 +1840,13 @@ out:
  * @chip: nand chip info structure
  * @buf: data buffer
  * @oob_required: must write chip->oob_poi to OOB
+ * @page: page number to write
  *
  * Not for syndrome calculating ECC controllers, which use a special oob layout.
  */
 static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
-                               const uint8_t *buf, int oob_required)
+                               const uint8_t *buf, int oob_required,
+                               int page)
 {
        chip->write_buf(mtd, buf, mtd->writesize);
        if (oob_required)
@@ -1864,7 +1866,8 @@ static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  */
 static int nand_write_page_raw_syndrome(struct mtd_info *mtd,
                                        struct nand_chip *chip,
-                                       const uint8_t *buf, int oob_required)
+                                       const uint8_t *buf, int oob_required,
+                                       int page)
 {
        int eccsize = chip->ecc.size;
        int eccbytes = chip->ecc.bytes;
@@ -1901,9 +1904,11 @@ static int nand_write_page_raw_syndrome(struct mtd_info *mtd,
  * @chip: nand chip info structure
  * @buf: data buffer
  * @oob_required: must write chip->oob_poi to OOB
+ * @page: page number to write
  */
 static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
-                                 const uint8_t *buf, int oob_required)
+                                 const uint8_t *buf, int oob_required,
+                                 int page)
 {
        int i, eccsize = chip->ecc.size;
        int eccbytes = chip->ecc.bytes;
@@ -1919,7 +1924,7 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
        for (i = 0; i < chip->ecc.total; i++)
                chip->oob_poi[eccpos[i]] = ecc_calc[i];
 
-       return chip->ecc.write_page_raw(mtd, chip, buf, 1);
+       return chip->ecc.write_page_raw(mtd, chip, buf, 1, page);
 }
 
 /**
@@ -1928,9 +1933,11 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,
  * @chip: nand chip info structure
  * @buf: data buffer
  * @oob_required: must write chip->oob_poi to OOB
+ * @page: page number to write
  */
 static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
-                                 const uint8_t *buf, int oob_required)
+                                 const uint8_t *buf, int oob_required,
+                                 int page)
 {
        int i, eccsize = chip->ecc.size;
        int eccbytes = chip->ecc.bytes;
@@ -1962,11 +1969,12 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
  * @data_len:  data length
  * @buf:       data buffer
  * @oob_required: must write chip->oob_poi to OOB
+ * @page: page number to write
  */
 static int nand_write_subpage_hwecc(struct mtd_info *mtd,
                                struct nand_chip *chip, uint32_t offset,
                                uint32_t data_len, const uint8_t *buf,
-                               int oob_required)
+                               int oob_required, int page)
 {
        uint8_t *oob_buf  = chip->oob_poi;
        uint8_t *ecc_calc = chip->buffers->ecccalc;
@@ -2027,7 +2035,8 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,
  */
 static int nand_write_page_syndrome(struct mtd_info *mtd,
                                    struct nand_chip *chip,
-                                   const uint8_t *buf, int oob_required)
+                                   const uint8_t *buf, int oob_required,
+                                   int page)
 {
        int i, eccsize = chip->ecc.size;
        int eccbytes = chip->ecc.bytes;
@@ -2091,12 +2100,13 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 
        if (unlikely(raw))
                status = chip->ecc.write_page_raw(mtd, chip, buf,
-                                                       oob_required);
+                                                 oob_required, page);
        else if (subpage)
                status = chip->ecc.write_subpage(mtd, chip, offset, data_len,
-                                                        buf, oob_required);
+                                                 buf, oob_required, page);
        else
-               status = chip->ecc.write_page(mtd, chip, buf, oob_required);
+               status = chip->ecc.write_page(mtd, chip, buf, oob_required,
+                                             page);
 
        if (status < 0)
                return status;
@@ -2135,6 +2145,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * @oob: oob data buffer
  * @len: oob data write length
  * @ops: oob ops structure
+ * @page: page number to write
  */
 static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len,
                              struct mtd_oob_ops *ops)
index 03bf0468f1426874a2efb453994c2975f34c704e..d3ac5391f156e84fce4134fb22f8f01303206b90 100644 (file)
@@ -1081,7 +1081,8 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd,
 }
 
 static int pxa3xx_nand_write_page_hwecc(struct mtd_info *mtd,
-               struct nand_chip *chip, const uint8_t *buf, int oob_required)
+               struct nand_chip *chip, const uint8_t *buf, int oob_required,
+               int page)
 {
        chip->write_buf(mtd, buf, mtd->writesize);
        chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
index 3eae4cbee20cc9a79fbcc6e369d6bbe7877911d4..2032f658129c5b5608d2f5d8b433bc5fb565c10f 100644 (file)
@@ -657,16 +657,9 @@ static int nand_read_page_hwecc(struct mtd_info *mtd,
  * @param buf  data buffer
  */
 static int nand_write_page_hwecc(struct mtd_info *mtd,
-       struct nand_chip *chip, const uint8_t *buf, int oob_required)
+       struct nand_chip *chip, const uint8_t *buf, int oob_required,
+       int page)
 {
-       int page;
-       struct nand_drv *info;
-
-       info = (struct nand_drv *)nand_get_controller_data(chip);
-
-       page = (readl(&info->reg->addr_reg1) >> 16) |
-               (readl(&info->reg->addr_reg2) << 16);
-
        nand_rw_page(mtd, chip, (uint8_t *)buf, page, 1, 1);
        return 0;
 }
@@ -697,15 +690,9 @@ static int nand_read_page_raw(struct mtd_info *mtd,
  * @param buf  data buffer
  */
 static int nand_write_page_raw(struct mtd_info *mtd,
-               struct nand_chip *chip, const uint8_t *buf, int oob_required)
+               struct nand_chip *chip, const uint8_t *buf,
+               int oob_required, int page)
 {
-       int page;
-       struct nand_drv *info;
-
-       info = (struct nand_drv *)nand_get_controller_data(chip);
-       page = (readl(&info->reg->addr_reg1) >> 16) |
-               (readl(&info->reg->addr_reg2) << 16);
-
        nand_rw_page(mtd, chip, (uint8_t *)buf, page, 0, 1);
        return 0;
 }
index a4d5a6205f38566f3647a6b05ca237229104a877..dfbefc6bb901c870b0fe8f16ce612fe757573891 100644 (file)
@@ -607,7 +607,7 @@ static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  * ECC will be calculated automatically
  */
 static int vf610_nfc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-                              const uint8_t *buf, int oob_required)
+                              const uint8_t *buf, int oob_required, int page)
 {
        struct vf610_nfc *nfc = mtd_to_nfc(mtd);
 
index e1df66b62570fab86d6ccd96ab06fadcf414e431..34945fda7021113e844a9f7cec7eebec0fe77807 100644 (file)
@@ -519,16 +519,16 @@ struct nand_ecc_ctrl {
        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,
-                       const uint8_t *buf, int oob_required);
+                       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 (*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);
+                       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);
+                       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,