[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <01e001dc068d$b4b94b70$1e2be250$@samsung.com>
Date: Wed, 6 Aug 2025 13:51:00 +0900
From: <sw617.shin@...sung.com>
To: "'Sam Protsenko'" <semen.protsenko@...aro.org>
Cc: "'Guenter Roeck'" <linux@...ck-us.net>, <krzk@...nel.org>,
<alim.akhtar@...sung.com>, <wim@...ux-watchdog.org>,
<khwan.seo@...sung.com>, <dongil01.park@...sung.com>,
<linux-arm-kernel@...ts.infradead.org>, <linux-samsung-soc@...r.kernel.org>,
<linux-watchdog@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4 2/4] watchdog: s3c2410_wdt: Fix max_timeout being
calculated larger
On Wednesday, August 6, 2025 at 7:53 AM Sam Protsenko <semen.protsenko@...aro.org> wrote:
>
> I don't mind, although it's quite easy to fix the code I suggested by
> replacing this line:
>
> u64 t_max = n_max / freq;
>
> with this one:
>
> u64 t_max = div64_ul(n_max, freq);
>
> from <math64.h>, as Guenter suggested. But I'm totally fine with your
> implementation as well.
Sam Protsenko and Guenter Roeck, thank you for your kind advice.
As you mentioned, I will proceed with the following code for the next patch set.
@@ -27,6 +27,7 @@
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/delay.h>
+#include <linux/math64.h>
#define S3C2410_WTCON 0x00
#define S3C2410_WTDAT 0x04
@@ -410,9 +411,13 @@ static inline unsigned long s3c2410wdt_get_freq(struct s3c2410_wdt *wdt)
static inline unsigned int s3c2410wdt_max_timeout(struct s3c2410_wdt *wdt)
{
const unsigned long freq = s3c2410wdt_get_freq(wdt);
+ //(S3C2410_WTCON_PRESCALE_MAX + 1) * S3C2410_WTCON_MAXDIV = 0x8000
+ u64 t_max = div64_ul((u64)S3C2410_WTCNT_MAXCNT * 0x8000, freq);
- return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1)
- / S3C2410_WTCON_MAXDIV);
+ if (t_max > UINT_MAX)
+ t_max = UINT_MAX;
+
+ return t_max;
}
Powered by blists - more mailing lists