Message ID | 20230301152440.531465-1-miquel.raynal@bootlin.com |
---|---|
State | Changes Requested |
Delegated to: | Miquel Raynal |
Headers | show |
Series | mtd: Avoid printing error messages on probe deferrals | expand |
Am 2023-03-01 16:24, schrieb Miquel Raynal: > There is no reason to complain about probe errors in case of deferrals. > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > --- > drivers/mtd/mtdcore.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index 0feacb9fbdac..d163c690750a 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -518,6 +518,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd) > { > struct device_node *node = mtd_get_of_node(mtd); > struct nvmem_config config = {}; > + int ret; > > config.id = -1; just noticed that magic value. If you care replace it with NVMEM_DEVID_NONE. > config.dev = &mtd->dev; > @@ -535,12 +536,15 @@ static int mtd_nvmem_add(struct mtd_info *mtd) > > mtd->nvmem = nvmem_register(&config); > if (IS_ERR(mtd->nvmem)) { > + ret = PTR_ERR(mtd->nvmem); > /* Just ignore if there is no NVMEM support in the kernel */ > - if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) { > + if (ret == -EOPNOTSUPP) { > mtd->nvmem = NULL; > } else { > - dev_err(&mtd->dev, "Failed to register NVMEM device\n"); > - return PTR_ERR(mtd->nvmem); > + if (ret != -EPROBE_DEFER) Since you have a proper "struct device" to operate on, you can also use dev_err_probe() which the same but also save the reason for the deferral. -michael > + dev_err(&mtd->dev, > + "Failed to register NVMEM device (%d)\n", ret); > + return ret; > } > }
Hi Michael, michael@walle.cc wrote on Mon, 06 Mar 2023 14:10:22 +0100: > Am 2023-03-01 16:24, schrieb Miquel Raynal: > > There is no reason to complain about probe errors in case of deferrals. > > > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > > --- > > drivers/mtd/mtdcore.c | 10 +++++++--- > > 1 file changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > > index 0feacb9fbdac..d163c690750a 100644 > > --- a/drivers/mtd/mtdcore.c > > +++ b/drivers/mtd/mtdcore.c > > @@ -518,6 +518,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd) > > { > > struct device_node *node = mtd_get_of_node(mtd); > > struct nvmem_config config = {}; > > + int ret; > > > > config.id = -1; > > just noticed that magic value. If you care replace it with NVMEM_DEVID_NONE. Mmmh yeah. > > > config.dev = &mtd->dev; > > @@ -535,12 +536,15 @@ static int mtd_nvmem_add(struct mtd_info *mtd) > > > > mtd->nvmem = nvmem_register(&config); > > if (IS_ERR(mtd->nvmem)) { > > + ret = PTR_ERR(mtd->nvmem); > > /* Just ignore if there is no NVMEM support in the kernel */ > > - if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) { > > + if (ret == -EOPNOTSUPP) { > > mtd->nvmem = NULL; > > } else { > > - dev_err(&mtd->dev, "Failed to register NVMEM device\n"); > > - return PTR_ERR(mtd->nvmem); > > + if (ret != -EPROBE_DEFER) > > Since you have a proper "struct device" to operate on, you can also use > dev_err_probe() which the same but also save the reason for the deferral. Good point. I'll update, that will make things clearer. > -michael > > > + dev_err(&mtd->dev, > > + "Failed to register NVMEM device (%d)\n", ret); > > + return ret; > > } > > } Thanks, Miquèl
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 0feacb9fbdac..d163c690750a 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -518,6 +518,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd) { struct device_node *node = mtd_get_of_node(mtd); struct nvmem_config config = {}; + int ret; config.id = -1; config.dev = &mtd->dev; @@ -535,12 +536,15 @@ static int mtd_nvmem_add(struct mtd_info *mtd) mtd->nvmem = nvmem_register(&config); if (IS_ERR(mtd->nvmem)) { + ret = PTR_ERR(mtd->nvmem); /* Just ignore if there is no NVMEM support in the kernel */ - if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) { + if (ret == -EOPNOTSUPP) { mtd->nvmem = NULL; } else { - dev_err(&mtd->dev, "Failed to register NVMEM device\n"); - return PTR_ERR(mtd->nvmem); + if (ret != -EPROBE_DEFER) + dev_err(&mtd->dev, + "Failed to register NVMEM device (%d)\n", ret); + return ret; } }
There is no reason to complain about probe errors in case of deferrals. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/mtd/mtdcore.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)