mtd: rawnand: Take check_only into account
authorBoris Brezillon <boris.brezillon@collabora.com>
Sat, 18 Apr 2020 19:42:17 +0000 (21:42 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Sun, 10 May 2020 19:16:01 +0000 (21:16 +0200)
->exec_op() is passed a check_only argument that encodes when the
controller should just check whether the operation is supported or not
without executing it. Some controllers simply ignore this arguments,
others don't but keep modifying some of the registers before returning.
Let's fix all those drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200418194217.1016060-1-boris.brezillon@collabora.com
drivers/mtd/nand/raw/cadence-nand-controller.c
drivers/mtd/nand/raw/fsmc_nand.c
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
drivers/mtd/nand/raw/marvell_nand.c
drivers/mtd/nand/raw/meson_nand.c
drivers/mtd/nand/raw/mxic_nand.c
drivers/mtd/nand/raw/nandsim.c
drivers/mtd/nand/raw/stm32_fmc2_nand.c
drivers/mtd/nand/raw/sunxi_nand.c
drivers/mtd/nand/raw/tegra_nand.c
drivers/mtd/nand/raw/vf610_nfc.c

index acc0a24e58166b2073720fefcb171a18d9dc9517..e7abb15c7253654b92708d17f78a397bfb714514 100644 (file)
@@ -2223,10 +2223,12 @@ static int cadence_nand_exec_op(struct nand_chip *chip,
                                const struct nand_operation *op,
                                bool check_only)
 {
-       int status = cadence_nand_select_target(chip);
+       if (!check_only) {
+               int status = cadence_nand_select_target(chip);
 
-       if (status)
-               return status;
+               if (status)
+                       return status;
+       }
 
        return nand_op_parser_exec_op(chip, &cadence_nand_op_parser, op,
                                      check_only);
index 7e28311dffcb18251da44fd84524a5c43d813a0a..31dc9fd0a94d98adcbff874733485931f3b18050 100644 (file)
@@ -608,6 +608,9 @@ static int fsmc_exec_op(struct nand_chip *chip, const struct nand_operation *op,
        unsigned int op_id;
        int i;
 
+       if (check_only)
+               return 0;
+
        pr_debug("Executing operation [%d instructions]:\n", op->ninstrs);
 
        for (op_id = 0; op_id < op->ninstrs; op_id++) {
index 53b00c841aec74f9841d6bb502250b2bf7b75920..cc4cb190968e573f6f5d3637781213fc08154983 100644 (file)
@@ -2408,6 +2408,9 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
        struct completion *completion;
        unsigned long to;
 
+       if (check_only)
+               return 0;
+
        this->ntransfers = 0;
        for (i = 0; i < GPMI_MAX_TRANSFERS; i++)
                this->transfers[i].direction = DMA_NONE;
index 179f0ca585f8547a140839b4a39c3fabfe095edc..343001250ccca141f5a3f631db841907746c5792 100644 (file)
@@ -2107,7 +2107,8 @@ static int marvell_nfc_exec_op(struct nand_chip *chip,
 {
        struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
 
-       marvell_nfc_select_target(chip, op->cs);
+       if (!check_only)
+               marvell_nfc_select_target(chip, op->cs);
 
        if (nfc->caps->is_nfcv2)
                return nand_op_parser_exec_op(chip, &marvell_nfcv2_op_parser,
index f6fb5c0e6255ce6d08a46dd2cc694bbe57d20a86..e961f7bebf0a8934c1812a43e9ae5edcb115bbcc 100644 (file)
@@ -899,6 +899,9 @@ static int meson_nfc_exec_op(struct nand_chip *nand,
        u32 op_id, delay_idle, cmd;
        int i;
 
+       if (check_only)
+               return 0;
+
        meson_nfc_select_chip(nand, op->cs);
        for (op_id = 0; op_id < op->ninstrs; op_id++) {
                instr = &op->instrs[op_id];
index ed7a4e021bf58bc2a2c73d557b0f44c355360792..5a5a5b3b546db168f2a865f1727e122a6ab6d554 100644 (file)
@@ -393,6 +393,9 @@ static int mxic_nfc_exec_op(struct nand_chip *chip,
        int ret = 0;
        unsigned int op_id;
 
+       if (check_only)
+               return 0;
+
        mxic_nfc_cs_enable(nfc);
        init_completion(&nfc->complete);
        for (op_id = 0; op_id < op->ninstrs; op_id++) {
index 1de03bb34e840d4f04383e648e97ac81d19ac3a3..23cda67a3f53ada86093e670162edd0359108319 100644 (file)
@@ -2144,6 +2144,9 @@ static int ns_exec_op(struct nand_chip *chip, const struct nand_operation *op,
        const struct nand_op_instr *instr = NULL;
        struct nandsim *ns = nand_get_controller_data(chip);
 
+       if (check_only)
+               return 0;
+
        ns->lines.ce = 1;
 
        for (op_id = 0; op_id < op->ninstrs; op_id++) {
index b6d45cd911aed99f34a72f85a0fbc355417f27b4..46b7d04e2c8746a8cbf2be56916b841dbfc9148a 100644 (file)
@@ -1365,13 +1365,13 @@ static int stm32_fmc2_exec_op(struct nand_chip *chip,
        unsigned int op_id, i;
        int ret;
 
+       if (check_only)
+               return 0;
+
        ret = stm32_fmc2_select_chip(chip, op->cs);
        if (ret)
                return ret;
 
-       if (check_only)
-               return ret;
-
        for (op_id = 0; op_id < op->ninstrs; op_id++) {
                instr = &op->instrs[op_id];
 
index 5f3e40b79fb1698f8c92cdddb04b44fdf5622077..18ac0b36abfa4534836944f755701356034c296a 100644 (file)
@@ -1907,7 +1907,8 @@ static int sunxi_nfc_exec_op(struct nand_chip *nand,
        struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
        const struct nand_op_parser *parser;
 
-       sunxi_nfc_select_chip(nand, op->cs);
+       if (!check_only)
+               sunxi_nfc_select_chip(nand, op->cs);
 
        if (sunxi_nand->sels[op->cs].rb >= 0)
                parser = &sunxi_nfc_op_parser;
index 3cc9a4c41443aa4b2205cf5ac522d27fc799fbb5..6a255ba0f2881e3508294412090b65aa92086dd4 100644 (file)
@@ -467,7 +467,9 @@ static int tegra_nand_exec_op(struct nand_chip *chip,
                              const struct nand_operation *op,
                              bool check_only)
 {
-       tegra_nand_select_target(chip, op->cs);
+       if (!check_only)
+               tegra_nand_select_target(chip, op->cs);
+
        return nand_op_parser_exec_op(chip, &tegra_nand_op_parser, op,
                                      check_only);
 }
index 6b399a75f9aecbc3e3cbf9c237c869d219cd0341..bd9e16de78a2943c6719055b02b4d3d279d37c49 100644 (file)
@@ -502,7 +502,9 @@ static int vf610_nfc_exec_op(struct nand_chip *chip,
                             const struct nand_operation *op,
                             bool check_only)
 {
-       vf610_nfc_select_target(chip, op->cs);
+       if (!check_only)
+               vf610_nfc_select_target(chip, op->cs);
+
        return nand_op_parser_exec_op(chip, &vf610_nfc_op_parser, op,
                                      check_only);
 }