[PATCH] mtd: spi-nor: core: Check read CR support

Jakub "Kuba" Czapiga czapiga at google.com
Wed Sep 10 07:30:43 PDT 2025


Hi Miquèl,

On Wed, Sep 10, 2025 at 2:05 PM Miquel Raynal <miquel.raynal at bootlin.com> wrote:
>
> Hi Jakub,
>
> > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> > index ac4b960101cc..79deee3a50d3 100644
> > --- a/drivers/mtd/spi-nor/core.c
> > +++ b/drivers/mtd/spi-nor/core.c
> > @@ -2608,6 +2608,10 @@ static int spi_nor_setup(struct spi_nor *nor,
> >               }
> >       }
> >
> > +     /* Some SPI controllers might not support CR read opcode. */
> > +     if (spi_nor_read_cr(nor, nor->bouncebuf) == -EOPNOTSUPP)
>
> There is a spi_nor_spimem_check_op() helper which might be better suited
> for this purpose?

spi_nor_spimem_check_op() works only for spi-mem devices. spi_nor_read_cr()
handles both spi-mem and spi-nor controller. Using spi_nor_spimem_check_op()
would require adding a variation of spi_nor_read_cr() that would use
spi_nor_spimem_check_op() for spi-mem and spi_nor_controller_ops_read_reg()
for spi-nor controller.
Another way would be to do this check only for the spi-mem as spi-nor
controllers seem to be deprecated in favour of spi-mem.

Thanks,
Jakub



More information about the linux-mtd mailing list