mtd: spi-nor: rename method for enabling or disabling octal DTR
authorTudor Ambarus <tudor.ambarus@linaro.org>
Fri, 14 Jul 2023 15:07:57 +0000 (18:07 +0300)
committerTudor Ambarus <tudor.ambarus@linaro.org>
Tue, 18 Jul 2023 17:40:51 +0000 (20:40 +0300)
Having an *_enable(..., bool enable) definition was misleading
as the method is used both to enable and to disable the octal DTR
mode. Splitting the method in the core in two, one to enable and
another to disable the octal DTR mode does not make sense as the
method is straight forward and we'd introduce code duplication.

Update the core to use:
int (*set_octal_dtr)(struct spi_nor *nor, bool enable);

Manufacturer drivers use different sequences of commands to enable
and disable the octal DTR mode, thus for clarity they shall
implement it as:
static int manufacturer_snor_set_octal_dtr(struct spi_nor *nor, bool enable)
{
return enable ? manufacturer_snor_octal_dtr_enable() :
manufacturer_snor_octal_dtr_disable();
}

Reviewed-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20230714150757.15372-1-tudor.ambarus@linaro.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/micron-st.c
drivers/mtd/spi-nor/spansion.c

index 434c545..273258f 100644 (file)
@@ -3090,17 +3090,17 @@ static int spi_nor_init_params(struct spi_nor *nor)
        return 0;
 }
 
-/** spi_nor_octal_dtr_enable() - enable Octal DTR I/O if needed
+/** spi_nor_set_octal_dtr() - enable or disable Octal DTR I/O.
  * @nor:                 pointer to a 'struct spi_nor'
  * @enable:              whether to enable or disable Octal DTR
  *
  * Return: 0 on success, -errno otherwise.
  */
-static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
+static int spi_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
 {
        int ret;
 
-       if (!nor->params->octal_dtr_enable)
+       if (!nor->params->set_octal_dtr)
                return 0;
 
        if (!(nor->read_proto == SNOR_PROTO_8_8_8_DTR &&
@@ -3110,7 +3110,7 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
        if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE))
                return 0;
 
-       ret = nor->params->octal_dtr_enable(nor, enable);
+       ret = nor->params->set_octal_dtr(nor, enable);
        if (ret)
                return ret;
 
@@ -3171,7 +3171,7 @@ static int spi_nor_init(struct spi_nor *nor)
 {
        int err;
 
-       err = spi_nor_octal_dtr_enable(nor, true);
+       err = spi_nor_set_octal_dtr(nor, true);
        if (err) {
                dev_dbg(nor->dev, "octal mode not supported\n");
                return err;
@@ -3273,7 +3273,7 @@ static int spi_nor_suspend(struct mtd_info *mtd)
        int ret;
 
        /* Disable octal DTR mode if we enabled it. */
-       ret = spi_nor_octal_dtr_enable(nor, false);
+       ret = spi_nor_set_octal_dtr(nor, false);
        if (ret)
                dev_err(nor->dev, "suspend() failed\n");
 
index 55b5e7a..f2fc2cf 100644 (file)
@@ -364,7 +364,7 @@ struct spi_nor_otp {
  * @erase_map:         the erase map parsed from the SFDP Sector Map Parameter
  *                      Table.
  * @otp:               SPI NOR OTP info.
- * @octal_dtr_enable:  enables SPI NOR octal DTR mode.
+ * @set_octal_dtr:     enables or disables SPI NOR octal DTR mode.
  * @quad_enable:       enables SPI NOR quad mode.
  * @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode.
  * @convert_addr:      converts an absolute address into something the flash
@@ -398,7 +398,7 @@ struct spi_nor_flash_parameter {
        struct spi_nor_erase_map        erase_map;
        struct spi_nor_otp              otp;
 
-       int (*octal_dtr_enable)(struct spi_nor *nor, bool enable);
+       int (*set_octal_dtr)(struct spi_nor *nor, bool enable);
        int (*quad_enable)(struct spi_nor *nor);
        int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable);
        u32 (*convert_addr)(struct spi_nor *nor, u32 addr);
index 4b91975..f79e71d 100644 (file)
@@ -120,7 +120,7 @@ static int micron_st_nor_octal_dtr_dis(struct spi_nor *nor)
        return 0;
 }
 
-static int micron_st_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
+static int micron_st_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
 {
        return enable ? micron_st_nor_octal_dtr_en(nor) :
                        micron_st_nor_octal_dtr_dis(nor);
@@ -128,7 +128,7 @@ static int micron_st_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
 
 static void mt35xu512aba_default_init(struct spi_nor *nor)
 {
-       nor->params->octal_dtr_enable = micron_st_nor_octal_dtr_enable;
+       nor->params->set_octal_dtr = micron_st_nor_set_octal_dtr;
 }
 
 static int mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)
index 36876aa..6d6466a 100644 (file)
@@ -607,7 +607,7 @@ static struct spi_nor_fixups s25hx_t_fixups = {
 };
 
 /**
- * cypress_nor_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
+ * cypress_nor_set_octal_dtr() - Enable or disable octal DTR on Cypress flashes.
  * @nor:               pointer to a 'struct spi_nor'
  * @enable:              whether to enable or disable Octal DTR
  *
@@ -616,7 +616,7 @@ static struct spi_nor_fixups s25hx_t_fixups = {
  *
  * Return: 0 on success, -errno otherwise.
  */
-static int cypress_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
+static int cypress_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
 {
        return enable ? cypress_nor_octal_dtr_en(nor) :
                        cypress_nor_octal_dtr_dis(nor);
@@ -667,7 +667,7 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
 
 static void s28hx_t_late_init(struct spi_nor *nor)
 {
-       nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable;
+       nor->params->set_octal_dtr = cypress_nor_set_octal_dtr;
        cypress_nor_ecc_init(nor);
 }