@@ -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) {
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