Hi, On 20/05/2018 15:37:23+0200, Uwe Kleine-König wrote: > static int pcf2127_probe(struct device *dev, struct regmap *regmap, > - const char *name) > + const char *name, bool has_nvmem) > { > struct pcf2127 *pcf2127; > + int ret = 0; > > dev_dbg(dev, "%s\n", __func__); > > @@ -200,8 +242,21 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap, > > pcf2127->rtc = devm_rtc_device_register(dev, name, &pcf2127_rtc_ops, > THIS_MODULE); > + if (IS_ERR(pcf2127->rtc)) > + return PTR_ERR(pcf2127->rtc); > + > + if (has_nvmem) { > + struct nvmem_config nvmem_cfg = { > + .priv = pcf2127, > + .reg_read = pcf2127_nvmem_read, > + .reg_write = pcf2127_nvmem_write, > + .size = 512, > + }; > + > + ret = rtc_nvmem_register(pcf2127->rtc, &nvmem_cfg); > + } > > - return PTR_ERR_OR_ZERO(pcf2127->rtc); > + return ret; You must not return an error here once devm_rtc_device_register has succeeded. You have the choice between ignoring the nvmem registration error or switching to devm_rtc_allocate_device/rtc_register_device(). -- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com