All of lore.kernel.org
 help / color / mirror / Atom feed
* [rtc-linux] [PATCH] rtc: ds1307: fix alarm reading at probe time
@ 2015-11-24 20:04 Simon Guinot
  2015-11-25 11:07 ` [rtc-linux] " Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Guinot @ 2015-11-24 20:04 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: rtc-linux, Vincent Donnefort, Yoann Sculo, Simon Guinot

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(-)

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

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [rtc-linux] Re: [PATCH] rtc: ds1307: fix alarm reading at probe time
  2015-11-24 20:04 [rtc-linux] [PATCH] rtc: ds1307: fix alarm reading at probe time Simon Guinot
@ 2015-11-25 11:07 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2015-11-25 11:07 UTC (permalink / raw)
  To: Simon Guinot; +Cc: Alessandro Zummo, rtc-linux, Vincent Donnefort, Yoann Sculo

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
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-25 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24 20:04 [rtc-linux] [PATCH] rtc: ds1307: fix alarm reading at probe time Simon Guinot
2015-11-25 11:07 ` [rtc-linux] " Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.