rtc: nvmem: emit an error message when nvmem registration fails

Some users check the return value of devm_rtc_nvmem_register() only in
order to emit an error message and then continue probing. This is fine
as an rtc can function without exposing nvmem but let's generalize it:
let's make the registration function emit the error message so that
users don't have to.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201109163409.24301-7-brgl@bgdev.pl
This commit is contained in:
Bartosz Golaszewski 2020-11-09 17:34:07 +01:00 committed by Alexandre Belloni
parent 3a905c2d95
commit 6746bc095b
4 changed files with 8 additions and 8 deletions

View File

@ -13,14 +13,17 @@
int devm_rtc_nvmem_register(struct rtc_device *rtc,
struct nvmem_config *nvmem_config)
{
struct device *dev = rtc->dev.parent;
struct nvmem_device *nvmem;
if (!nvmem_config)
return -ENODEV;
nvmem_config->dev = rtc->dev.parent;
nvmem_config->dev = dev;
nvmem_config->owner = rtc->owner;
nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config);
nvmem = devm_nvmem_register(dev, nvmem_config);
if (IS_ERR(nvmem))
dev_err(dev, "failed to register nvmem device for RTC\n");
return PTR_ERR_OR_ZERO(nvmem);
}

View File

@ -869,8 +869,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
/* export at least the first block of NVRAM */
nvmem_cfg.size = address_space - NVRAM_OFFSET;
if (devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg))
dev_err(dev, "nvmem registration failed\n");
devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg);
dev_info(dev, "%s%s, %d bytes nvram%s\n",
!is_valid_irq(rtc_irq) ? "no alarms" :

View File

@ -309,8 +309,7 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
}
}
if (devm_rtc_nvmem_register(pdata->rtc, &nvmem_cfg))
dev_err(&pdev->dev, "unable to register nvmem\n");
devm_rtc_nvmem_register(pdata->rtc, &nvmem_cfg);
return 0;
}

View File

@ -195,8 +195,7 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
if (ret)
return ret;
if (devm_rtc_nvmem_register(rtc, &nvmem_cfg))
dev_err(&pdev->dev, "Unable to register nvmem\n");
devm_rtc_nvmem_register(rtc, &nvmem_cfg);
return 0;
}