Skip to content

Commit f8cd9f6

Browse files
Patrice Chotardambarus
authored andcommitted
mtd: spi-nor: fix spi_nor_spimem_setup_op() call in spi_nor_erase_{sector,chip}()
For erase operations, reg_proto must be used as indicated in struct spi_nor description in spi-nor.h. This issue was found when DT property spi-tx-bus-width is set to 4. In this case the spi_mem_op->addr.buswidth is set to 4 for erase command which is not correct. Tested on stm32mp157c-ev1 board with mx66l51235f spi-nor. Fixes: 0e30f47 ("mtd: spi-nor: add support for DTR protocol") Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> [ta: use nor->reg_proto in spi_nor_controller_ops_erase()] Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Tested-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Link: https://lore.kernel.org/r/20220629133013.3382393-1-patrice.chotard@foss.st.com
1 parent b6b2383 commit f8cd9f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/mtd/spi-nor/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int spi_nor_controller_ops_write_reg(struct spi_nor *nor, u8 opcode,
177177

178178
static int spi_nor_controller_ops_erase(struct spi_nor *nor, loff_t offs)
179179
{
180-
if (spi_nor_protocol_is_dtr(nor->write_proto))
180+
if (spi_nor_protocol_is_dtr(nor->reg_proto))
181181
return -EOPNOTSUPP;
182182

183183
return nor->controller_ops->erase(nor, offs);
@@ -972,7 +972,7 @@ static int spi_nor_erase_chip(struct spi_nor *nor)
972972
if (nor->spimem) {
973973
struct spi_mem_op op = SPI_NOR_CHIP_ERASE_OP;
974974

975-
spi_nor_spimem_setup_op(nor, &op, nor->write_proto);
975+
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
976976

977977
ret = spi_mem_exec_op(nor->spimem, &op);
978978
} else {
@@ -1115,7 +1115,7 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
11151115
SPI_NOR_SECTOR_ERASE_OP(nor->erase_opcode,
11161116
nor->addr_nbytes, addr);
11171117

1118-
spi_nor_spimem_setup_op(nor, &op, nor->write_proto);
1118+
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
11191119

11201120
return spi_mem_exec_op(nor->spimem, &op);
11211121
} else if (nor->controller_ops->erase) {

0 commit comments

Comments
 (0)