From nobody Sat Oct 4 12:49:00 2025 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 718122571A5 for ; Mon, 18 Aug 2025 02:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755483884; cv=none; b=GOOGtOvPhgT1tr7MuH8M3mLPbqdvY3zKod97Uj2PlMtA0gQBCbuzxsHcYRWYDYTfy6t8Di121zN8shCsH/C88XSsZmnnMi0UsC+YS3P8c5TRBMlSLKJN9Pf4JQAuS/AGdB4kNSVWka9snYC9kNj4ChEOLW22jyijl1zENhsgEu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755483884; c=relaxed/simple; bh=6JccX6rb/Pl5uPrlz/pFSYC+n7076GYlHeFGHkCmUKM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=G46QEOB8GYqMd8gv+QG4tHLjMbxoES9uRBR7eWoYuCVBGfkk96ipIXF6iyHOQMF3T3H6jzHgfFe2DZF1x0Jzmeu4GYUU1HUnkYDgLitmlt+iU6rFLvVDm+kuvi8AoATfQjgVMAyeteulkQaTKuMSiVibULCZkEjvMazNdwSz7sY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=dHehWi6Z; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="dHehWi6Z" Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20250818022435epoutp01dd98f78756bb86695a98d31276b102ea~cu0iTBDkM0677106771epoutp01t for ; Mon, 18 Aug 2025 02:24:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20250818022435epoutp01dd98f78756bb86695a98d31276b102ea~cu0iTBDkM0677106771epoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1755483875; bh=Gy16/RzPndx2WyvU5JaijoXqsjTfpeBr39YjjbSjy/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHehWi6ZCuJbWIzKCKNgzqfpn1hx9JCeP97HYRu6Jn+hLbn4TvbEiUJzLl0RdsPTF Gv12+rWp2CFHqqYpW6sNiqquJfZmgAFzOToFd9kQ2TbnMlkIiWnKcy3qHShctJTn5W WMOeubMWFX/Ed7t7zpxMVhcsPdPKDAX/gomry7KI= Received: from epsnrtp02.localdomain (unknown [182.195.42.154]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPS id 20250818022434epcas2p4fd13107b3298d90fa381ff9498342688~cu0hzlEwe2945429454epcas2p4X; Mon, 18 Aug 2025 02:24:34 +0000 (GMT) Received: from epcas2p2.samsung.com (unknown [182.195.36.99]) by epsnrtp02.localdomain (Postfix) with ESMTP id 4c4xPG24nDz2SSKf; Mon, 18 Aug 2025 02:24:34 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c~cu0gxZS4m0148401484epcas2p3R; Mon, 18 Aug 2025 02:24:33 +0000 (GMT) Received: from localhost.localdomain (unknown [10.229.9.126]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250818022433epsmtip134777d3422bc84da61719ae40059d335~cu0gsjRKQ2020320203epsmtip1O; Mon, 18 Aug 2025 02:24:33 +0000 (GMT) From: Sangwook Shin To: krzk@kernel.org, alim.akhtar@samsung.com, wim@linux-watchdog.org, linux@roeck-us.net, semen.protsenko@linaro.org, dongil01.park@samsung.com, khwan.seo@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Sangwook Shin Subject: [PATCH v6 2/5] watchdog: s3c2410_wdt: Fix max_timeout being calculated larger Date: Mon, 18 Aug 2025 11:18:23 +0900 Message-Id: <20250818021826.623830-3-sw617.shin@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250818021826.623830-1-sw617.shin@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMS-MailID: 20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P cpgsPolicy: CPGSC10-234,N X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250818022433epcas2p3fc48febfa6729645af6ebd088937c80c References: <20250818021826.623830-1-sw617.shin@samsung.com> Fix the issue of max_timeout being calculated larger than actual value. The calculation result of freq / (S3C2410_WTCON_PRESCALE_MAX + 1) / S3C2410_WTCON_MAXDIV is smaller than the actual value because the remainder is discarded during the calculation process. This leads to a larger calculated value for max_timeout compared to the actual settable value. To resolve this issue, the order of calculations in the computation process has been adjusted. Reviewed-by: Sam Protsenko Signed-off-by: Sangwook Shin Reviewed-by: Alim Akhtar Reviewed-by: Guenter Roeck --- drivers/watchdog/s3c2410_wdt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 95f7207e390a..1e8cf0299713 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -27,6 +27,7 @@ #include #include #include +#include =20 #define S3C2410_WTCON 0x00 #define S3C2410_WTDAT 0x04 @@ -410,9 +411,14 @@ 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 =3D s3c2410wdt_get_freq(wdt); + const u64 n_max =3D (u64)(S3C2410_WTCON_PRESCALE_MAX + 1) * + S3C2410_WTCON_MAXDIV * S3C2410_WTCNT_MAXCNT; + u64 t_max =3D div64_ul(n_max, freq); =20 - return S3C2410_WTCNT_MAXCNT / (freq / (S3C2410_WTCON_PRESCALE_MAX + 1) - / S3C2410_WTCON_MAXDIV); + if (t_max > UINT_MAX) + t_max =3D UINT_MAX; + + return t_max; } =20 static int s3c2410wdt_disable_wdt_reset(struct s3c2410_wdt *wdt, bool mask) --=20 2.25.1