mtd: core: handle flashes without OTP gracefully
authorMichael Walle <michael@walle.cc>
Wed, 7 Jul 2021 13:53:59 +0000 (15:53 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 15 Jul 2021 22:49:20 +0000 (00:49 +0200)
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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210707135359.32398-1-michael@walle.cc
drivers/mtd/mtdcore.c

index b5ccd3037788a2401ce31b39ed013f4bb57ad72b..c8fd7f758938bfd35d70968b1b8115eb589facd8 100644 (file)
@@ -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,