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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F30AC4321E for ; Thu, 1 Dec 2022 10:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbiLAKXF convert rfc822-to-8bit (ORCPT ); Thu, 1 Dec 2022 05:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbiLAKXE (ORCPT ); Thu, 1 Dec 2022 05:23:04 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC5E810A1; Thu, 1 Dec 2022 02:23:02 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A95EED1; Thu, 1 Dec 2022 02:23:09 -0800 (PST) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D4DF93F67D; Thu, 1 Dec 2022 02:22:55 -0800 (PST) Date: Thu, 1 Dec 2022 10:22:52 +0000 From: Andre Przywara To: Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?= Cc: Thierry Reding , Conor Dooley , Linus Walleij , Bartosz Golaszewski , Douglas Anderson , Pavel Machek , 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: <20221201102252.52ace284@donnerap.cambridge.arm.com> In-Reply-To: <20221130152148.2769768-2-u.kleine-koenig@pengutronix.de> References: <20221130152148.2769768-1-u.kleine-koenig@pengutronix.de> <20221130152148.2769768-2-u.kleine-koenig@pengutronix.de> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Wed, 30 Nov 2022 16:21:38 +0100 Uwe Kleine-König wrote: 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. > > This patch was created using coccinelle and the following semantic patch: > > @p1@ > identifier getstatefunc; > identifier driver; > @@ > struct pwm_ops driver = { > ..., > .get_state = getstatefunc > ,... > }; > > @p2@ > identifier p1.getstatefunc; > identifier chip, pwm, state; > @@ > -void > +int > getstatefunc(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) > { > ... > - return; > + return 0; > ... > } > > plus the actual change of the prototype in include/linux/pwm.h (plus some > manual fixing of indentions and empty lines). > > So for now all drivers return success unconditionally. They are adapted > in the following patches to make the changes easier reviewable. > > Signed-off-by: Uwe Kleine-König > --- > drivers/gpio/gpio-mvebu.c | 9 ++++++--- > drivers/gpu/drm/bridge/ti-sn65dsi86.c | 14 ++++++++------ > drivers/leds/rgb/leds-qcom-lpg.c | 14 ++++++++------ > drivers/pwm/pwm-atmel.c | 6 ++++-- > drivers/pwm/pwm-bcm-iproc.c | 8 +++++--- > drivers/pwm/pwm-crc.c | 10 ++++++---- > drivers/pwm/pwm-cros-ec.c | 8 +++++--- > drivers/pwm/pwm-dwc.c | 6 ++++-- > drivers/pwm/pwm-hibvt.c | 6 ++++-- > drivers/pwm/pwm-imx-tpm.c | 8 +++++--- > drivers/pwm/pwm-imx27.c | 8 +++++--- > drivers/pwm/pwm-intel-lgm.c | 6 ++++-- > drivers/pwm/pwm-iqs620a.c | 6 ++++-- > drivers/pwm/pwm-keembay.c | 6 ++++-- > drivers/pwm/pwm-lpss.c | 6 ++++-- > drivers/pwm/pwm-meson.c | 8 +++++--- > drivers/pwm/pwm-mtk-disp.c | 12 +++++++----- > drivers/pwm/pwm-pca9685.c | 8 +++++--- > drivers/pwm/pwm-raspberrypi-poe.c | 8 +++++--- > drivers/pwm/pwm-rockchip.c | 12 +++++++----- > drivers/pwm/pwm-sifive.c | 6 ++++-- > drivers/pwm/pwm-sl28cpld.c | 8 +++++--- > drivers/pwm/pwm-sprd.c | 8 +++++--- > drivers/pwm/pwm-stm32-lp.c | 8 +++++--- > drivers/pwm/pwm-sun4i.c | 12 +++++++----- > drivers/pwm/pwm-sunplus.c | 6 ++++-- > drivers/pwm/pwm-visconti.c | 6 ++++-- > drivers/pwm/pwm-xilinx.c | 8 +++++--- > include/linux/pwm.h | 4 ++-- > 29 files changed, 146 insertions(+), 89 deletions(-) > [ ... ] > diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c > index c8445b0a3339..37d75e252d4e 100644 > --- a/drivers/pwm/pwm-sun4i.c > +++ b/drivers/pwm/pwm-sun4i.c > @@ -108,9 +108,9 @@ static inline void sun4i_pwm_writel(struct sun4i_pwm_chip *chip, > writel(val, chip->base + offset); > } > > -static void sun4i_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int sun4i_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct sun4i_pwm_chip *sun4i_pwm = to_sun4i_pwm_chip(chip); > u64 clk_rate, tmp; > @@ -132,7 +132,7 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip, > state->duty_cycle = DIV_ROUND_UP_ULL(state->period, 2); > state->polarity = PWM_POLARITY_NORMAL; > state->enabled = true; > - return; > + return 0; > } > > if ((PWM_REG_PRESCAL(val, pwm->hwpwm) == PWM_PRESCAL_MASK) && > @@ -142,7 +142,7 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip, > prescaler = prescaler_table[PWM_REG_PRESCAL(val, pwm->hwpwm)]; > > if (prescaler == 0) > - return; > + return 0; > > if (val & BIT_CH(PWM_ACT_STATE, pwm->hwpwm)) > state->polarity = PWM_POLARITY_NORMAL; > @@ -162,6 +162,8 @@ static void sun4i_pwm_get_state(struct pwm_chip *chip, > > tmp = (u64)prescaler * NSEC_PER_SEC * PWM_REG_PRD(val); > state->period = DIV_ROUND_CLOSEST_ULL(tmp, clk_rate); > + > + return 0; > } > > static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm, For sunxi: Reviewed-by: Andre Przywara Just one comment: I don't see a sunxi specific patch later in the series, though it seems we have at least one error error exit (see prescaler == 0 above). Plus potentially another exit if clk_get_rate() (at the very beginning) fails. Shall I send a patch for that? Cheers, Andre.