Skip to content

Commit a007d81

Browse files
ambarusPratyush Yadav
authored andcommitted
mtd: spi-nor: manufacturers: Use spi_nor_read_id() core method
Use spi_nor_read_id() core method to avoid duplication of code. Now the ID is read on the full SPI_NOR_MAX_ID_LEN instead of round_up(nor->info->id_len, 2), but it doesn't harm to read more ID bytes, so the change comes with no secondary effects. dev_dbg messages in case spi_nor_read_id() fails, will be added in a further patch after we split the octal DTR enable/disable methods. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20220420103427.47867-6-tudor.ambarus@microchip.com
1 parent 86b6b55 commit a007d81

2 files changed

Lines changed: 6 additions & 20 deletions

File tree

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,10 @@ static int micron_st_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
9191
return ret;
9292

9393
/* Read flash ID to make sure the switch was successful. */
94-
op = (struct spi_mem_op)
95-
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 1),
96-
SPI_MEM_OP_NO_ADDR,
97-
SPI_MEM_OP_DUMMY(enable ? 8 : 0, 1),
98-
SPI_MEM_OP_DATA_IN(round_up(nor->info->id_len, 2),
99-
buf, 1));
100-
10194
if (enable)
102-
spi_nor_spimem_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
103-
104-
ret = spi_mem_exec_op(nor->spimem, &op);
95+
ret = spi_nor_read_id(nor, 0, 8, buf, SNOR_PROTO_8_8_8_DTR);
96+
else
97+
ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1);
10598
if (ret)
10699
return ret;
107100

drivers/mtd/spi-nor/spansion.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,10 @@ static int cypress_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
9898
return ret;
9999

100100
/* Read flash ID to make sure the switch was successful. */
101-
op = (struct spi_mem_op)
102-
SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RDID, 1),
103-
SPI_MEM_OP_ADDR(enable ? 4 : 0, 0, 1),
104-
SPI_MEM_OP_DUMMY(enable ? 3 : 0, 1),
105-
SPI_MEM_OP_DATA_IN(round_up(nor->info->id_len, 2),
106-
buf, 1));
107-
108101
if (enable)
109-
spi_nor_spimem_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
110-
111-
ret = spi_mem_exec_op(nor->spimem, &op);
102+
ret = spi_nor_read_id(nor, 4, 3, buf, SNOR_PROTO_8_8_8_DTR);
103+
else
104+
ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1);
112105
if (ret)
113106
return ret;
114107

0 commit comments

Comments
 (0)