]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mtd: rawnand: Pass a nand_chip object to chip->setup_read_retry()
authorBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 6 Sep 2018 12:05:32 +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 the chip->setup_read_retry() hook.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/nand_hynix.c
drivers/mtd/nand/raw/nand_micron.c
include/linux/mtd/rawnand.h

index 0ae597ced5b420dbeaf5fd87c8e20e8daf8785fb..a7575aa68c4802b2fc31e796a11f0778b23b0c68 100644 (file)
@@ -3475,17 +3475,15 @@ static uint8_t *nand_transfer_oob(struct mtd_info *mtd, uint8_t *oob,
 
 /**
  * nand_setup_read_retry - [INTERN] Set the READ RETRY mode
- * @mtd: MTD device structure
+ * @chip: NAND chip object
  * @retry_mode: the retry mode to use
  *
  * Some vendors supply a special command to shift the Vt threshold, to be used
  * when there are too many bitflips in a page (i.e., ECC error). After setting
  * a new threshold, the host should retry reading the page.
  */
-static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)
+static int nand_setup_read_retry(struct nand_chip *chip, int retry_mode)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
-
        pr_debug("setting READ RETRY mode %d\n", retry_mode);
 
        if (retry_mode >= chip->read_retries)
@@ -3494,7 +3492,7 @@ static int nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)
        if (!chip->setup_read_retry)
                return -EOPNOTSUPP;
 
-       return chip->setup_read_retry(mtd, retry_mode);
+       return chip->setup_read_retry(chip, retry_mode);
 }
 
 static void nand_wait_readrdy(struct nand_chip *chip)
@@ -3619,7 +3617,7 @@ read_retry:
                        if (mtd->ecc_stats.failed - ecc_failures) {
                                if (retry_mode + 1 < chip->read_retries) {
                                        retry_mode++;
-                                       ret = nand_setup_read_retry(mtd,
+                                       ret = nand_setup_read_retry(chip,
                                                        retry_mode);
                                        if (ret < 0)
                                                break;
@@ -3646,7 +3644,7 @@ read_retry:
 
                /* Reset to retry mode 0 */
                if (retry_mode) {
-                       ret = nand_setup_read_retry(mtd, 0);
+                       ret = nand_setup_read_retry(chip, 0);
                        if (ret < 0)
                                break;
                        retry_mode = 0;
index fa873e5171316af192b7609daefe481b65ee736f..bb1c4f8ce785372f9182086b228722490706cdbe 100644 (file)
@@ -113,9 +113,8 @@ static int hynix_nand_reg_write_op(struct nand_chip *chip, u8 addr, u8 val)
        return 0;
 }
 
-static int hynix_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)
+static int hynix_nand_setup_read_retry(struct nand_chip *chip, int retry_mode)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct hynix_nand *hynix = nand_get_manufacturer_data(chip);
        const u8 *values;
        int i, ret;
index 2f26dbeb54284c80c0b79b1d391fe4a4befa8e3e..1a5505ccbe54b24c7c6d46f727951666049db650 100644 (file)
@@ -74,9 +74,8 @@ struct micron_nand {
        struct micron_on_die_ecc ecc;
 };
 
-static int micron_nand_setup_read_retry(struct mtd_info *mtd, int retry_mode)
+static int micron_nand_setup_read_retry(struct nand_chip *chip, int retry_mode)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        u8 feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode};
 
        return nand_set_features(chip, ONFI_FEATURE_ADDR_READ_RETRY, feature);
index 7c639070c512e4262430a39ab8ad66b422f6a41a..14ce2b0782060bbc80641cd94d9e655fa85f73ea 100644 (file)
@@ -1303,7 +1303,7 @@ struct nand_chip {
                            uint8_t *subfeature_para);
        int (*get_features)(struct nand_chip *chip, int feature_addr,
                            uint8_t *subfeature_para);
-       int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
+       int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
        int (*setup_data_interface)(struct mtd_info *mtd, int chipnr,
                                    const struct nand_data_interface *conf);