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 24A22C47089 for ; Mon, 5 Dec 2022 22:31:01 +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=gs4DgNV8XCZV7UKtvAOENsRcAh/Qrn0rMv8TnkVSo3Q=; b=xrSf4B+EuCgKTMsd+PDyLB1Jp8 055p+ic1PoGi0D/m9pRHbVHRG8WMq7UbQ6yB86xMxeVbtKKHbcCjK+IknxSYCVMOxh5ady5jCy3wu i+3q/RNz/yLIfJqVRiFUZetnN6KT+phoWqdq3vQutjim2fUzCELvmW6ukrZlYBRIpSshEhJKj6SKX ng9C1miDQCZ22Oyu4z9myvQjakaSKmDfEO73CKb/t3hAPwnjJfZMdlC1WTCmXR+9Ka9Mf7xk9vETW t6CXtwvOYM1//6z7qgx7N0n48A531ibiaO1Z7fNDhn6aQHa3UWka9mZEzwLDVa/NuBEfLHPMSQxet Wo/LBcmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2Jz6-00BIzu-GB; Mon, 05 Dec 2022 22:30:48 +0000 Received: from jabberwock.ucw.cz ([46.255.230.98]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2Jz2-00BIs2-D0; Mon, 05 Dec 2022 22:30:46 +0000 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 73F5F1C09F4; Mon, 5 Dec 2022 23:30:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1670279436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0beeeN3x4oja6CoA48n0dgddbavIjL+s5ouQp7TTWtU=; b=Glfr3eDW908ut8l8ZtyxnivFsAwFhKrd91OZ8Hn4B5DsYqkFacSwVHpMdO+0ZJbEke3io+ rZJ6H6RfHZXL+x1iQ654lTF809RKZz+X/69jMIvQbgjOVGWGx/4uVo747OBUmRhyZzWmxv I6Gh8EjJUSygmU/FfosMXAkJOwmFGvg= Date: Mon, 5 Dec 2022 23:30:35 +0100 From: Pavel Machek To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Thierry Reding , Conor Dooley , Linus Walleij , Bartosz Golaszewski , Douglas Anderson , Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , Ray Jui , Scott Branden , Broadcom internal kernel review list , Benson Leung , Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Matthias Brugger , Florian Fainelli , Heiko Stuebner , Palmer Dabbelt , Paul Walmsley , Michael Walle , Orson Zhai , Baolin Wang , Chunyan Zhang , Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai , Samuel Holland , Hammer Hsieh , Nobuhiro Iwamatsu , Sean Anderson , Michal Simek , Bjorn Andersson , Stephen Boyd , Matthias Kaehlcke , Satya Priya , linux-pwm@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Message-ID: References: <20221130152148.2769768-1-u.kleine-koenig@pengutronix.de> <20221130152148.2769768-2-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 In-Reply-To: <20221130152148.2769768-2-u.kleine-koenig@pengutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221205_143045_076527_22FDF8DA X-CRM114-Status: GOOD ( 23.56 ) X-BeenThere: linux-amlogic@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="===============3757581419161790331==" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org --===============3757581419161790331== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZBm0pYJnT4srarSL" Content-Disposition: inline --ZBm0pYJnT4srarSL Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > .get_state() might fail in some cases. To make it possible that a driver > signals such a failure change the prototype of .get_state() to return an > error code. >=20 > This patch was created using coccinelle and the following semantic patch: >=20 > @p1@ > identifier getstatefunc; > identifier driver; > @@ > struct pwm_ops driver =3D { > ..., > .get_state =3D getstatefunc > ,... > }; >=20 > @p2@ > identifier p1.getstatefunc; > identifier chip, pwm, state; > @@ > -void > +int > getstatefunc(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_s= tate *state) > { > ... > - return; > + return 0; > ... > } >=20 > plus the actual change of the prototype in include/linux/pwm.h (plus some > manual fixing of indentions and empty lines). >=20 > So for now all drivers return success unconditionally. They are adapted > in the following patches to make the changes easier reviewable. >=20 > Signed-off-by: Uwe Kleine-K=F6nig LED part: Acked-by: Pavel Machek Best regards, Pavel > static const struct pwm_ops ti_sn_pwm_ops =3D { > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qco= m-lpg.c > index 02f51cc61837..741cc2fd817d 100644 > --- a/drivers/leds/rgb/leds-qcom-lpg.c > +++ b/drivers/leds/rgb/leds-qcom-lpg.c > @@ -968,8 +968,8 @@ static int lpg_pwm_apply(struct pwm_chip *chip, struc= t pwm_device *pwm, > return ret; > } > =20 > -static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *= pwm, > - struct pwm_state *state) > +static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *p= wm, > + struct pwm_state *state) > { > struct lpg *lpg =3D container_of(chip, struct lpg, pwm); > struct lpg_channel *chan =3D &lpg->channels[pwm->hwpwm]; > @@ -982,20 +982,20 @@ static void lpg_pwm_get_state(struct pwm_chip *chip= , struct pwm_device *pwm, > =20 > ret =3D regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); > if (ret) > - return; > + return 0; > =20 > refclk =3D lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; > if (refclk) { > ret =3D regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); > if (ret) > - return; > + return 0; > =20 > pre_div =3D lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; > m =3D FIELD_GET(PWM_FREQ_EXP_MASK, val); > =20 > ret =3D regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_va= lue, sizeof(pwm_value)); > if (ret) > - return; > + return 0; > =20 > state->period =3D DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION = * pre_div * (1 << m), refclk); > state->duty_cycle =3D DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value *= pre_div * (1 << m), refclk); > @@ -1006,13 +1006,15 @@ static void lpg_pwm_get_state(struct pwm_chip *ch= ip, struct pwm_device *pwm, > =20 > ret =3D regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val= ); > if (ret) > - return; > + return 0; > =20 > state->enabled =3D FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); > state->polarity =3D PWM_POLARITY_NORMAL; > =20 > if (state->duty_cycle > state->period) > state->duty_cycle =3D state->period; > + > + return 0; > } --=20 People of Russia, stop Putin before his war on Ukraine escalates. --ZBm0pYJnT4srarSL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCY45xCwAKCRAw5/Bqldv6 8qEdAKCcIFDwtp8cJpPtW1EpTb0IJOYYKwCdGtyKdQYCFKVLwV+BGw7lryK0MC8= =gb+Q -----END PGP SIGNATURE----- --ZBm0pYJnT4srarSL-- --===============3757581419161790331== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic --===============3757581419161790331==--