summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-02-12 17:47:17 -0500
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-02-14 14:58:13 -0500
commit2cc8212198820487ec3fdcc7b98133701fc9dfc3 (patch)
treee4e81b3f8b537aa7f6aa4960dae86bbe04f7dc06
parent4cce9d3988ae33eb53742d9648ecc59046196e6f (diff)
rtc: nvmem: return error values
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>
-rw-r--r--drivers/rtc/nvmem.c10
-rw-r--r--drivers/rtc/rtc-core.h11
2 files changed, 13 insertions, 8 deletions
diff --git a/drivers/rtc/nvmem.c b/drivers/rtc/nvmem.c
index 0a3522bcdd25..293df6db7c42 100644
--- a/drivers/rtc/nvmem.c
+++ b/drivers/rtc/nvmem.c
@@ -84,21 +84,23 @@ static void rtc_nvram_unregister(struct rtc_device *rtc)
84/* 84/*
85 * New ABI, uses nvmem 85 * New ABI, uses nvmem
86 */ 86 */
87void rtc_nvmem_register(struct rtc_device *rtc, 87int rtc_nvmem_register(struct rtc_device *rtc,
88 struct nvmem_config *nvmem_config) 88 struct nvmem_config *nvmem_config)
89{ 89{
90 if (!nvmem_config) 90 if (!nvmem_config)
91 return; 91 return -ENODEV;
92 92
93 nvmem_config->dev = &rtc->dev; 93 nvmem_config->dev = &rtc->dev;
94 nvmem_config->owner = rtc->owner; 94 nvmem_config->owner = rtc->owner;
95 rtc->nvmem = nvmem_register(nvmem_config); 95 rtc->nvmem = nvmem_register(nvmem_config);
96 if (IS_ERR_OR_NULL(rtc->nvmem)) 96 if (IS_ERR_OR_NULL(rtc->nvmem))
97 return; 97 return PTR_ERR(rtc->nvmem);
98 98
99 /* Register the old ABI */ 99 /* Register the old ABI */
100 if (rtc->nvram_old_abi) 100 if (rtc->nvram_old_abi)
101 rtc_nvram_register(rtc, nvmem_config->size); 101 rtc_nvram_register(rtc, nvmem_config->size);
102
103 return 0;
102} 104}
103 105
104void rtc_nvmem_unregister(struct rtc_device *rtc) 106void rtc_nvmem_unregister(struct rtc_device *rtc)
diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h
index 5f60e3b11cde..05a67837fd76 100644
--- a/drivers/rtc/rtc-core.h
+++ b/drivers/rtc/rtc-core.h
@@ -48,11 +48,14 @@ static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
48#endif 48#endif
49 49
50#ifdef CONFIG_RTC_NVMEM 50#ifdef CONFIG_RTC_NVMEM
51void rtc_nvmem_register(struct rtc_device *rtc, 51int rtc_nvmem_register(struct rtc_device *rtc,
52 struct nvmem_config *nvmem_config); 52 struct nvmem_config *nvmem_config);
53void rtc_nvmem_unregister(struct rtc_device *rtc); 53void rtc_nvmem_unregister(struct rtc_device *rtc);
54#else 54#else
55static inline void rtc_nvmem_register(struct rtc_device *rtc, 55static inline int rtc_nvmem_register(struct rtc_device *rtc,
56 struct nvmem_config *nvmem_config) {} 56 struct nvmem_config *nvmem_config)
57{
58 return -ENODEV;
59}
57static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {} 60static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {}
58#endif 61#endif