* [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
2026-01-21 12:11 ` Michal Simek
2026-01-21 12:16 ` Michal Simek
2026-01-19 9:51 ` [PATCH v3 2/6] rtc: zynqmp: correct frequency value Tomas Melin
` (4 subsequent siblings)
5 siblings, 2 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin,
kernel test robot
Driver is compatible with RTC controller found on zynqmp.
Configure dependency to enable building only when zynqmp architecture
is enabled.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 2933c41c77c88e60df721fe65b9c8afb995ae51e..46b497524cbfb5d0c1662dcaddbb6d28b4ae2abe 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1376,7 +1376,7 @@ config RTC_DRV_OPTEE
config RTC_DRV_ZYNQMP
tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
- depends on OF && HAS_IOMEM
+ depends on OF && HAS_IOMEM && ARCH_ZYNQMP
help
If you say yes here you get support for the RTC controller found on
Xilinx Zynq Ultrascale+ MPSoC.
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch
2026-01-19 9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
@ 2026-01-21 12:11 ` Michal Simek
2026-01-21 12:16 ` Michal Simek
1 sibling, 0 replies; 11+ messages in thread
From: Michal Simek @ 2026-01-21 12:11 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni
Cc: linux-rtc, linux-arm-kernel, linux-kernel, kernel test robot
On 1/19/26 10:51, Tomas Melin wrote:
> Driver is compatible with RTC controller found on zynqmp.
> Configure dependency to enable building only when zynqmp architecture
> is enabled.
>
> Reported-by: kernel test robot <lkp@intel.com>
do you have any link what exactly has been reported?
M
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
> drivers/rtc/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 2933c41c77c88e60df721fe65b9c8afb995ae51e..46b497524cbfb5d0c1662dcaddbb6d28b4ae2abe 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1376,7 +1376,7 @@ config RTC_DRV_OPTEE
>
> config RTC_DRV_ZYNQMP
> tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
> - depends on OF && HAS_IOMEM
> + depends on OF && HAS_IOMEM && ARCH_ZYNQMP
> help
> If you say yes here you get support for the RTC controller found on
> Xilinx Zynq Ultrascale+ MPSoC.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch
2026-01-19 9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
2026-01-21 12:11 ` Michal Simek
@ 2026-01-21 12:16 ` Michal Simek
2026-01-22 12:25 ` Tomas Melin
1 sibling, 1 reply; 11+ messages in thread
From: Michal Simek @ 2026-01-21 12:16 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni
Cc: linux-rtc, linux-arm-kernel, linux-kernel, kernel test robot
On 1/19/26 10:51, Tomas Melin wrote:
> Driver is compatible with RTC controller found on zynqmp.
> Configure dependency to enable building only when zynqmp architecture
> is enabled.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
> drivers/rtc/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 2933c41c77c88e60df721fe65b9c8afb995ae51e..46b497524cbfb5d0c1662dcaddbb6d28b4ae2abe 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1376,7 +1376,7 @@ config RTC_DRV_OPTEE
>
> config RTC_DRV_ZYNQMP
> tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
> - depends on OF && HAS_IOMEM
> + depends on OF && HAS_IOMEM && ARCH_ZYNQMP
arm-linux-gnueabi-ld: drivers/rtc/rtc-zynqmp.o: in function
`xlnx_rtc_read_offset':
>> rtc-zynqmp.c:(.text.xlnx_rtc_read_offset+0xd0): undefined reference to
`__aeabi_ldivmod'
You should use macros like div_u64() to fix it instead of have driver enabled
only for ZynqMP.
M
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch
2026-01-21 12:16 ` Michal Simek
@ 2026-01-22 12:25 ` Tomas Melin
2026-01-22 12:38 ` Michal Simek
0 siblings, 1 reply; 11+ messages in thread
From: Tomas Melin @ 2026-01-22 12:25 UTC (permalink / raw)
To: Michal Simek, Alexandre Belloni
Cc: linux-rtc, linux-arm-kernel, linux-kernel, kernel test robot
Hi,
On 21/01/2026 14:16, Michal Simek wrote:
>
>
> On 1/19/26 10:51, Tomas Melin wrote:
>> Driver is compatible with RTC controller found on zynqmp.
>> Configure dependency to enable building only when zynqmp architecture
>> is enabled.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
>> ---
>> drivers/rtc/Kconfig | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
>> index 2933c41c77c88e60df721fe65b9c8afb995ae51e..46b497524cbfb5d0c1662dcaddbb6d28b4ae2abe 100644
>> --- a/drivers/rtc/Kconfig
>> +++ b/drivers/rtc/Kconfig
>> @@ -1376,7 +1376,7 @@ config RTC_DRV_OPTEE
>>
>> config RTC_DRV_ZYNQMP
>> tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
>> - depends on OF && HAS_IOMEM
>> + depends on OF && HAS_IOMEM && ARCH_ZYNQMP
>
>
> arm-linux-gnueabi-ld: drivers/rtc/rtc-zynqmp.o: in function
> `xlnx_rtc_read_offset':
> >> rtc-zynqmp.c:(.text.xlnx_rtc_read_offset+0xd0): undefined reference to
> `__aeabi_ldivmod'
>
> You should use macros like div_u64() to fix it instead of have driver enabled
> only for ZynqMP.
I can do it that way if you prefer such approach.
Thanks,
Tomas
>
> M
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch
2026-01-22 12:25 ` Tomas Melin
@ 2026-01-22 12:38 ` Michal Simek
0 siblings, 0 replies; 11+ messages in thread
From: Michal Simek @ 2026-01-22 12:38 UTC (permalink / raw)
To: Tomas Melin, Alexandre Belloni
Cc: linux-rtc, linux-arm-kernel, linux-kernel, kernel test robot
On 1/22/26 13:25, Tomas Melin wrote:
> Hi,
>
> On 21/01/2026 14:16, Michal Simek wrote:
>>
>>
>> On 1/19/26 10:51, Tomas Melin wrote:
>>> Driver is compatible with RTC controller found on zynqmp.
>>> Configure dependency to enable building only when zynqmp architecture
>>> is enabled.
>>>
>>> Reported-by: kernel test robot <lkp@intel.com>
>>> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
>>> ---
>>> drivers/rtc/Kconfig | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
>>> index 2933c41c77c88e60df721fe65b9c8afb995ae51e..46b497524cbfb5d0c1662dcaddbb6d28b4ae2abe 100644
>>> --- a/drivers/rtc/Kconfig
>>> +++ b/drivers/rtc/Kconfig
>>> @@ -1376,7 +1376,7 @@ config RTC_DRV_OPTEE
>>>
>>> config RTC_DRV_ZYNQMP
>>> tristate "Xilinx Zynq Ultrascale+ MPSoC RTC"
>>> - depends on OF && HAS_IOMEM
>>> + depends on OF && HAS_IOMEM && ARCH_ZYNQMP
>>
>>
>> arm-linux-gnueabi-ld: drivers/rtc/rtc-zynqmp.o: in function
>> `xlnx_rtc_read_offset':
>> >> rtc-zynqmp.c:(.text.xlnx_rtc_read_offset+0xd0): undefined reference to
>> `__aeabi_ldivmod'
>>
>> You should use macros like div_u64() to fix it instead of have driver enabled
>> only for ZynqMP.
> I can do it that way if you prefer such approach.
Definitely because this driver could be called from different architectures.
RISC-V or x86.
Thanks,
Michal
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 2/6] rtc: zynqmp: correct frequency value
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
2026-01-19 9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
2026-01-19 9:51 ` [PATCH v3 3/6] rtc: zynqmp: check calibration max value Tomas Melin
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
Fix calibration value in case a clock reference is provided.
The actual calibration value written into register is
frequency - 1.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 3baa2b481d9f2008750046005283b98a0d546c5c..856bc1678e7d31144f320ae9f75fc58c742a2a64 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -345,7 +345,10 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
&xrtcdev->freq);
if (ret)
xrtcdev->freq = RTC_CALIB_DEF;
+ } else {
+ xrtcdev->freq--;
}
+
ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
if (!ret)
writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 3/6] rtc: zynqmp: check calibration max value
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
2026-01-19 9:51 ` [PATCH v3 1/6] rtc: zynqmp: declare dependency on arch Tomas Melin
2026-01-19 9:51 ` [PATCH v3 2/6] rtc: zynqmp: correct frequency value Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
2026-01-19 9:51 ` [PATCH v3 4/6] rtc: zynqmp: rework read_offset Tomas Melin
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
Enable check to not overflow the calibration
max value.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 856bc1678e7d31144f320ae9f75fc58c742a2a64..caacce3725e2ef3803ea42d40e77ceaeb7d7b914 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -349,6 +349,11 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
xrtcdev->freq--;
}
+ if (xrtcdev->freq > RTC_TICK_MASK) {
+ dev_err(&pdev->dev, "Invalid RTC calibration value\n");
+ return -EINVAL;
+ }
+
ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
if (!ret)
writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 4/6] rtc: zynqmp: rework read_offset
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (2 preceding siblings ...)
2026-01-19 9:51 ` [PATCH v3 3/6] rtc: zynqmp: check calibration max value Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
2026-01-19 9:51 ` [PATCH v3 5/6] rtc: zynqmp: rework set_offset Tomas Melin
2026-01-19 9:51 ` [PATCH v3 6/6] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin
5 siblings, 0 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
read_offset() was using static frequency for determining
the tick offset. It was also using remainder from do_div()
operation as tick_mult value which caused the offset to be
incorrect.
At the same time, rework function to improve readability.
It is worth noting, that due to rounding errors, the offset
readback will differ slightly for positive and negative
calibration values.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index caacce3725e2ef3803ea42d40e77ceaeb7d7b914..6740c3aed1897d4b50a02c4823a746d9c2ae2655 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -178,21 +178,28 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev)
static int xlnx_rtc_read_offset(struct device *dev, long *offset)
{
struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
- unsigned long long rtc_ppb = RTC_PPB;
- unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
- unsigned int calibval;
+ unsigned int calibval, fract_data, fract_part;
+ int freq = xrtcdev->freq;
+ int max_tick, tick_mult;
long offset_val;
+ /* Tick to offset multiplier */
+ tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, freq);
+
calibval = readl(xrtcdev->reg_base + RTC_CALIB_RD);
/* Offset with seconds ticks */
- offset_val = calibval & RTC_TICK_MASK;
- offset_val = offset_val - RTC_CALIB_DEF;
- offset_val = offset_val * tick_mult;
+ max_tick = calibval & RTC_TICK_MASK;
+ offset_val = max_tick - freq;
+ /* Convert to ppb */
+ offset_val *= tick_mult;
/* Offset with fractional ticks */
- if (calibval & RTC_FR_EN)
- offset_val += ((calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT)
- * (tick_mult / RTC_FR_MAX_TICKS);
+ if (calibval & RTC_FR_EN) {
+ fract_data = (calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT;
+ fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
+ offset_val += (fract_part * fract_data);
+ }
+
*offset = offset_val;
return 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 5/6] rtc: zynqmp: rework set_offset
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (3 preceding siblings ...)
2026-01-19 9:51 ` [PATCH v3 4/6] rtc: zynqmp: rework read_offset Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
2026-01-19 9:51 ` [PATCH v3 6/6] rtc: zynqmp: use dynamic max and min offset ranges Tomas Melin
5 siblings, 0 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
set_offset was using remainder of do_div as tick_mult which resulted in
wrong offset. Calibration value also assumed builtin calibration default.
Update fract_offset to correctly calculate the value for
negative offset and replace the for loop with division.
Tested-by: Harini T <harini.t@amd.com>
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
drivers/rtc/rtc-zynqmp.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 6740c3aed1897d4b50a02c4823a746d9c2ae2655..1bc957b3a9058aa1d809696c13662ecef0437a92 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -208,13 +208,13 @@ static int xlnx_rtc_read_offset(struct device *dev, long *offset)
static int xlnx_rtc_set_offset(struct device *dev, long offset)
{
struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
- unsigned long long rtc_ppb = RTC_PPB;
- unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
- unsigned char fract_tick = 0;
+ int max_tick, tick_mult, fract_offset, fract_part;
+ int freq = xrtcdev->freq;
unsigned int calibval;
- short int max_tick;
- int fract_offset;
+ int fract_data = 0;
+ /* Tick to offset multiplier */
+ tick_mult = DIV_ROUND_CLOSEST(RTC_PPB, xrtcdev->freq);
if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
return -ERANGE;
@@ -223,29 +223,22 @@ static int xlnx_rtc_set_offset(struct device *dev, long offset)
/* Number fractional ticks for given offset */
if (fract_offset) {
- if (fract_offset < 0) {
- fract_offset = fract_offset + tick_mult;
+ fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
+ fract_data = fract_offset / fract_part;
+ /* Subtract one from max_tick while adding fract_offset */
+ if (fract_offset < 0 && fract_data) {
max_tick--;
- }
- if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
- for (fract_tick = 1; fract_tick < 16; fract_tick++) {
- if (fract_offset <=
- (fract_tick *
- (tick_mult / RTC_FR_MAX_TICKS)))
- break;
- }
+ fract_data += RTC_FR_MAX_TICKS;
}
}
/* Zynqmp RTC uses second and fractional tick
* counters for compensation
*/
- calibval = max_tick + RTC_CALIB_DEF;
-
- if (fract_tick)
- calibval |= RTC_FR_EN;
+ calibval = max_tick + freq;
- calibval |= (fract_tick << RTC_FR_DATSHIFT);
+ if (fract_data)
+ calibval |= (RTC_FR_EN | (fract_data << RTC_FR_DATSHIFT));
writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 6/6] rtc: zynqmp: use dynamic max and min offset ranges
2026-01-19 9:51 [PATCH v3 0/6] rtc: zynqmp: fixes for read and set offset Tomas Melin
` (4 preceding siblings ...)
2026-01-19 9:51 ` [PATCH v3 5/6] rtc: zynqmp: rework set_offset Tomas Melin
@ 2026-01-19 9:51 ` Tomas Melin
5 siblings, 0 replies; 11+ messages in thread
From: Tomas Melin @ 2026-01-19 9:51 UTC (permalink / raw)
To: Alexandre Belloni, Michal Simek
Cc: linux-rtc, linux-arm-kernel, linux-kernel, Tomas Melin, Harini T
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.
Reviewed-by: Harini T <harini.t@amd.com>
Tested-by: Harini T <harini.t@amd.com>
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 1bc957b3a9058aa1d809696c13662ecef0437a92..8fc2f838707c32297e812ef1b8a195ff55f849e3 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)
/* Tick to offset multiplier */
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))
+ return -ERANGE;
+
/* Number fractional ticks for given offset */
if (fract_offset) {
fract_part = DIV_ROUND_UP(tick_mult, RTC_FR_MAX_TICKS);
--
2.47.3
^ permalink raw reply related [flat|nested] 11+ messages in thread