mtd: rawnand: Deprecate ->{set,get}_features() hooks
authorBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 6 Sep 2018 22:38:40 +0000 (00:38 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 3 Oct 2018 09:12:25 +0000 (11:12 +0200)
Those hooks should be replaced by a proper ->exec_op() implementation.
Move them to the nand_legacy struct to make it clear.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
12 files changed:
drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
drivers/mtd/nand/raw/cafe_nand.c
drivers/mtd/nand/raw/fsl_elbc_nand.c
drivers/mtd/nand/raw/fsl_ifc_nand.c
drivers/mtd/nand/raw/hisi504_nand.c
drivers/mtd/nand/raw/mpc5121_nfc.c
drivers/mtd/nand/raw/mxc_nand.c
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/qcom_nandc.c
drivers/mtd/nand/raw/sh_flctl.c
drivers/staging/mt29f_spinand/mt29f_spinand.c
include/linux/mtd/rawnand.h

index 925d4cd..357bc75 100644 (file)
@@ -390,8 +390,8 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
        b47n->nand_chip.legacy.read_byte = bcm47xxnflash_ops_bcm4706_read_byte;
        b47n->nand_chip.legacy.read_buf = bcm47xxnflash_ops_bcm4706_read_buf;
        b47n->nand_chip.legacy.write_buf = bcm47xxnflash_ops_bcm4706_write_buf;
-       b47n->nand_chip.set_features = nand_get_set_features_notsupp;
-       b47n->nand_chip.get_features = nand_get_set_features_notsupp;
+       b47n->nand_chip.legacy.set_features = nand_get_set_features_notsupp;
+       b47n->nand_chip.legacy.get_features = nand_get_set_features_notsupp;
 
        nand_chip->chip_delay = 50;
        b47n->nand_chip.bbt_options = NAND_BBT_USE_FLASH;
index db62b12..e3f702b 100644 (file)
@@ -709,8 +709,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
        cafe->nand.legacy.read_buf = cafe_read_buf;
        cafe->nand.legacy.write_buf = cafe_write_buf;
        cafe->nand.select_chip = cafe_select_chip;
-       cafe->nand.set_features = nand_get_set_features_notsupp;
-       cafe->nand.get_features = nand_get_set_features_notsupp;
+       cafe->nand.legacy.set_features = nand_get_set_features_notsupp;
+       cafe->nand.legacy.get_features = nand_get_set_features_notsupp;
 
        cafe->nand.chip_delay = 0;
 
index 29f0832..c5f3aa9 100644 (file)
@@ -782,8 +782,8 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
        chip->select_chip = fsl_elbc_select_chip;
        chip->legacy.cmdfunc = fsl_elbc_cmdfunc;
        chip->legacy.waitfunc = fsl_elbc_wait;
-       chip->set_features = nand_get_set_features_notsupp;
-       chip->get_features = nand_get_set_features_notsupp;
+       chip->legacy.set_features = nand_get_set_features_notsupp;
+       chip->legacy.get_features = nand_get_set_features_notsupp;
 
        chip->bbt_td = &bbt_main_descr;
        chip->bbt_md = &bbt_mirror_descr;
index 682ae38..a303d12 100644 (file)
@@ -867,8 +867,8 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
        chip->select_chip = fsl_ifc_select_chip;
        chip->legacy.cmdfunc = fsl_ifc_cmdfunc;
        chip->legacy.waitfunc = fsl_ifc_wait;
-       chip->set_features = nand_get_set_features_notsupp;
-       chip->get_features = nand_get_set_features_notsupp;
+       chip->legacy.set_features = nand_get_set_features_notsupp;
+       chip->legacy.get_features = nand_get_set_features_notsupp;
 
        chip->bbt_td = &bbt_main_descr;
        chip->bbt_md = &bbt_mirror_descr;
index 6e17239..fee7d63 100644 (file)
@@ -788,8 +788,8 @@ static int hisi_nfc_probe(struct platform_device *pdev)
        chip->legacy.write_buf  = hisi_nfc_write_buf;
        chip->legacy.read_buf   = hisi_nfc_read_buf;
        chip->chip_delay        = HINFC504_CHIP_DELAY;
-       chip->set_features      = nand_get_set_features_notsupp;
-       chip->get_features      = nand_get_set_features_notsupp;
+       chip->legacy.set_features       = nand_get_set_features_notsupp;
+       chip->legacy.get_features       = nand_get_set_features_notsupp;
 
        hisi_nfc_host_init(host);
 
index 9a6dc78..86a0aab 100644 (file)
@@ -698,8 +698,8 @@ static int mpc5121_nfc_probe(struct platform_device *op)
        chip->legacy.read_buf = mpc5121_nfc_read_buf;
        chip->legacy.write_buf = mpc5121_nfc_write_buf;
        chip->select_chip = mpc5121_nfc_select_chip;
-       chip->set_features      = nand_get_set_features_notsupp;
-       chip->get_features      = nand_get_set_features_notsupp;
+       chip->legacy.set_features = nand_get_set_features_notsupp;
+       chip->legacy.get_features = nand_get_set_features_notsupp;
        chip->bbt_options = NAND_BBT_USE_FLASH;
        chip->ecc.mode = NAND_ECC_SOFT;
        chip->ecc.algo = NAND_ECC_HAMMING;
index ca074c9..b811510 100644 (file)
@@ -1778,8 +1778,8 @@ static int mxcnd_probe(struct platform_device *pdev)
        this->legacy.read_byte = mxc_nand_read_byte;
        this->legacy.write_buf = mxc_nand_write_buf;
        this->legacy.read_buf = mxc_nand_read_buf;
-       this->set_features = mxc_nand_set_features;
-       this->get_features = mxc_nand_get_features;
+       this->legacy.set_features = mxc_nand_set_features;
+       this->legacy.get_features = mxc_nand_get_features;
 
        host->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(host->clk))
index 57c89e2..d4a84a8 100644 (file)
@@ -1176,44 +1176,6 @@ static bool nand_supports_set_features(struct nand_chip *chip, int addr)
 }
 
 /**
- * nand_get_features - wrapper to perform a GET_FEATURE
- * @chip: NAND chip info structure
- * @addr: feature address
- * @subfeature_param: the subfeature parameters, a four bytes array
- *
- * Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
- * operation cannot be handled.
- */
-int nand_get_features(struct nand_chip *chip, int addr,
-                     u8 *subfeature_param)
-{
-       if (!nand_supports_get_features(chip, addr))
-               return -ENOTSUPP;
-
-       return chip->get_features(chip, addr, subfeature_param);
-}
-EXPORT_SYMBOL_GPL(nand_get_features);
-
-/**
- * nand_set_features - wrapper to perform a SET_FEATURE
- * @chip: NAND chip info structure
- * @addr: feature address
- * @subfeature_param: the subfeature parameters, a four bytes array
- *
- * Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
- * operation cannot be handled.
- */
-int nand_set_features(struct nand_chip *chip, int addr,
-                     u8 *subfeature_param)
-{
-       if (!nand_supports_set_features(chip, addr))
-               return -ENOTSUPP;
-
-       return chip->set_features(chip, addr, subfeature_param);
-}
-EXPORT_SYMBOL_GPL(nand_set_features);
-
-/**
  * nand_reset_data_interface - Reset data interface and timings
  * @chip: The NAND chip
  * @chipnr: Internal die id
@@ -2834,6 +2796,50 @@ int nand_reset(struct nand_chip *chip, int chipnr)
 EXPORT_SYMBOL_GPL(nand_reset);
 
 /**
+ * nand_get_features - wrapper to perform a GET_FEATURE
+ * @chip: NAND chip info structure
+ * @addr: feature address
+ * @subfeature_param: the subfeature parameters, a four bytes array
+ *
+ * Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
+ * operation cannot be handled.
+ */
+int nand_get_features(struct nand_chip *chip, int addr,
+                     u8 *subfeature_param)
+{
+       if (!nand_supports_get_features(chip, addr))
+               return -ENOTSUPP;
+
+       if (chip->legacy.get_features)
+               return chip->legacy.get_features(chip, addr, subfeature_param);
+
+       return nand_get_features_op(chip, addr, subfeature_param);
+}
+EXPORT_SYMBOL_GPL(nand_get_features);
+
+/**
+ * nand_set_features - wrapper to perform a SET_FEATURE
+ * @chip: NAND chip info structure
+ * @addr: feature address
+ * @subfeature_param: the subfeature parameters, a four bytes array
+ *
+ * Returns 0 for success, a negative error otherwise. Returns -ENOTSUPP if the
+ * operation cannot be handled.
+ */
+int nand_set_features(struct nand_chip *chip, int addr,
+                     u8 *subfeature_param)
+{
+       if (!nand_supports_set_features(chip, addr))
+               return -ENOTSUPP;
+
+       if (chip->legacy.set_features)
+               return chip->legacy.set_features(chip, addr, subfeature_param);
+
+       return nand_set_features_op(chip, addr, subfeature_param);
+}
+EXPORT_SYMBOL_GPL(nand_set_features);
+
+/**
  * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data
  * @buf: buffer to test
  * @len: buffer length
@@ -4865,30 +4871,6 @@ static int nand_max_bad_blocks(struct mtd_info *mtd, loff_t ofs, size_t len)
 }
 
 /**
- * nand_default_set_features- [REPLACEABLE] set NAND chip features
- * @chip: nand chip info structure
- * @addr: feature address.
- * @subfeature_param: the subfeature parameters, a four bytes array.
- */
-static int nand_default_set_features(struct nand_chip *chip, int addr,
-                                    uint8_t *subfeature_param)
-{
-       return nand_set_features_op(chip, addr, subfeature_param);
-}
-
-/**
- * nand_default_get_features- [REPLACEABLE] get NAND chip features
- * @chip: nand chip info structure
- * @addr: feature address.
- * @subfeature_param: the subfeature parameters, a four bytes array.
- */
-static int nand_default_get_features(struct nand_chip *chip, int addr,
-                                    uint8_t *subfeature_param)
-{
-       return nand_get_features_op(chip, addr, subfeature_param);
-}
-
-/**
  * nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP
  * @chip: nand chip info structure
  * @addr: feature address.
@@ -4958,12 +4940,6 @@ static void nand_set_defaults(struct nand_chip *chip)
        if (!chip->select_chip)
                chip->select_chip = nand_select_chip;
 
-       /* set for ONFI nand */
-       if (!chip->set_features)
-               chip->set_features = nand_default_set_features;
-       if (!chip->get_features)
-               chip->get_features = nand_default_get_features;
-
        /* If called twice, pointers that depend on busw may need to be reset */
        if (!chip->legacy.read_byte || chip->legacy.read_byte == nand_read_byte)
                chip->legacy.read_byte = busw ? nand_read_byte16 : nand_read_byte;
index 79342e2..ef75dfa 100644 (file)
@@ -2808,8 +2808,8 @@ static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc,
        chip->legacy.read_byte  = qcom_nandc_read_byte;
        chip->legacy.read_buf   = qcom_nandc_read_buf;
        chip->legacy.write_buf  = qcom_nandc_write_buf;
-       chip->set_features      = nand_get_set_features_notsupp;
-       chip->get_features      = nand_get_set_features_notsupp;
+       chip->legacy.set_features       = nand_get_set_features_notsupp;
+       chip->legacy.get_features       = nand_get_set_features_notsupp;
 
        /*
         * the bad block marker is readable only when we read the last codeword
index 71658fb..40a4159 100644 (file)
@@ -1185,8 +1185,8 @@ static int flctl_probe(struct platform_device *pdev)
        nand->legacy.read_buf = flctl_read_buf;
        nand->select_chip = flctl_select_chip;
        nand->legacy.cmdfunc = flctl_cmdfunc;
-       nand->set_features = nand_get_set_features_notsupp;
-       nand->get_features = nand_get_set_features_notsupp;
+       nand->legacy.set_features = nand_get_set_features_notsupp;
+       nand->legacy.get_features = nand_get_set_features_notsupp;
 
        if (pdata->flcmncr_val & SEL_16BIT)
                nand->options |= NAND_BUSWIDTH_16;
index fb28cc6..def8a1f 100644 (file)
@@ -922,8 +922,8 @@ static int spinand_probe(struct spi_device *spi_nand)
        chip->legacy.waitfunc   = spinand_wait;
        chip->options   |= NAND_CACHEPRG;
        chip->select_chip = spinand_select_chip;
-       chip->set_features = nand_get_set_features_notsupp;
-       chip->get_features = nand_get_set_features_notsupp;
+       chip->legacy.set_features = nand_get_set_features_notsupp;
+       chip->legacy.get_features = nand_get_set_features_notsupp;
 
        mtd = nand_to_mtd(chip);
 
index 97c6ff7..02ac70a 100644 (file)
@@ -1190,6 +1190,8 @@ int nand_op_parser_exec_op(struct nand_chip *chip,
  * @block_bad: check if a block is bad, using OOB markers
  * @block_markbad: mark a block bad
  * @erase: erase function
+ * @set_features: set the NAND chip features
+ * @get_features: get the NAND chip features
  *
  * If you look at this structure you're already wrong. These fields/hooks are
  * all deprecated.
@@ -1209,6 +1211,10 @@ struct nand_legacy {
        int (*block_bad)(struct nand_chip *chip, loff_t ofs);
        int (*block_markbad)(struct nand_chip *chip, loff_t ofs);
        int (*erase)(struct nand_chip *chip, int page);
+       int (*set_features)(struct nand_chip *chip, int feature_addr,
+                           u8 *subfeature_para);
+       int (*get_features)(struct nand_chip *chip, int feature_addr,
+                           u8 *subfeature_para);
 };
 
 /**
@@ -1279,8 +1285,6 @@ struct nand_legacy {
  * @blocks_per_die:    [INTERN] The number of PEBs in a die
  * @data_interface:    [INTERN] NAND interface timing information
  * @read_retries:      [INTERN] the number of read retry modes supported
- * @set_features:      [REPLACEABLE] set the NAND chip features
- * @get_features:      [REPLACEABLE] get the NAND chip features
  * @setup_data_interface: [OPTIONAL] setup the data interface and timing. If
  *                       chipnr is set to %NAND_DATA_IFACE_CHECK_ONLY this
  *                       means the configuration should not be applied but
@@ -1309,10 +1313,6 @@ struct nand_chip {
        int (*exec_op)(struct nand_chip *chip,
                       const struct nand_operation *op,
                       bool check_only);
-       int (*set_features)(struct nand_chip *chip, int feature_addr,
-                           uint8_t *subfeature_para);
-       int (*get_features)(struct nand_chip *chip, int feature_addr,
-                           uint8_t *subfeature_para);
        int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
        int (*setup_data_interface)(struct nand_chip *chip, int chipnr,
                                    const struct nand_data_interface *conf);