linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: core: handle flashes without OTP gracefully
@ 2021-07-07 13:53 Michael Walle
  2021-07-15 22:50 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Walle @ 2021-07-07 13:53 UTC (permalink / raw)
  To: linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Tudor.Ambarus, Michael Walle, Guenter Roeck

There are flash drivers which registers the OTP callbacks although the
flash doesn't support OTP regions and return -ENODATA for these
callbacks if there is no OTP. If this happens, the probe of the whole
flash will fail. Fix it by handling the ENODATA return code and skip
the OTP region nvmem setup.

Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Michael Walle <michael@walle.cc>
Tested-by: Guenter Roeck <linux@roeck-us.net>
---
changes since v1:
 - move the check into mtd_otp_size()

 drivers/mtd/mtdcore.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index b5ccd3037788..c8fd7f758938 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -806,7 +806,9 @@ static ssize_t mtd_otp_size(struct mtd_info *mtd, bool is_user)
 
 err:
 	kfree(info);
-	return ret;
+
+	/* ENODATA means there is no OTP region. */
+	return ret == -ENODATA ? 0 : ret;
 }
 
 static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mtd: core: handle flashes without OTP gracefully
  2021-07-07 13:53 [PATCH v2] mtd: core: handle flashes without OTP gracefully Michael Walle
@ 2021-07-15 22:50 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-07-15 22:50 UTC (permalink / raw)
  To: Michael Walle, linux-mtd, linux-kernel
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Tudor.Ambarus, Guenter Roeck

On Wed, 2021-07-07 at 13:53:59 UTC, Michael Walle wrote:
> There are flash drivers which registers the OTP callbacks although the
> flash doesn't support OTP regions and return -ENODATA for these
> callbacks if there is no OTP. If this happens, the probe of the whole
> flash will fail. Fix it by handling the ENODATA return code and skip
> the OTP region nvmem setup.
> 
> Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Michael Walle <michael@walle.cc>
> Tested-by: Guenter Roeck <linux@roeck-us.net>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-15 22:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 13:53 [PATCH v2] mtd: core: handle flashes without OTP gracefully Michael Walle
2021-07-15 22:50 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).