diff mbox

[v2] rtc: ds1307: fix alarm reading at probe time

Message ID 1448546126-22407-1-git-send-email-simon.guinot@sequanux.org
State Superseded
Headers show

Commit Message

Simon Guinot Nov. 26, 2015, 1:55 p.m. UTC
With the actual code, read_alarm() always returns -EINVAL when called
during the RTC device registration. This prevents from retrieving an
already configured alarm in hardware.

This patch fixes the issue by moving the HAS_ALARM bit configuration
(if supported by the hardware) above the rtc_device_register() call.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
 drivers/rtc/rtc-ds1307.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Change for v2: rebase against the branch rtc-fixes
diff mbox

Patch

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 325836818826..754c60dad224 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1135,6 +1135,8 @@  read_rtc:
 	}
 
 	device_set_wakeup_capable(&client->dev, want_irq);
+	if (want_irq)
+		set_bit(HAS_ALARM, &ds1307->flags);
 	ds1307->rtc = devm_rtc_device_register(&client->dev, client->name,
 				rtc_ops, THIS_MODULE);
 	if (IS_ERR(ds1307->rtc)) {
@@ -1149,11 +1151,8 @@  read_rtc:
 		if (err) {
 			client->irq = 0;
 			dev_err(&client->dev, "unable to request IRQ!\n");
-		} else {
-
-			set_bit(HAS_ALARM, &ds1307->flags);
+		} else
 			dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
-		}
 	}
 
 	if (chip->nvram_size) {