diff mbox series

[7/7] rtc: rzn1: Report maximum alarm limit to rtc core

Message ID 20230816133936.2150294-8-linux@roeck-us.net
State Superseded
Headers show
Series rtc: Add support for limited alarm timer offsets | expand

Commit Message

Guenter Roeck Aug. 16, 2023, 1:39 p.m. UTC
RZN1 only supports alarms up to one week in the future.
Report the limit to the RTC core.

Cc: Brian Norris <briannorris@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/rtc/rtc-rzn1.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Miquel Raynal Aug. 17, 2023, 8:03 a.m. UTC | #1
Hi Guenter,

linux@roeck-us.net wrote on Wed, 16 Aug 2023 06:39:36 -0700:

> RZN1 only supports alarms up to one week in the future.
> Report the limit to the RTC core.
> 
> Cc: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/rtc/rtc-rzn1.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index dca736caba85..c2cc3774ebb8 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -351,6 +351,7 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  
>  	rtc->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000;
>  	rtc->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
> +	rtc->rtcdev->range_max_offset = 7 * 86400;

When we set the alarm, we use:

	farest = rtc_tm_to_time64(&tm_now) + (7 * 86400);

What about using range_max_offset (whatever its final name) in this
calculation as it will be now set in probe? It would further clarify
its purpose.

>  	rtc->rtcdev->ops = &rzn1_rtc_ops;
>  	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
>  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);

With the above change,

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl
Guenter Roeck Aug. 17, 2023, 1:43 p.m. UTC | #2
On Thu, Aug 17, 2023 at 10:03:41AM +0200, Miquel Raynal wrote:
> Hi Guenter,
> 
> linux@roeck-us.net wrote on Wed, 16 Aug 2023 06:39:36 -0700:
> 
> > RZN1 only supports alarms up to one week in the future.
> > Report the limit to the RTC core.
> > 
> > Cc: Brian Norris <briannorris@chromium.org>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> >  drivers/rtc/rtc-rzn1.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> > index dca736caba85..c2cc3774ebb8 100644
> > --- a/drivers/rtc/rtc-rzn1.c
> > +++ b/drivers/rtc/rtc-rzn1.c
> > @@ -351,6 +351,7 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
> >  
> >  	rtc->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000;
> >  	rtc->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
> > +	rtc->rtcdev->range_max_offset = 7 * 86400;
> 
> When we set the alarm, we use:
> 
> 	farest = rtc_tm_to_time64(&tm_now) + (7 * 86400);
> 
> What about using range_max_offset (whatever its final name) in this
> calculation as it will be now set in probe? It would further clarify
> its purpose.

Excellent idea. I'll make that change.

Thanks,
Guenter

> 
> >  	rtc->rtcdev->ops = &rzn1_rtc_ops;
> >  	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
> >  	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);
> 
> With the above change,
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> 
> Thanks,
> Miquèl
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index dca736caba85..c2cc3774ebb8 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -351,6 +351,7 @@  static int rzn1_rtc_probe(struct platform_device *pdev)
 
 	rtc->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000;
 	rtc->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
+	rtc->rtcdev->range_max_offset = 7 * 86400;
 	rtc->rtcdev->ops = &rzn1_rtc_ops;
 	set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
 	clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);