rtc: nvmem: disallow registering nvmem more than once
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 12 Feb 2018 22:47:18 +0000 (23:47 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 14 Feb 2018 19:58:16 +0000 (20:58 +0100)
Make rtc_nvmem_register return -EBUSY when an nvmem is already registered
for that RTC.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/nvmem.c

index 293df6d..fd1c39a 100644 (file)
@@ -87,6 +87,9 @@ static void rtc_nvram_unregister(struct rtc_device *rtc)
 int rtc_nvmem_register(struct rtc_device *rtc,
                       struct nvmem_config *nvmem_config)
 {
+       if (!IS_ERR_OR_NULL(rtc->nvmem))
+               return -EBUSY;
+
        if (!nvmem_config)
                return -ENODEV;