Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1965951pxb; Wed, 9 Feb 2022 08:11:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHsOXJpOXh+N67NLX51CnyLU7KzkMsLiHlCmMmM8Tq/pYQhg4fm7FLX/PsGvOMQy8EflaM X-Received: by 2002:a63:f156:: with SMTP id o22mr2361427pgk.387.1644423095020; Wed, 09 Feb 2022 08:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644423095; cv=none; d=google.com; s=arc-20160816; b=nPHMsGC4okM4fkVdBnWZyHikgGsHJpVNSsWA1EZlmzIAbAaq1srhJ+kac+/DMnD/gn jV1Mfhj26llvzQSUUx4+XueFOVQZpWohdKWf5CxnRYad0qCgY5w1jae/c8RP3kbNNDeO JMFhhw+g26nM57zL3gMPtodhuh7u6VkPfvShz984Btd4TBuGdStmJ6fG6VHmsJrb86N9 fA5z3shCIzRVnmW5h4vEAwPI+2Z31uIzD5IxUaVN+DBcolPTP1icHjXiWVWIZE1jQ/Ch iucBjhChH0Uv79YSjRrEIQQI1opgNbS3G9W0GC0yW/EJA+i8S5nn8xlFEMvQlguhYI6F X4vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3WvOZNN1fWUsVK9/7jrpWUANj7ZKgUAskAkr6yL1oKs=; b=RTrR3ytXjRzGZlFLZxpv3pNSzoaO4Tp/cSK3lS0945mAIYYWg0ph6aYurR4IxrRwcb 8EgQsUvpN9LNWqlcQoinTqGMjt/Yr/zihlMBl+bu2BwnjUPNatMdyr6Wufy4ypjCVo/e Kfw6Bg/p7F237xSiHZLiUgQ1+COaItri4KehCzvcKeiP2pu+JwUyGwCvyhZb3MO7KnXS CJAXnRrVqtZRJHBbTSINQJxC+BhEDC0W0pTiKGEGSLjPhunQC616Khr8PyuXVCl2OjmP k3K4jpYf9hhyTvj3EthCakPommM2DEtaRkr1cf83vmTsjsVx8wttbLHcI0WGzKfM0su3 UOjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j70si9858585pgd.814.2022.02.09.08.11.18; Wed, 09 Feb 2022 08:11:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235784AbiBIP0X (ORCPT + 99 others); Wed, 9 Feb 2022 10:26:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235778AbiBIP0R (ORCPT ); Wed, 9 Feb 2022 10:26:17 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7ED5C061355 for ; Wed, 9 Feb 2022 07:26:19 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nHorH-0002pa-8O; Wed, 09 Feb 2022 16:26:15 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nHorF-00FX3B-A2; Wed, 09 Feb 2022 16:26:12 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nHorD-00DMQZ-N3; Wed, 09 Feb 2022 16:26:11 +0100 Date: Wed, 9 Feb 2022 16:26:09 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Qing Wang Cc: Thierry Reding , Lee Jones , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pwm: use div64_u64() instead of do_div() Message-ID: <20220209152609.gqeivcehkuzgz3sk@pengutronix.de> References: <1644395998-4397-1-git-send-email-wangqing@vivo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hakboj7n3cnu24o3" Content-Disposition: inline In-Reply-To: <1644395998-4397-1-git-send-email-wangqing@vivo.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hakboj7n3cnu24o3 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Wed, Feb 09, 2022 at 12:39:58AM -0800, Qing Wang wrote: > From: Wang Qing >=20 > do_div() does a 64-by-32 division. > When the divisor is u64, do_div() truncates it to 32 bits, this means it > can test non-zero and be truncated to zero for division. >=20 > fix do_div.cocci warning: > do_div() does a 64-by-32 division, please consider using div64_u64 instea= d. >=20 > Signed-off-by: Wang Qing > --- > drivers/pwm/pwm-berlin.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c > index e157273..15b10cb3 > --- a/drivers/pwm/pwm-berlin.c > +++ b/drivers/pwm/pwm-berlin.c > @@ -109,7 +109,7 @@ static int berlin_pwm_config(struct pwm_chip *chip, s= truct pwm_device *pwm, > =20 > period =3D cycles; > cycles *=3D duty_ns; > - do_div(cycles, period_ns); > + div64_u64(cycles, period_ns); This is wrong, div64_u64() has a different calling convention than do_div(). The issue however is real. Please add=20 Fixes: 30dffb42fcd4 ("pwm: berlin: Implement .apply() callback") to your v2. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --hakboj7n3cnu24o3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmID3Q4ACgkQwfwUeK3K 7AllnAf+O+1frxj5epv4nRAEt/Fq5cqM1lXqY1SLK9WFn7QzGqaDSdxFZX8HQJJB 1Ab3fUkZ3DCm9Wy4gEz7Hf5k43iiv+ZG5MvPKQgsoB2R40ru6RcOxftrdh2vYh5U yhG8sklLkgM0U1Q2X65IMPXi8Vz4tB6FRK2pR+vrPl/Ae+loTkU337pN7ccCk5ur IuIzZ4lkynjhX/1eU/ORevpZSvSp3HxyqBxFPx9oRSJ2J30gl2ElEWNYgnh+E8Vq 92RITLFwDGoZ1VYiZaGgFxI6vLSjGt1WxyCCMZv1vn+e4c4fw94328Vc2K/kzY5E +S+u966W1vF4Z4ZTnt97oQUFJ01wPQ== =Wd2L -----END PGP SIGNATURE----- --hakboj7n3cnu24o3--