From: Tomas Melin <tomas.melin@vaisala.com>
To: "T, Harini" <Harini.T@amd.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
"Simek, Michal" <michal.simek@amd.com>
Cc: "linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] rtc: zynqmp: use dynamic max and min offset ranges
Date: Wed, 10 Dec 2025 14:25:27 +0200 [thread overview]
Message-ID: <ea85c8d6-ead8-4fda-905d-909968de5056@vaisala.com> (raw)
In-Reply-To: <LV5PR12MB98046A63E80D7A7FA299366E92A3A@LV5PR12MB9804.namprd12.prod.outlook.com>
Hi,
On 09/12/2025 21:28, T, Harini wrote:
> [Public]
>
> Hi,
>
>> -----Original Message-----
>> From: Tomas Melin <tomas.melin@vaisala.com>
>> Sent: Monday, December 1, 2025 6:20 PM
>> To: Alexandre Belloni <alexandre.belloni@bootlin.com>; Simek, Michal
>> <michal.simek@amd.com>
>> Cc: linux-rtc@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
>> kernel@vger.kernel.org; Tomas Melin <tomas.melin@vaisala.com>
>> Subject: [PATCH 4/4] rtc: zynqmp: use dynamic max and min offset ranges
>>
>> Caution: This message originated from an External Source. Use proper
>> caution when opening attachments, clicking links, or responding.
>>
>>
>> Maximum and minimum offsets in ppb that can be handled are dependent
>> on the rtc clock frequency and what can fit in the 16-bit register field.
>>
>> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
>> ---
>> drivers/rtc/rtc-zynqmp.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c index
>> 3bc8831ba2c4c4c701a49506b67ae6174f3ade3d..0cebc99b15a6de2440a60afc
>> 2bd1769eccfa84b3 100644
>> --- a/drivers/rtc/rtc-zynqmp.c
>> +++ b/drivers/rtc/rtc-zynqmp.c
>> @@ -44,8 +44,6 @@
>> #define RTC_FR_MASK 0xF0000
>> #define RTC_FR_MAX_TICKS 16
>> #define RTC_PPB 1000000000LL
>> -#define RTC_MIN_OFFSET -32768000
>> -#define RTC_MAX_OFFSET 32767000
>>
>> struct xlnx_rtc_dev {
>> struct rtc_device *rtc;
>> @@ -215,12 +213,12 @@ static int xlnx_rtc_set_offset(struct device *dev,
>> long offset)
>>
>> /* ticks to reach RTC_PPB */
>> tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, xrtcdev->freq);
>> - if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
>> - return -ERANGE;
>> -
>> /* Number ticks for given offset */
>> max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
>>
>> + if (freq + max_tick > RTC_TICK_MASK || (freq + max_tick < 1))
> The check 'freq + max_tick < 1' should be '<2' to prevent writing 0 to the calibration register when fract_offset < 0 causes max_tick--.
> Example: freq=32767, max_tick=-32766 passes (sum=1), but after decrement becomes calibval=0.
calibval=0 is not documented as invalid calibration value. AFAIS it
would mean a frequency of 1Hz. Can You provide more info on this?
Thanks,
Tomas
>> + return -ERANGE;
>> +
>> /* Number fractional ticks for given offset */
>> if (fract_offset) {
>> /* round up here so we stay below a full tick */
>>
>> --
>> 2.47.3
>>
>
> Thanks,
> Harini T
>
next prev parent reply other threads:[~2025-12-10 12:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 12:50 [PATCH 0/4] rtc: zynqmp: fixes for read and set offset Tomas Melin
2025-12-01 12:50 ` [PATCH 1/4] rtc: zynqmp: correct frequency value Tomas Melin
2025-12-09 16:51 ` T, Harini
2025-12-10 12:29 ` Tomas Melin
2025-12-01 12:50 ` [PATCH 2/4] rtc: zynqmp: rework read_offset Tomas Melin
2025-12-09 17:28 ` T, Harini
2025-12-10 12:04 ` Tomas Melin
2025-12-17 18:14 ` T, Harini
2025-12-17 19:17 ` Alexandre Belloni
2025-12-01 12:50 ` [PATCH 3/4] rtc: zynqmp: rework set_offset Tomas Melin
2025-12-09 19:03 ` T, Harini
2025-12-10 12:18 ` Tomas Melin
2025-12-17 18:33 ` T, Harini
2025-12-01 12:50 ` [PATCH 4/4] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin
2025-12-09 19:28 ` T, Harini
2025-12-10 12:25 ` Tomas Melin [this message]
2025-12-17 19:03 ` T, Harini
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=ea85c8d6-ead8-4fda-905d-909968de5056@vaisala.com \
--to=tomas.melin@vaisala.com \
--cc=Harini.T@amd.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=michal.simek@amd.com \
/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).