lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cb827883-1d3c-4d9f-8523-c2186c1c0a2b@vaisala.com>
Date: Thu, 15 Jan 2026 09:24:12 +0200
From: Tomas Melin <tomas.melin@...sala.com>
To: "T, Harini" <Harini.T@....com>,
 Alexandre Belloni <alexandre.belloni@...tlin.com>,
 "Simek, Michal" <michal.simek@....com>
Cc: "linux-rtc@...r.kernel.org" <linux-rtc@...r.kernel.org>,
 "linux-arm-kernel@...ts.infradead.org"
 <linux-arm-kernel@...ts.infradead.org>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 4/5] rtc: zynqmp: rework set_offset

Hi,


On 14/01/2026 17:37, T, Harini wrote:
>> +++ 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;
>>         unsigned int calibval;
>> -       short int  max_tick;
>> -       int fract_offset;
>> +       int fract_data = 0;
>> +       int freq = xrtcdev->freq;
> Please follow reverse XMAS tree style.
I can fix this with a follow up version.

Thanks,
Tomas



>>
>> +       /* 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
>>
> 
> Thanks,
> Harini T


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ