mtd: spi-nor: core: Don't use mtd_info in the NOR's probe sequence of calls

Use NOR parameters in the probe's sequence of calls, thus
nor->params->size instead of nor->mtd.size and let the mtd_info
fields be used by the mtd calls (mtd->_erase, mtd->_read, mtd->_write).
mtd_info fields should not be used during probe because we haven't
registered mtd yet. It's safe to drop xilinx's setting of nor->mtd.size,
now that we use nor->params->size in spi_nor_set_addr_width().

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-3-tudor.ambarus@microchip.com
This commit is contained in:
Tudor Ambarus 2021-12-07 16:02:42 +02:00
Родитель f656b419d4
Коммит eb726c3220
2 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -2115,7 +2115,7 @@ static int spi_nor_spimem_check_op(struct spi_nor *nor,
*/
op->addr.nbytes = 4;
if (!spi_mem_supports_op(nor->spimem, op)) {
if (nor->mtd.size > SZ_16M)
if (nor->params->size > SZ_16M)
return -EOPNOTSUPP;
/* If flash size <= 16MB, 3 address bytes are sufficient */
@ -3011,7 +3011,7 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)
nor->addr_width = 3;
}
if (nor->addr_width == 3 && nor->mtd.size > 0x1000000) {
if (nor->addr_width == 3 && nor->params->size > 0x1000000) {
/* enable 4-byte addressing if the device exceeds 16MiB */
nor->addr_width = 4;
}
@ -3245,7 +3245,7 @@ static int spi_nor_create_read_dirmap(struct spi_nor *nor)
SPI_MEM_OP_DUMMY(nor->read_dummy, 0),
SPI_MEM_OP_DATA_IN(0, NULL, 0)),
.offset = 0,
.length = nor->mtd.size,
.length = nor->params->size,
};
struct spi_mem_op *op = &info.op_tmpl;
@ -3276,7 +3276,7 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_DATA_OUT(0, NULL, 0)),
.offset = 0,
.length = nor->mtd.size,
.length = nor->params->size,
};
struct spi_mem_op *op = &info.op_tmpl;

Просмотреть файл

@ -70,7 +70,6 @@ static int xilinx_nor_setup(struct spi_nor *nor,
nor->params->page_size = page_size;
nor->mtd.writebufsize = page_size;
nor->params->size = 8 * page_size * nor->info->n_sectors;
nor->mtd.size = nor->params->size;
nor->mtd.erasesize = 8 * page_size;
} else {
/* Flash in Default addressing mode */