Skip to content

Commit d499670

Browse files
committed
mtd: spi-nor: rename method for enabling or disabling octal DTR
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tudor Ambarus <[email protected]>
1 parent 83e824a commit d499670

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

drivers/mtd/spi-nor/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,17 +3090,17 @@ static int spi_nor_init_params(struct spi_nor *nor)
30903090
return 0;
30913091
}
30923092

3093-
/** spi_nor_octal_dtr_enable() - enable Octal DTR I/O if needed
3093+
/** spi_nor_set_octal_dtr() - enable or disable Octal DTR I/O.
30943094
* @nor: pointer to a 'struct spi_nor'
30953095
* @enable: whether to enable or disable Octal DTR
30963096
*
30973097
* Return: 0 on success, -errno otherwise.
30983098
*/
3099-
static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
3099+
static int spi_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
31003100
{
31013101
int ret;
31023102

3103-
if (!nor->params->octal_dtr_enable)
3103+
if (!nor->params->set_octal_dtr)
31043104
return 0;
31053105

31063106
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)
31103110
if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE))
31113111
return 0;
31123112

3113-
ret = nor->params->octal_dtr_enable(nor, enable);
3113+
ret = nor->params->set_octal_dtr(nor, enable);
31143114
if (ret)
31153115
return ret;
31163116

@@ -3171,7 +3171,7 @@ static int spi_nor_init(struct spi_nor *nor)
31713171
{
31723172
int err;
31733173

3174-
err = spi_nor_octal_dtr_enable(nor, true);
3174+
err = spi_nor_set_octal_dtr(nor, true);
31753175
if (err) {
31763176
dev_dbg(nor->dev, "octal mode not supported\n");
31773177
return err;
@@ -3273,7 +3273,7 @@ static int spi_nor_suspend(struct mtd_info *mtd)
32733273
int ret;
32743274

32753275
/* Disable octal DTR mode if we enabled it. */
3276-
ret = spi_nor_octal_dtr_enable(nor, false);
3276+
ret = spi_nor_set_octal_dtr(nor, false);
32773277
if (ret)
32783278
dev_err(nor->dev, "suspend() failed\n");
32793279

drivers/mtd/spi-nor/core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ struct spi_nor_otp {
364364
* @erase_map: the erase map parsed from the SFDP Sector Map Parameter
365365
* Table.
366366
* @otp: SPI NOR OTP info.
367-
* @octal_dtr_enable: enables SPI NOR octal DTR mode.
367+
* @set_octal_dtr: enables or disables SPI NOR octal DTR mode.
368368
* @quad_enable: enables SPI NOR quad mode.
369369
* @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode.
370370
* @convert_addr: converts an absolute address into something the flash
@@ -398,7 +398,7 @@ struct spi_nor_flash_parameter {
398398
struct spi_nor_erase_map erase_map;
399399
struct spi_nor_otp otp;
400400

401-
int (*octal_dtr_enable)(struct spi_nor *nor, bool enable);
401+
int (*set_octal_dtr)(struct spi_nor *nor, bool enable);
402402
int (*quad_enable)(struct spi_nor *nor);
403403
int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable);
404404
u32 (*convert_addr)(struct spi_nor *nor, u32 addr);

drivers/mtd/spi-nor/micron-st.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ static int micron_st_nor_octal_dtr_dis(struct spi_nor *nor)
120120
return 0;
121121
}
122122

123-
static int micron_st_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
123+
static int micron_st_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
124124
{
125125
return enable ? micron_st_nor_octal_dtr_en(nor) :
126126
micron_st_nor_octal_dtr_dis(nor);
127127
}
128128

129129
static void mt35xu512aba_default_init(struct spi_nor *nor)
130130
{
131-
nor->params->octal_dtr_enable = micron_st_nor_octal_dtr_enable;
131+
nor->params->set_octal_dtr = micron_st_nor_set_octal_dtr;
132132
}
133133

134134
static int mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor)

drivers/mtd/spi-nor/spansion.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static struct spi_nor_fixups s25hx_t_fixups = {
607607
};
608608

609609
/**
610-
* cypress_nor_octal_dtr_enable() - Enable octal DTR on Cypress flashes.
610+
* cypress_nor_set_octal_dtr() - Enable or disable octal DTR on Cypress flashes.
611611
* @nor: pointer to a 'struct spi_nor'
612612
* @enable: whether to enable or disable Octal DTR
613613
*
@@ -616,7 +616,7 @@ static struct spi_nor_fixups s25hx_t_fixups = {
616616
*
617617
* Return: 0 on success, -errno otherwise.
618618
*/
619-
static int cypress_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
619+
static int cypress_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
620620
{
621621
return enable ? cypress_nor_octal_dtr_en(nor) :
622622
cypress_nor_octal_dtr_dis(nor);
@@ -667,7 +667,7 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,
667667

668668
static void s28hx_t_late_init(struct spi_nor *nor)
669669
{
670-
nor->params->octal_dtr_enable = cypress_nor_octal_dtr_enable;
670+
nor->params->set_octal_dtr = cypress_nor_set_octal_dtr;
671671
cypress_nor_ecc_init(nor);
672672
}
673673

0 commit comments

Comments
 (0)