Skip to content

Commit

Permalink
mtd: spi-nor: remove unused enum spi_nor_ops
Browse files Browse the repository at this point in the history
The ops aren't used in any SPI NOR controller. Therefore, remove them
altogether.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
  • Loading branch information
Michael Walle authored and Tudor Ambarus committed Jan 14, 2020
1 parent 701a167 commit 52bbd2d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd/spi-nor/aspeed-smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ static void aspeed_smc_stop_user(struct spi_nor *nor)
writel(ctl, chip->ctl); /* default to fread or read mode */
}

static int aspeed_smc_prep(struct spi_nor *nor, enum spi_nor_ops ops)
static int aspeed_smc_prep(struct spi_nor *nor)
{
struct aspeed_smc_chip *chip = nor->priv;

mutex_lock(&chip->controller->mutex);
return 0;
}

static void aspeed_smc_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
static void aspeed_smc_unprep(struct spi_nor *nor)
{
struct aspeed_smc_chip *chip = nor->priv;

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/spi-nor/cadence-quadspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ static int cqspi_erase(struct spi_nor *nor, loff_t offs)
return 0;
}

static int cqspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
static int cqspi_prep(struct spi_nor *nor)
{
struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi;
Expand All @@ -1072,7 +1072,7 @@ static int cqspi_prep(struct spi_nor *nor, enum spi_nor_ops ops)
return 0;
}

static void cqspi_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
static void cqspi_unprep(struct spi_nor *nor)
{
struct cqspi_flash_pdata *f_pdata = nor->priv;
struct cqspi_st *cqspi = f_pdata->cqspi;
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/spi-nor/hisi-sfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static void hisi_spi_nor_init(struct hifmc_host *host)
writel(reg, host->regbase + FMC_SPI_TIMING_CFG);
}

static int hisi_spi_nor_prep(struct spi_nor *nor, enum spi_nor_ops ops)
static int hisi_spi_nor_prep(struct spi_nor *nor)
{
struct hifmc_priv *priv = nor->priv;
struct hifmc_host *host = priv->host;
Expand All @@ -167,7 +167,7 @@ static int hisi_spi_nor_prep(struct spi_nor *nor, enum spi_nor_ops ops)
return ret;
}

static void hisi_spi_nor_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
static void hisi_spi_nor_unprep(struct spi_nor *nor)
{
struct hifmc_priv *priv = nor->priv;
struct hifmc_host *host = priv->host;
Expand Down
36 changes: 18 additions & 18 deletions drivers/mtd/spi-nor/spi-nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,14 +1312,14 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor)
}
}

static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops)
static int spi_nor_lock_and_prep(struct spi_nor *nor)
{
int ret = 0;

mutex_lock(&nor->lock);

if (nor->controller_ops && nor->controller_ops->prepare) {
ret = nor->controller_ops->prepare(nor, ops);
ret = nor->controller_ops->prepare(nor);
if (ret) {
mutex_unlock(&nor->lock);
return ret;
Expand All @@ -1328,10 +1328,10 @@ static int spi_nor_lock_and_prep(struct spi_nor *nor, enum spi_nor_ops ops)
return ret;
}

static void spi_nor_unlock_and_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
static void spi_nor_unlock_and_unprep(struct spi_nor *nor)
{
if (nor->controller_ops && nor->controller_ops->unprepare)
nor->controller_ops->unprepare(nor, ops);
nor->controller_ops->unprepare(nor);
mutex_unlock(&nor->lock);
}

Expand Down Expand Up @@ -1693,7 +1693,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
addr = instr->addr;
len = instr->len;

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_ERASE);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

Expand Down Expand Up @@ -1756,7 +1756,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
ret = spi_nor_write_disable(nor);

erase_err:
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE);
spi_nor_unlock_and_unprep(nor);

return ret;
}
Expand Down Expand Up @@ -2052,13 +2052,13 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_LOCK);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

ret = nor->params.locking_ops->lock(nor, ofs, len);

spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_UNLOCK);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand All @@ -2067,13 +2067,13 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

ret = nor->params.locking_ops->unlock(nor, ofs, len);

spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand All @@ -2082,13 +2082,13 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

ret = nor->params.locking_ops->is_locked(nor, ofs, len);

spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand Down Expand Up @@ -2742,7 +2742,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,

dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_READ);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

Expand All @@ -2769,7 +2769,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
ret = 0;

read_err:
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand All @@ -2782,7 +2782,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,

dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_WRITE);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

Expand Down Expand Up @@ -2855,7 +2855,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
}
out:
*retlen += actual;
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand All @@ -2873,7 +2873,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,

dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);

ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_WRITE);
ret = spi_nor_lock_and_prep(nor);
if (ret)
return ret;

Expand Down Expand Up @@ -2919,7 +2919,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
}

write_err:
spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
spi_nor_unlock_and_unprep(nor);
return ret;
}

Expand Down
12 changes: 2 additions & 10 deletions include/linux/mtd/spi-nor.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,6 @@ static inline u8 spi_nor_get_protocol_width(enum spi_nor_protocol proto)
return spi_nor_get_protocol_data_nbits(proto);
}

enum spi_nor_ops {
SPI_NOR_OPS_READ = 0,
SPI_NOR_OPS_WRITE,
SPI_NOR_OPS_ERASE,
SPI_NOR_OPS_LOCK,
SPI_NOR_OPS_UNLOCK,
};

enum spi_nor_option_flags {
SNOR_F_USE_FSR = BIT(0),
SNOR_F_HAS_SR_TB = BIT(1),
Expand Down Expand Up @@ -485,8 +477,8 @@ struct spi_nor;
* opcode via write_reg().
*/
struct spi_nor_controller_ops {
int (*prepare)(struct spi_nor *nor, enum spi_nor_ops ops);
void (*unprepare)(struct spi_nor *nor, enum spi_nor_ops ops);
int (*prepare)(struct spi_nor *nor);
void (*unprepare)(struct spi_nor *nor);
int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, size_t len);
int (*write_reg)(struct spi_nor *nor, u8 opcode, const u8 *buf,
size_t len);
Expand Down

0 comments on commit 52bbd2d

Please sign in to comment.