Skip to content

Commit 8bd1d24

Browse files
mwallemiquelraynal
authored andcommitted
mtd: core: fix nvmem error reporting
The master MTD will only have an associated device if CONFIG_MTD_PARTITIONED_MASTER is set, thus we cannot use dev_err() on mtd->dev. Instead use the parent device which is the physical flash memory. Fixes: 4b361cf ("mtd: core: add OTP nvmem provider support") Cc: stable@vger.kernel.org Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230308082021.870459-2-michael@walle.cc
1 parent 1cd9cea commit 8bd1d24

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/mtd/mtdcore.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ static int mtd_nvmem_fact_otp_reg_read(void *priv, unsigned int offset,
939939

940940
static int mtd_otp_nvmem_add(struct mtd_info *mtd)
941941
{
942+
struct device *dev = mtd->dev.parent;
942943
struct nvmem_device *nvmem;
943944
ssize_t size;
944945
int err;
@@ -952,7 +953,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
952953
nvmem = mtd_otp_nvmem_register(mtd, "user-otp", size,
953954
mtd_nvmem_user_otp_reg_read);
954955
if (IS_ERR(nvmem)) {
955-
dev_err(&mtd->dev, "Failed to register OTP NVMEM device\n");
956+
dev_err(dev, "Failed to register OTP NVMEM device\n");
956957
return PTR_ERR(nvmem);
957958
}
958959
mtd->otp_user_nvmem = nvmem;
@@ -970,7 +971,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
970971
nvmem = mtd_otp_nvmem_register(mtd, "factory-otp", size,
971972
mtd_nvmem_fact_otp_reg_read);
972973
if (IS_ERR(nvmem)) {
973-
dev_err(&mtd->dev, "Failed to register OTP NVMEM device\n");
974+
dev_err(dev, "Failed to register OTP NVMEM device\n");
974975
err = PTR_ERR(nvmem);
975976
goto err;
976977
}

0 commit comments

Comments
 (0)