Re: [PATCH v4 3/3] mtd: spi-nor: Rework hwcaps selection for the spi-mem case

From: Tudor.Ambarus
Date: Mon Aug 05 2019 - 13:45:59 EST




On 08/01/2019 07:22 PM, Vignesh Raghavendra wrote:
> +static int spi_nor_spimem_check_op(struct spi_nor *nor,
> + struct spi_mem_op *op)
> +{
> + /*
> + * First test with 4 address bytes. The opcode itself might
> + * be a 3B addressing opcode but we don't care, because
> + * SPI controller implementation should not check the opcode,
> + * but just the sequence.
> + */
> + op->addr.nbytes = 4;
> + if (!spi_mem_supports_op(nor->spimem, op)) {
> + /* If flash size <16MB, 3 address bytes are sufficient */
> + if (nor->mtd.size <= SZ_16M) {
> + op->addr.nbytes = 3;
> + if (!spi_mem_supports_op(nor->spimem, op))
> + return -ENOTSUPP;
> + }

this returns success when:
op->addr.nbytes == 4 && !spi_mem_supports_op(nor->spimem, op) &&
!(nor->mtd.size <= SZ_16M))

which is wrong.

The patch looks good otherwise!

> + }
> +
> + return 0;
> +}