Message ID | 1448395486-10514-1-git-send-email-simon.guinot@sequanux.org |
---|---|
State | Superseded |
Headers | show |
On 24/11/2015 at 21:04:46 +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. > Sure, can you rebase on top of rtc-next and move the whole 'if (want_irq)' block before devm_rtc_device_register()? I think we also probably don't want to set device_set_wakeup_capable(&client->dev, want_irq); when the IRQ request fails. > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org> > --- > drivers/rtc/rtc-ds1307.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c > index 188006c55ce0..732d2afd6489 100644 > --- a/drivers/rtc/rtc-ds1307.c > +++ b/drivers/rtc/rtc-ds1307.c > @@ -1139,6 +1139,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)) { > @@ -1158,7 +1160,6 @@ read_rtc: > goto no_irq; > } > > - set_bit(HAS_ALARM, &ds1307->flags); > dev_dbg(&client->dev, "got IRQ %d\n", client->irq); > > /* Currently supported by OF code only! */ > -- > 2.1.4 >
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 188006c55ce0..732d2afd6489 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -1139,6 +1139,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)) { @@ -1158,7 +1160,6 @@ read_rtc: goto no_irq; } - set_bit(HAS_ALARM, &ds1307->flags); dev_dbg(&client->dev, "got IRQ %d\n", client->irq); /* Currently supported by OF code only! */
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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)