Skip to content

Commit

Permalink
mtd: core: handle flashes without OTP gracefully
Browse files Browse the repository at this point in the history
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: 4b361cf ("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
  • Loading branch information
Michael Walle authored and Miquel Raynal committed Jul 15, 2021
1 parent e83862e commit 45bb1fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 45bb1fa

Please sign in to comment.