Thread (46 messages) 46 messages, 1 author, 2018-02-12
DORMANTno replies

[PATCH 04/45] rtc: nvmem: disallow registering nvmem more than once

From: Alexandre Belloni <alexandre.belloni@bootlin.com>
Date: 2018-02-12 22:59:03
Also in: lkml
Subsystem: real time clock (rtc) subsystem, the rest · Maintainers: Alexandre Belloni, Linus Torvalds

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 | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/rtc/nvmem.c b/drivers/rtc/nvmem.c
index 293df6db7c42..fd1c39a5ade5 100644
--- a/drivers/rtc/nvmem.c
+++ b/drivers/rtc/nvmem.c
@@ -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;
 
-- 
2.16.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help