From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D1F4C07545 for ; Tue, 24 Oct 2023 21:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JbtQ05ZCfjYxXzqBzjmFKqqh1Yq5I4YDuJ3FJtE/2Cg=; b=GfMmcEJyKkN5GEMoqi03eVIUHC ok6Ru7rPAPR8wUiJUXpfTPOCUcJ2c93db8GSfDRWsJgXxmjp2gcwyh4+2iK80di/fCWp8Ty6Sd9ks q0hgrypvxZzMlmXY/exSYwPLnqKp2d0rQSEDZh2pNt1XNEXf/exBkn1VJ3YGVt2q14T6WSPtdvPWG xEbVbQNEgNHh81nuOSIHBanzRxrj0HYN+JYRhK+BYlf8ATM0ZH0UfLDZwV2dG3m1aa6qITw+dWfvJ gHGD4zzoNrQAmD8KRnqqhk2hFkyHI02AAmRYHyzpHu6PK1QWi8KBVU3xSSpgPtIyIqfF5oqzUsX9v 1cb4zlYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvOhF-00ArgY-2M; Tue, 24 Oct 2023 21:12:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvOhB-00Arfj-1V for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 21:12:16 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qvOgx-0005EP-SP; Tue, 24 Oct 2023 23:11:59 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvOgw-00421X-Cl; Tue, 24 Oct 2023 23:11:58 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qvOgw-005XxO-3K; Tue, 24 Oct 2023 23:11:58 +0200 Date: Tue, 24 Oct 2023 23:11:57 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Dan Carpenter Cc: Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pwm@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] pwm: samsung: Fix a bit test Message-ID: <20231024211157.xv3vzqlmxmxwgvle@pengutronix.de> References: <917e3890-7895-4b1c-bcee-4eecb3b7fe09@moroto.mountain> MIME-Version: 1.0 In-Reply-To: <917e3890-7895-4b1c-bcee-4eecb3b7fe09@moroto.mountain> 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231024_141213_519883_6DDAE343 X-CRM114-Status: GOOD ( 28.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============3457247005171029731==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============3457247005171029731== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="nkibwm3sl7ikb3rs" Content-Disposition: inline --nkibwm3sl7ikb3rs Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Dan, On Tue, Oct 17, 2023 at 05:04:08PM +0300, Dan Carpenter wrote: > This code has two problems. First, it passes the wrong bit parameter to > test_bit(). Second, it mixes using PWMF_REQUESTED in test_bit() and in > open coded bit tests. >=20 > The test_bit() function takes a bit number. In other words, > "if (test_bit(0, &flags))" is the equivalent of "if (flags & (1 << 0))". > Passing (1 << 0) to test_bit() is like writing BIT(BIT(0)). It's a > double shift bug. >=20 > In pwm_samsung_resume() these issues mean that the flag is never set and > the function is essentially a no-op. >=20 > Fixes: 4c9548d24c0d ("pwm: samsung: Put per-channel data into driver data= ") > Signed-off-by: Dan Carpenter > --- > From static analysis and not tested. >=20 > drivers/pwm/pwm-samsung.c | 2 +- > include/linux/pwm.h | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c > index 10fe2c13cd80..acf4a0d8d990 100644 > --- a/drivers/pwm/pwm-samsung.c > +++ b/drivers/pwm/pwm-samsung.c > @@ -630,7 +630,7 @@ static int pwm_samsung_resume(struct device *dev) > struct pwm_device *pwm =3D &chip->pwms[i]; > struct samsung_pwm_channel *chan =3D &our_chip->channel[i]; > =20 > - if (!(pwm->flags & PWMF_REQUESTED)) > + if (!test_bit(PWMF_REQUESTED, &pwm->flags)) > continue; > =20 > if (our_chip->variant.output_mask & BIT(i)) > diff --git a/include/linux/pwm.h b/include/linux/pwm.h > index e3b437587b32..3eee5bf367fb 100644 > --- a/include/linux/pwm.h > +++ b/include/linux/pwm.h > @@ -41,8 +41,8 @@ struct pwm_args { > }; > =20 > enum { > - PWMF_REQUESTED =3D 1 << 0, > - PWMF_EXPORTED =3D 1 << 1, > + PWMF_REQUESTED =3D 0, > + PWMF_EXPORTED =3D 1, I'd want s/ / / here. Or even not assign explicit values at all? > }; > =20 > /* I'd say these are two separate issues, with the one in pwm-samsung being bad and the one in "only" ugly. I wonder how I could get the samsung part wrong. All current usages of PMWF_REQUESTED (and also PWMF_EXPORTED) use test_bit (et al). Grepping through history pwm-pca9685.c got this wrong in a similar way for some time, but otherwise it was always used correctly. The definition of the flags in is ugly since=20 f051c466cf69 ("pwm: Allow chips to support multiple PWMs") from 2011! @Dan: Would you split the patch in two please? Thanks for catching that! Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --nkibwm3sl7ikb3rs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmU4Mx0ACgkQj4D7WH0S /k7KQwf/eaAyfpovq4WF+Ttz94ctJhg4PD7Nk9TRKnE72mEh/giRc3ZaQ6RY3ybw 1ymd1StO/XRx6QtH16VFBW7x3FHcxMedBndun4K33rruSUaaQ9lw+Br8FPNuHFmg akDIcusQDG+PUR2K2ERAAELHU0cmFHxG78jbUZ+Y/+lQg7JEiRLW4lFvMSzTsJMs I4i3EzBZXRpcFPk80HoA9PhECYqP+OleLpUmuc53hRb8txwJpSJrWjohaXP45ps0 gEcS7ItZJQOjDvc5bHEy6/DOwdhtbZU/nuOqqGLqs4PIuM2WARmQKrtVCl4IMrJ1 5sd5d5F3TWurS/8+vXSjNWQj+fMOAQ== =qrEt -----END PGP SIGNATURE----- --nkibwm3sl7ikb3rs-- --===============3457247005171029731== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============3457247005171029731==--