linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Benson Leung <bleung@chromium.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brian Norris <briannorris@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH v2 7/7] rtc: rzn1: Report maximum alarm limit to rtc core
Date: Thu, 17 Aug 2023 15:55:37 -0700	[thread overview]
Message-ID: <20230817225537.4053865-8-linux@roeck-us.net> (raw)
In-Reply-To: <20230817225537.4053865-1-linux@roeck-us.net>

RZN1 only supports alarms up to one week in the future.
Report the limit to the RTC core and use the reported limit
to validate the requested alarm time when setting it.

Cc: Brian Norris <briannorris@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rename range_max_offset -> alarm_offset_max
    Use the new variable to validate the limit when setting the alarm

 drivers/rtc/rtc-rzn1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
index dca736caba85..c0f448bce145 100644
--- a/drivers/rtc/rtc-rzn1.c
+++ b/drivers/rtc/rtc-rzn1.c
@@ -227,7 +227,7 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 		return ret;
 
 	/* We cannot set alarms more than one week ahead */
-	farest = rtc_tm_to_time64(&tm_now) + (7 * 86400);
+	farest = rtc_tm_to_time64(&tm_now) + rtc->rtcdev->alarm_offset_max;
 	alarm = rtc_tm_to_time64(tm);
 	if (time_after(alarm, farest))
 		return -ERANGE;
@@ -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->alarm_offset_max = 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);
-- 
2.39.2


  parent reply	other threads:[~2023-08-17 22:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 22:55 [PATCH v2 0/7] rtc: Add support for limited alarm timer offsets Guenter Roeck
2023-08-17 22:55 ` [PATCH v2 1/7] " Guenter Roeck
2023-08-23 16:50   ` Guenter Roeck
2023-08-23 22:51     ` Alexandre Belloni
2023-08-24  3:26       ` Guenter Roeck
2023-08-17 22:55 ` [PATCH v2 2/7] rtc: alarmtimer: Use maximum alarm time offset Guenter Roeck
2023-08-25  3:52   ` John Stultz
2023-08-25  5:46     ` Guenter Roeck
2023-08-26 11:15     ` Guenter Roeck
2023-08-29 21:50   ` Stephen Boyd
2023-08-30  7:13     ` Guenter Roeck
2023-08-30 21:16       ` Stephen Boyd
2023-08-31  4:23         ` Guenter Roeck
2023-09-06 21:06           ` Stephen Boyd
2023-08-17 22:55 ` [PATCH v2 3/7] rtc: cros-ec: Detect and report supported alarm window size Guenter Roeck
2023-08-17 22:55 ` [PATCH v2 4/7] rtc: cmos: Report supported alarm limit to rtc infrastructure Guenter Roeck
2023-08-17 22:55 ` [PATCH v2 5/7] rtc: tps6586x: Report maximum alarm limit to rtc core Guenter Roeck
2023-08-17 22:55 ` [PATCH v2 6/7] rtc: ds1305: " Guenter Roeck
2023-08-17 22:55 ` Guenter Roeck [this message]
2023-08-18  7:32   ` [PATCH v2 7/7] rtc: rzn1: " Miquel Raynal
2023-08-27 21:51 ` (subset) [PATCH v2 0/7] rtc: Add support for limited alarm timer offsets Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230817225537.4053865-8-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bleung@chromium.org \
    --cc=briannorris@chromium.org \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).