mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <sw617.shin@samsung.com>
To: "'Sam Protsenko'" <semen.protsenko@linaro.org>
Cc: "'Guenter Roeck'" <linux@roeck-us.net>, <krzk@kernel.org>,
	<alim.akhtar@samsung.com>, <wim@linux-watchdog.org>,
	<khwan.seo@samsung.com>, <dongil01.park@samsung.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-samsung-soc@vger.kernel.org>,
	<linux-watchdog@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v4 2/4] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger
Date: Wed, 6 Aug 2025 13:51:00 +0900	[thread overview]
Message-ID: <01e001dc068d$b4b94b70$1e2be250$@samsung.com> (raw)
In-Reply-To: <CAPLW+4mNejXUMW0VqZW8hieNUFmDqS_-qqE=p+bV4TnwM_TWgw@mail.gmail.com>

On Wednesday, August 6, 2025 at 7:53 AM Sam Protsenko <semen.protsenko@linaro.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;
 }


  reply	other threads:[~2025-08-06  4:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250724081336epcas2p30ba9afd1e78d9bbb60f44d24d1cf0acb@epcas2p3.samsung.com>
2025-07-24  8:08 ` [PATCH v4 0/4] Increase max timeout value of s3c2410 watchdog Sangwook Shin
     [not found]   ` <CGME20250724081336epcas2p31c2e3cbed1d3a7bf30a9fb664e6cb92b@epcas2p3.samsung.com>
2025-07-24  8:08     ` [PATCH v4 1/4] watchdog: s3c2410_wdt: Replace hardcoded values with macro definitions Sangwook Shin
     [not found]   ` <CGME20250724081336epcas2p38e95932ddc5c702e05a6436f05582993@epcas2p3.samsung.com>
2025-07-24  8:08     ` [PATCH v4 2/4] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger Sangwook Shin
2025-08-02  4:11       ` Sam Protsenko
2025-08-05  4:22         ` sw617.shin
2025-08-05  4:47           ` Guenter Roeck
2025-08-05  5:03             ` Sam Protsenko
2025-08-05  7:26               ` sw617.shin
2025-08-05 13:30                 ` Guenter Roeck
2025-08-05 22:53                 ` Sam Protsenko
2025-08-06  4:51                   ` sw617.shin [this message]
     [not found]   ` <CGME20250724081337epcas2p31f594b6e9ab87e24c94f11dea4070956@epcas2p3.samsung.com>
2025-07-24  8:08     ` [PATCH v4 3/4] watchdog: s3c2410_wdt: Increase max timeout value of watchdog Sangwook Shin
2025-08-02  4:36       ` Sam Protsenko
2025-08-05  4:23         ` sw617.shin
2025-08-05  4:51           ` Sam Protsenko
     [not found]   ` <CGME20250724081337epcas2p430db7d7514b8cc05e41001f17b8b0d45@epcas2p4.samsung.com>
2025-07-24  8:08     ` [PATCH v4 4/4] watchdog: s3c2410_wdt: exynosautov9: Enable supported features Sangwook Shin
2025-08-02  4:39       ` Sam Protsenko

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='01e001dc068d$b4b94b70$1e2be250$@samsung.com' \
    --to=sw617.shin@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=dongil01.park@samsung.com \
    --cc=khwan.seo@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=semen.protsenko@linaro.org \
    --cc=wim@linux-watchdog.org \
    /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

all inboxes | Powered by JetHome®