[PATCH v6 05/17] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning()

Miquel Raynal miquel.raynal at bootlin.com
Wed Jul 29 01:37:31 PDT 2026


Hello Santhosh,

On 23/07/2026 at 16:32:07 +0530, Santhosh Kumar K <s-k6 at ti.com> wrote:

> Add an execute_tuning callback to struct spi_controller_mem_ops. The
> callback receives a mandatory read op template and an optional write op
> template. On success the controller sets op->max_freq in each provided
> template to the validated clock rate.
>
> Add the corresponding spi_mem_execute_tuning() wrapper that checks for
> callback availability and returns -EOPNOTSUPP when the controller has
> not implemented it, allowing callers to handle controllers that do not
> support tuning gracefully.
>
> Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>
> Signed-off-by: Santhosh Kumar K <s-k6 at ti.com>

Sashiko found two issues which I think are easy yet worth fixing:

- [High] spi_mem_execute_tuning() directly invokes the controller callback without acquiring the SPI bus locks or ensuring the controller is powered on.
- [High] spi_mem_execute_tuning() does not check if the SPI device is using a GPIO chip select before invoking the hardware tuning callback.

Can you please have a look?

Thanks,
Miquèl



More information about the linux-mtd mailing list