[PATCH v2 01/11] pwm: Make .get_state() callback return an error code

nobuhiro1.iwamatsu at toshiba.co.jp nobuhiro1.iwamatsu at toshiba.co.jp
Thu Dec 1 01:30:27 PST 2022


> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> Sent: Thursday, December 1, 2022 12:22 AM
> To: Thierry Reding <thierry.reding at gmail.com>
> Cc: Conor Dooley <conor.dooley at microchip.com>; Linus Walleij
> <linus.walleij at linaro.org>; Bartosz Golaszewski <brgl at bgdev.pl>; Douglas
> Anderson <dianders at chromium.org>; Pavel Machek <pavel at ucw.cz>;
> Claudiu Beznea <claudiu.beznea at microchip.com>; Nicolas Ferre
> <nicolas.ferre at microchip.com>; Alexandre Belloni
> <alexandre.belloni at bootlin.com>; Ray Jui <rjui at broadcom.com>; Scott
> Branden <sbranden at broadcom.com>; Broadcom internal kernel review list
> <bcm-kernel-feedback-list at broadcom.com>; Benson Leung
> <bleung at chromium.org>; Guenter Roeck <groeck at chromium.org>; Shawn
> Guo <shawnguo at kernel.org>; Sascha Hauer <s.hauer at pengutronix.de>;
> Pengutronix Kernel Team <kernel at pengutronix.de>; Fabio Estevam
> <festevam at gmail.com>; NXP Linux Team <linux-imx at nxp.com>; Kevin
> Hilman <khilman at baylibre.com>; Jerome Brunet <jbrunet at baylibre.com>;
> Martin Blumenstingl <martin.blumenstingl at googlemail.com>; Matthias
> Brugger <matthias.bgg at gmail.com>; Florian Fainelli <f.fainelli at gmail.com>;
> Heiko Stuebner <heiko at sntech.de>; Palmer Dabbelt
> <palmer at dabbelt.com>; Paul Walmsley <paul.walmsley at sifive.com>;
> Michael Walle <michael at walle.cc>; Orson Zhai <orsonzhai at gmail.com>;
> Baolin Wang <baolin.wang at linux.alibaba.com>; Chunyan Zhang
> <zhang.lyra at gmail.com>; Fabrice Gasnier <fabrice.gasnier at foss.st.com>;
> Maxime Coquelin <mcoquelin.stm32 at gmail.com>; Alexandre Torgue
> <alexandre.torgue at foss.st.com>; Chen-Yu Tsai <wens at csie.org>; Samuel
> Holland <samuel at sholland.org>; Hammer Hsieh
> <hammerh0314 at gmail.com>; iwamatsu nobuhiro(岩松 信洋 □SWC◯AC
> T) <nobuhiro1.iwamatsu at toshiba.co.jp>; Sean Anderson
> <sean.anderson at seco.com>; Michal Simek <michal.simek at xilinx.com>;
> Bjorn Andersson <andersson at kernel.org>; Stephen Boyd
> <swboyd at chromium.org>; Matthias Kaehlcke <mka at chromium.org>; Satya
> Priya <quic_c_skakit at quicinc.com>; linux-pwm at vger.kernel.org;
> linux-gpio at vger.kernel.org; dri-devel at lists.freedesktop.org;
> linux-leds at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> chrome-platform at lists.linux.dev; linux-amlogic at lists.infradead.org;
> linux-mediatek at lists.infradead.org; linux-rpi-kernel at lists.infradead.org;
> linux-rockchip at lists.infradead.org; linux-riscv at lists.infradead.org;
> linux-stm32 at st-md-mailman.stormreply.com; linux-sunxi at lists.linux.dev
> Subject: [PATCH v2 01/11] pwm: Make .get_state() callback return an error
> code
> 
> .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 <u.kleine-koenig at pengutronix.de>

<snip>

> a/drivers/pwm/pwm-visconti.c b/drivers/pwm/pwm-visconti.c index
> 927c4cbb1daf..e3fb79b3e2a7 100644
> --- a/drivers/pwm/pwm-visconti.c
> +++ b/drivers/pwm/pwm-visconti.c
> @@ -103,8 +103,8 @@ static int visconti_pwm_apply(struct pwm_chip *chip,
> struct pwm_device *pwm,
>  	return 0;
>  }
> 
> -static void visconti_pwm_get_state(struct pwm_chip *chip, struct
> pwm_device *pwm,
> -				   struct pwm_state *state)
> +static int visconti_pwm_get_state(struct pwm_chip *chip, struct
> pwm_device *pwm,
> +				  struct pwm_state *state)
>  {
>  	struct visconti_pwm_chip *priv = visconti_pwm_from_chip(chip);
>  	u32 period, duty, pwmc0, pwmc0_clk;
> @@ -122,6 +122,8 @@ static void visconti_pwm_get_state(struct pwm_chip
> *chip, struct pwm_device *pwm
>  		state->polarity = PWM_POLARITY_NORMAL;
> 
>  	state->enabled = true;
> +
> +	return 0;
>  }
> 
>  static const struct pwm_ops visconti_pwm_ops = { diff --git

<snip>

for the Visconti pwd:
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu at toshiba.co.jp>



More information about the linux-amlogic mailing list