diff options
author | Simon Guinot <simon.guinot@sequanux.org> | 2015-11-26 09:37:13 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-11-26 12:11:26 -0500 |
commit | 3abb1ada21a4fb5b2920457a2e5c8483abb09a45 (patch) | |
tree | 88ead2d36f6031a3252bc5f291b738735464f336 | |
parent | 51c4cfef568fe8ebac06761ed7c754fac1f9b5a8 (diff) |
rtc: ds1307: fix alarm reading at probe time
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>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 325836818826..aa705bb4748c 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -1134,7 +1134,10 @@ read_rtc: | |||
1134 | bin2bcd(tmp)); | 1134 | bin2bcd(tmp)); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | device_set_wakeup_capable(&client->dev, want_irq); | 1137 | if (want_irq) { |
1138 | device_set_wakeup_capable(&client->dev, true); | ||
1139 | set_bit(HAS_ALARM, &ds1307->flags); | ||
1140 | } | ||
1138 | ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, | 1141 | ds1307->rtc = devm_rtc_device_register(&client->dev, client->name, |
1139 | rtc_ops, THIS_MODULE); | 1142 | rtc_ops, THIS_MODULE); |
1140 | if (IS_ERR(ds1307->rtc)) { | 1143 | if (IS_ERR(ds1307->rtc)) { |
@@ -1148,12 +1151,11 @@ read_rtc: | |||
1148 | ds1307->rtc->name, client); | 1151 | ds1307->rtc->name, client); |
1149 | if (err) { | 1152 | if (err) { |
1150 | client->irq = 0; | 1153 | client->irq = 0; |
1154 | device_set_wakeup_capable(&client->dev, false); | ||
1155 | clear_bit(HAS_ALARM, &ds1307->flags); | ||
1151 | dev_err(&client->dev, "unable to request IRQ!\n"); | 1156 | dev_err(&client->dev, "unable to request IRQ!\n"); |
1152 | } else { | 1157 | } else |
1153 | |||
1154 | set_bit(HAS_ALARM, &ds1307->flags); | ||
1155 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); | 1158 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); |
1156 | } | ||
1157 | } | 1159 | } |
1158 | 1160 | ||
1159 | if (chip->nvram_size) { | 1161 | if (chip->nvram_size) { |