OSDN Git Service

rtc: nvmem: return error values
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 12 Feb 2018 22:47:17 +0000 (23:47 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 14 Feb 2018 19:58:13 +0000 (20:58 +0100)
In case of error, make rtc_nvmem_register() able to return an error value
to its caller.

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

index 0a3522b..293df6d 100644 (file)
@@ -84,21 +84,23 @@ static void rtc_nvram_unregister(struct rtc_device *rtc)
 /*
  * New ABI, uses nvmem
  */
-void rtc_nvmem_register(struct rtc_device *rtc,
-                       struct nvmem_config *nvmem_config)
+int rtc_nvmem_register(struct rtc_device *rtc,
+                      struct nvmem_config *nvmem_config)
 {
        if (!nvmem_config)
-               return;
+               return -ENODEV;
 
        nvmem_config->dev = &rtc->dev;
        nvmem_config->owner = rtc->owner;
        rtc->nvmem = nvmem_register(nvmem_config);
        if (IS_ERR_OR_NULL(rtc->nvmem))
-               return;
+               return PTR_ERR(rtc->nvmem);
 
        /* Register the old ABI */
        if (rtc->nvram_old_abi)
                rtc_nvram_register(rtc, nvmem_config->size);
+
+       return 0;
 }
 
 void rtc_nvmem_unregister(struct rtc_device *rtc)
index 5f60e3b..05a6783 100644 (file)
@@ -48,11 +48,14 @@ static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
 #endif
 
 #ifdef CONFIG_RTC_NVMEM
-void rtc_nvmem_register(struct rtc_device *rtc,
-                       struct nvmem_config *nvmem_config);
+int rtc_nvmem_register(struct rtc_device *rtc,
+                      struct nvmem_config *nvmem_config);
 void rtc_nvmem_unregister(struct rtc_device *rtc);
 #else
-static inline void rtc_nvmem_register(struct rtc_device *rtc,
-                                     struct nvmem_config *nvmem_config) {}
+static inline int rtc_nvmem_register(struct rtc_device *rtc,
+                                    struct nvmem_config *nvmem_config)
+{
+       return -ENODEV;
+}
 static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {}
 #endif