[PATCH v4 07/27] mtd: spi-nor: swp: Explain the MEMLOCK ioctl implementation behaviour
Pratyush Yadav
pratyush at kernel.org
Tue May 5 08:40:18 PDT 2026
Hi,
On Fri, Apr 03 2026, Miquel Raynal wrote:
> Add comments about how these requests are actually handled in the SPI
> NOR core. Their behaviour was not entirely clear to me at first, and
> explaining them in plain English sounds the way to go.
>
> Reviewed-by: Michael Walle <mwalle at kernel.org>
> Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> ---
> drivers/mtd/spi-nor/swp.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c
> index 1d50db1ef1a0..64a917543928 100644
> --- a/drivers/mtd/spi-nor/swp.c
> +++ b/drivers/mtd/spi-nor/swp.c
> @@ -346,6 +346,14 @@ static int spi_nor_sr_is_locked(struct spi_nor *nor, loff_t ofs, u64 len)
> return spi_nor_is_locked_sr(nor, ofs, len, nor->bouncebuf[0]);
> }
>
> +/*
> + * These ioctls behave according to the following rules:
> + * ->lock(): Never locks more than what is requested, ie. may lock less
> + * ->unlock(): Never unlocks more than what is requested, ie. may unlock less
> + * -is_locked(): Checks if the region is *fully* locked, returns false otherwise.
> + * This feeback may be misleading because users may get an "unlocked"
> + * status even though a subpart of the region is effectively locked.
> + */
We already have some text where struct spi_nor_locking_ops is defined.
Can we move this information there?
> static const struct spi_nor_locking_ops spi_nor_sr_locking_ops = {
> .lock = spi_nor_sr_lock,
> .unlock = spi_nor_sr_unlock,
--
Regards,
Pratyush Yadav
More information about the linux-mtd
mailing list