Commit 8bd1d24e authored by Michael Walle's avatar Michael Walle Committed by Miquel Raynal
Browse files

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: 4b361cfa ("mtd: core: add OTP nvmem provider support")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230308082021.870459-2-michael@walle.cc
parent 1cd9ceaa
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -939,6 +939,7 @@ static int mtd_nvmem_fact_otp_reg_read(void *priv, unsigned int offset,


static int mtd_otp_nvmem_add(struct mtd_info *mtd)
static int mtd_otp_nvmem_add(struct mtd_info *mtd)
{
{
	struct device *dev = mtd->dev.parent;
	struct nvmem_device *nvmem;
	struct nvmem_device *nvmem;
	ssize_t size;
	ssize_t size;
	int err;
	int err;
@@ -952,7 +953,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
			nvmem = mtd_otp_nvmem_register(mtd, "user-otp", size,
			nvmem = mtd_otp_nvmem_register(mtd, "user-otp", size,
						       mtd_nvmem_user_otp_reg_read);
						       mtd_nvmem_user_otp_reg_read);
			if (IS_ERR(nvmem)) {
			if (IS_ERR(nvmem)) {
				dev_err(&mtd->dev, "Failed to register OTP NVMEM device\n");
				dev_err(dev, "Failed to register OTP NVMEM device\n");
				return PTR_ERR(nvmem);
				return PTR_ERR(nvmem);
			}
			}
			mtd->otp_user_nvmem = nvmem;
			mtd->otp_user_nvmem = nvmem;
@@ -970,7 +971,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
			nvmem = mtd_otp_nvmem_register(mtd, "factory-otp", size,
			nvmem = mtd_otp_nvmem_register(mtd, "factory-otp", size,
						       mtd_nvmem_fact_otp_reg_read);
						       mtd_nvmem_fact_otp_reg_read);
			if (IS_ERR(nvmem)) {
			if (IS_ERR(nvmem)) {
				dev_err(&mtd->dev, "Failed to register OTP NVMEM device\n");
				dev_err(dev, "Failed to register OTP NVMEM device\n");
				err = PTR_ERR(nvmem);
				err = PTR_ERR(nvmem);
				goto err;
				goto err;
			}
			}