Message ID | 1448548633-651-1-git-send-email-simon.guinot@sequanux.org |
---|---|
State | Accepted |
Headers | show |
On 26/11/2015 at 15:37:13 +0100, Simon Guinot wrote : > 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 | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > Applied, thanks.
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: bin2bcd(tmp)); } - device_set_wakeup_capable(&client->dev, want_irq); + if (want_irq) { + device_set_wakeup_capable(&client->dev, true); + 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)) { @@ -1148,12 +1151,11 @@ read_rtc: ds1307->rtc->name, client); if (err) { client->irq = 0; + device_set_wakeup_capable(&client->dev, false); + clear_bit(HAS_ALARM, &ds1307->flags); 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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) Changes for v2: - Rebase against the branch rtc-fixes. Changes for v3: - Clear the device wake-up capability and the HAS_ALARM flag if the IRQ request fails.