From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (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 BBC4E13A86C; Fri, 23 Aug 2024 09:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724405637; cv=none; b=BLt/OZllwYY1+gHA4ioD7DTXPK1dPGYF8e+wJuBQu1O1ZFaooIdE06dki7w3gYMmwW5pZ3U8bHnCJEiC/drhdcuo0dFoK7LjWvWkg0h9K630640GjGmz2pahwfE9ovL3g6hMWG2jGcAdts4yiHUuzObz9QdNVP0tOKccAK/qD98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724405637; c=relaxed/simple; bh=94Oj+6Hrgb9H/+EtnwJQvyp/Aoq0Ek+bMHAQYtZ3rNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YpcKVSAODsysnrIHPnoairFru4PH57Br7l5HcH4yMJRf1vZWI8+YlU30rhg1gMdZrCyFuP4+/YAIcb0QaC9sreBokyDujau55IAUMx5d+QUSrsBhEnr2vwzhz0uejvDwMc8YjVn/BbC9c8X0L4lptZO9aooX+Rp4o31l1HslJWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=MIObJiob; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="MIObJiob" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Type:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VSF0ofpqVbXipZjEn2ptobw3B3A2X9stUgfiIscvRIA=; b=MIObJiobwizHAH4f2xl+A2u+a8 J+AB8MybckpNLriEASHgl19CpzbLeJDJ/sNbbvxT0f7AxAZvto7rgfG6XMZFIiT8X6qm3hDO+1pHx 0gX1jcWYT6RmjkGqS6ELqqmJqQ99JkuDes2StMr/E791bFH86B4SIwzDl+lmhTFYzZx9PrKRo8XYc wgVJo/+5bWQHbKz4WgdQJ+A8RTXU75QuTFFWiBC9HLKgJw0oP3aD06ecgmQaFEODEgk44lCscrXaq OP0cD1euUqu1GrsgnFr/bhGtFgV5L4mnmUzDKGwZ3x1guNrMyx1XhEGvKMP5hZ1MWsxbE+234zYcD C7D95/Lg==; Received: from i5e861933.versanet.de ([94.134.25.51] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shQg5-0003r5-2j; Fri, 23 Aug 2024 11:33:53 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: linus.walleij@linaro.org, brgl@bgdev.pl, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ye Zhang Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, tao.huang@rock-chips.com, finley.xiao@rock-chips.com, tim.chen@rock-chips.com, elaine.zhang@rock-chips.com, Ye Zhang Subject: Re: [PATCH v2] gpio: rockchip: resolve overflow issues Date: Fri, 23 Aug 2024 11:34:34 +0200 Message-ID: <2735393.uZKlY2gecq@diego> In-Reply-To: <20240823034314.62305-4-ye.zhang@rock-chips.com> References: <20240823034314.62305-1-ye.zhang@rock-chips.com> <20240823034314.62305-4-ye.zhang@rock-chips.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Am Freitag, 23. August 2024, 05:43:06 CEST schrieb Ye Zhang: > Prevent overflow issues when performing debounce-related calculations. Please add some more explanation here. I.e. something about previous max_debounce calculation does overflow the type of max_debounce Thanks Heiko > Fixes: 3bcbd1a85b68 ("gpio/rockchip: support next version gpio controller") > Signed-off-by: Ye Zhang > --- > drivers/gpio/gpio-rockchip.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c > index 5f60162baaeb..bf22b103b6a2 100644 > --- a/drivers/gpio/gpio-rockchip.c > +++ b/drivers/gpio/gpio-rockchip.c > @@ -209,11 +209,12 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc, > freq = clk_get_rate(bank->db_clk); > if (!freq) > return -EINVAL; > - max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq; > + div = (u64)(GENMASK(23, 0) + 1) * 2 * 1000000; > + max_debounce = DIV_ROUND_CLOSEST_ULL(div, freq); > if (debounce > max_debounce) > return -EINVAL; > > - div = debounce * freq; > + div = (u64)debounce * freq; > div_reg = DIV_ROUND_CLOSEST_ULL(div, 2 * USEC_PER_SEC) - 1; > } else { > div_debounce_support = false; >