* [PATCH v2 00/11] pwm: Allow .get_state to fail
@ 2022-11-30 15:21 Uwe Kleine-König
2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König
` (12 more replies)
0 siblings, 13 replies; 47+ messages in thread
From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw)
To: Thierry Reding
Cc: 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,
linux-gpio, dri-devel, linux-leds, linux-arm-kernel,
chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel,
linux-rockchip, linux-riscv, linux-stm32, linux-sunxi,
Steven Rostedt, Masami Hiramatsu, Marijn Suijten
Hello,
I forgot about this series and was remembered when I talked to Conor
Dooley about how .get_state() should behave in an error case.
Compared to (implicit) v1, sent with Message-Id: 20220916151506.298488-1-u.kleine-koenig@pengutronix.de
I changed:
- Patch #1 which does the prototype change now just adds "return 0" to
all implementations and so gets simpler and doesn't change behaviour.
The adaptions to the different .get_state() implementations are split
out into individual patches to ease review.
- One minor inconsistency fixed in "pwm: Handle .get_state() failures"
that I noticed while looking into this patch.
- I skipped changing sun4i.c as I don't know how to handle the error
there. Someone might want to have a look. (That's not ideal, but it's
not worse than the same issue before this series.)
In v1 Thierry had the concern:
| That raises the question about what to do in these cases. If we return
| an error, that could potentially throw off consumers. So perhaps the
| closest would be to return a disabled PWM? Or perhaps it'd be up to the
| consumer to provide some fallback configuration for invalidly configured
| or unconfigured PWMs.
.get_state() is only called in pwm_device_request on a pwm_state that a
consumer might see. Before my series a consumer might have seen a
partial modified pwm_state (because .get_state() might have modified
.period, then stumbled and returned silently). The last patch ensures
that this partial modification isn't given out to the consumer. Instead
they now see the same as if .get_state wasn't implemented at all.
Best regards
Uwe
Uwe Kleine-König (11):
pwm: Make .get_state() callback return an error code
pwm/tracing: Also record trace events for failed API calls
drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the
caller
leds: qcom-lpg: Propagate errors in .get_state() to the caller
pwm: crc: Propagate errors in .get_state() to the caller
pwm: cros-ec: Propagate errors in .get_state() to the caller
pwm: imx27: Propagate errors in .get_state() to the caller
pwm: mtk-disp: Propagate errors in .get_state() to the caller
pwm: rockchip: Propagate errors in .get_state() to the caller
pwm: sprd: Propagate errors in .get_state() to the caller
pwm: Handle .get_state() failures
drivers/gpio/gpio-mvebu.c | 9 ++++++---
drivers/gpu/drm/bridge/ti-sn65dsi86.c | 14 ++++++++------
drivers/leds/rgb/leds-qcom-lpg.c | 14 ++++++++------
drivers/pwm/core.c | 28 +++++++++++++++++----------
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 ++--
include/trace/events/pwm.h | 20 +++++++++----------
31 files changed, 174 insertions(+), 109 deletions(-)
base-commit: 50315945d178eebec4e8e2c50c265767ddb926eb
--
2.38.1
^ permalink raw reply [flat|nested] 47+ messages in thread* [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 1:17 ` Baolin Wang ` (8 more replies) 2022-11-30 15:21 ` [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls Uwe Kleine-König ` (11 subsequent siblings) 12 siblings, 9 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi .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@pengutronix.de> --- 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/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 1bb317b8dcce..91a4232ee58c 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -657,9 +657,10 @@ static void mvebu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) spin_unlock_irqrestore(&mvpwm->lock, flags); } -static void mvebu_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) { +static int mvebu_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) +{ struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; @@ -693,6 +694,8 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, state->enabled = false; spin_unlock_irqrestore(&mvpwm->lock, flags); + + return 0; } static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 3c3561942eb6..6826d2423ae9 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1500,8 +1500,8 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } -static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct ti_sn65dsi86 *pdata = pwm_chip_to_ti_sn_bridge(chip); unsigned int pwm_en_inv; @@ -1512,19 +1512,19 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); if (ret) - return; + return 0; ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); if (ret) - return; + return 0; ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); if (ret) - return; + return 0; ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); if (ret) - return; + return 0; state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) @@ -1539,6 +1539,8 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, if (state->duty_cycle > state->period) state->duty_cycle = state->period; + + return 0; } static const struct pwm_ops ti_sn_pwm_ops = { diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-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, struct pwm_device *pwm, return ret; } -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 *pwm, + struct pwm_state *state) { struct lpg *lpg = container_of(chip, struct lpg, pwm); struct lpg_channel *chan = &lpg->channels[pwm->hwpwm]; @@ -982,20 +982,20 @@ static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); if (ret) - return; + return 0; refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; if (refclk) { ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); if (ret) - return; + return 0; pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; m = FIELD_GET(PWM_FREQ_EXP_MASK, val); ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value)); if (ret) - return; + return 0; state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk); state->duty_cycle = 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 *chip, struct pwm_device *pwm, ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val); if (ret) - return; + return 0; state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); state->polarity = PWM_POLARITY_NORMAL; if (state->duty_cycle > state->period) state->duty_cycle = state->period; + + return 0; } static const struct pwm_ops lpg_pwm_ops = { diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 8e00a4286145..cdbc23649032 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -356,8 +356,8 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); u32 sr, cmr; @@ -396,6 +396,8 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->polarity = PWM_POLARITY_INVERSED; else state->polarity = PWM_POLARITY_NORMAL; + + return 0; } static const struct pwm_ops atmel_pwm_ops = { diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c index 7251037d4dd5..97ec131eb7c1 100644 --- a/drivers/pwm/pwm-bcm-iproc.c +++ b/drivers/pwm/pwm-bcm-iproc.c @@ -68,8 +68,8 @@ static void iproc_pwmc_disable(struct iproc_pwmc *ip, unsigned int channel) ndelay(400); } -static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct iproc_pwmc *ip = to_iproc_pwmc(chip); u64 tmp, multi, rate; @@ -91,7 +91,7 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, if (rate == 0) { state->period = 0; state->duty_cycle = 0; - return; + return 0; } value = readl(ip->base + IPROC_PWM_PRESCALE_OFFSET); @@ -107,6 +107,8 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, value = readl(ip->base + IPROC_PWM_DUTY_CYCLE_OFFSET(pwm->hwpwm)); tmp = (value & IPROC_PWM_PERIOD_MAX) * multi; state->duty_cycle = div64_u64(tmp, rate); + + return 0; } static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-crc.c b/drivers/pwm/pwm-crc.c index 7b357d1cf642..4099850117ba 100644 --- a/drivers/pwm/pwm-crc.c +++ b/drivers/pwm/pwm-crc.c @@ -121,8 +121,8 @@ static int crc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct crystalcove_pwm *crc_pwm = to_crc_pwm(chip); struct device *dev = crc_pwm->chip.dev; @@ -132,13 +132,13 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, error = regmap_read(crc_pwm->regmap, PWM0_CLK_DIV, &clk_div_reg); if (error) { dev_err(dev, "Error reading PWM0_CLK_DIV %d\n", error); - return; + return 0; } error = regmap_read(crc_pwm->regmap, PWM0_DUTY_CYCLE, &duty_cycle_reg); if (error) { dev_err(dev, "Error reading PWM0_DUTY_CYCLE %d\n", error); - return; + return 0; } clk_div = (clk_div_reg & ~PWM_OUTPUT_ENABLE) + 1; @@ -149,6 +149,8 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, DIV_ROUND_UP_ULL(duty_cycle_reg * state->period, PWM_MAX_LEVEL); state->polarity = PWM_POLARITY_NORMAL; state->enabled = !!(clk_div_reg & PWM_OUTPUT_ENABLE); + + return 0; } static const struct pwm_ops crc_pwm_ops = { diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c index 7f10f56c3eb6..11684edc0620 100644 --- a/drivers/pwm/pwm-cros-ec.c +++ b/drivers/pwm/pwm-cros-ec.c @@ -183,8 +183,8 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); struct cros_ec_pwm *channel = pwm_get_chip_data(pwm); @@ -193,7 +193,7 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm); if (ret < 0) { dev_err(chip->dev, "error getting initial duty: %d\n", ret); - return; + return 0; } state->enabled = (ret > 0); @@ -212,6 +212,8 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->duty_cycle = channel->duty_cycle; else state->duty_cycle = ret; + + return 0; } static struct pwm_device * diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index 7568300bb11e..bd2308812096 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -163,8 +163,8 @@ static int dwc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct dwc_pwm *dwc = to_dwc_pwm(chip); u64 duty, period; @@ -188,6 +188,8 @@ static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->polarity = PWM_POLARITY_INVERSED; pm_runtime_put_sync(chip->dev); + + return 0; } static const struct pwm_ops dwc_pwm_ops = { diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c index 333f1b18ff4e..12c05c155cab 100644 --- a/drivers/pwm/pwm-hibvt.c +++ b/drivers/pwm/pwm-hibvt.c @@ -128,8 +128,8 @@ static void hibvt_pwm_set_polarity(struct pwm_chip *chip, PWM_POLARITY_MASK, (0x0 << PWM_POLARITY_SHIFT)); } -static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip); void __iomem *base; @@ -146,6 +146,8 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, value = readl(base + PWM_CTRL_ADDR(pwm->hwpwm)); state->enabled = (PWM_ENABLE_MASK & value); + + return 0; } static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index e5e7b7c339a8..ed1aad96fff0 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -132,9 +132,9 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip, return 0; } -static void pwm_imx_tpm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int pwm_imx_tpm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); u32 rate, val, prescale; @@ -164,6 +164,8 @@ static void pwm_imx_tpm_get_state(struct pwm_chip *chip, /* get channel status */ state->enabled = FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val) ? true : false; + + return 0; } /* this function is supposed to be called with mutex hold */ diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index ea91a2f81a9f..3a22c2fddc45 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -118,8 +118,8 @@ static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) clk_disable_unprepare(imx->clk_ipg); } -static void pwm_imx27_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, struct pwm_state *state) +static int pwm_imx27_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, struct pwm_state *state) { struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); u32 period, prescaler, pwm_clk, val; @@ -128,7 +128,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip, ret = pwm_imx27_clk_prepare_enable(imx); if (ret < 0) - return; + return 0; val = readl(imx->mmio_base + MX3_PWMCR); @@ -170,6 +170,8 @@ static void pwm_imx27_get_state(struct pwm_chip *chip, state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk); pwm_imx27_clk_disable_unprepare(imx); + + return 0; } static void pwm_imx27_sw_reset(struct pwm_chip *chip) diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c index b66c35074087..0cd7dd548e82 100644 --- a/drivers/pwm/pwm-intel-lgm.c +++ b/drivers/pwm/pwm-intel-lgm.c @@ -86,8 +86,8 @@ static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return lgm_pwm_enable(chip, 1); } -static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip); u32 duty, val; @@ -100,6 +100,8 @@ static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, regmap_read(pc->regmap, LGM_PWM_FAN_CON0, &val); duty = FIELD_GET(LGM_PWM_FAN_DC_MSK, val); state->duty_cycle = DIV_ROUND_UP(duty * pc->period, LGM_PWM_MAX_DUTY_CYCLE); + + return 0; } static const struct pwm_ops lgm_pwm_ops = { diff --git a/drivers/pwm/pwm-iqs620a.c b/drivers/pwm/pwm-iqs620a.c index 54bd95a5cab0..15aae53db5ab 100644 --- a/drivers/pwm/pwm-iqs620a.c +++ b/drivers/pwm/pwm-iqs620a.c @@ -104,8 +104,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } -static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct iqs620_pwm_private *iqs620_pwm; @@ -126,6 +126,8 @@ static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, mutex_unlock(&iqs620_pwm->lock); state->period = IQS620_PWM_PERIOD_NS; + + return 0; } static int iqs620_pwm_notifier(struct notifier_block *notifier, diff --git a/drivers/pwm/pwm-keembay.c b/drivers/pwm/pwm-keembay.c index 733811b05721..ac02d8bb4a0b 100644 --- a/drivers/pwm/pwm-keembay.c +++ b/drivers/pwm/pwm-keembay.c @@ -89,8 +89,8 @@ static void keembay_pwm_disable(struct keembay_pwm *priv, int ch) KMB_PWM_LEADIN_OFFSET(ch)); } -static void keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct keembay_pwm *priv = to_keembay_pwm_dev(chip); unsigned long long high, low; @@ -113,6 +113,8 @@ static void keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->duty_cycle = DIV_ROUND_UP_ULL(high, clk_rate); state->period = DIV_ROUND_UP_ULL(high + low, clk_rate); state->polarity = PWM_POLARITY_NORMAL; + + return 0; } static int keembay_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index accdef5dd58e..81ac297b8ba5 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c @@ -205,8 +205,8 @@ static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } -static void pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct pwm_lpss_chip *lpwm = to_lpwm(chip); unsigned long base_unit_range; @@ -236,6 +236,8 @@ static void pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->enabled = !!(ctrl & PWM_ENABLE); pm_runtime_put(chip->dev); + + return 0; } static const struct pwm_ops pwm_lpss_ops = { diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 57112f438c6d..16d79ca5d8f5 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -318,8 +318,8 @@ static unsigned int meson_pwm_cnt_to_ns(struct pwm_chip *chip, return cnt * fin_ns * (channel->pre_div + 1); } -static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct meson_pwm *meson = to_meson_pwm(chip); struct meson_pwm_channel_data *channel_data; @@ -327,7 +327,7 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, u32 value, tmp; if (!state) - return; + return 0; channel = &meson->channels[pwm->hwpwm]; channel_data = &meson_pwm_per_channel_data[pwm->hwpwm]; @@ -357,6 +357,8 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->period = 0; state->duty_cycle = 0; } + + return 0; } static const struct pwm_ops meson_pwm_ops = { diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index c605013e4114..9a6bb334a31b 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -172,9 +172,9 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void mtk_disp_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int mtk_disp_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); u64 rate, period, high_width; @@ -184,14 +184,14 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, err = clk_prepare_enable(mdp->clk_main); if (err < 0) { dev_err(chip->dev, "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); - return; + return 0; } err = clk_prepare_enable(mdp->clk_mm); if (err < 0) { dev_err(chip->dev, "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); clk_disable_unprepare(mdp->clk_main); - return; + return 0; } rate = clk_get_rate(mdp->clk_main); @@ -211,6 +211,8 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, state->polarity = PWM_POLARITY_NORMAL; clk_disable_unprepare(mdp->clk_mm); clk_disable_unprepare(mdp->clk_main); + + return 0; } static const struct pwm_ops mtk_disp_pwm_ops = { diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index f230c10d28bb..41be244e7dd3 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c @@ -431,8 +431,8 @@ static int pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } -static void pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct pca9685 *pca = to_pca(chip); unsigned long long duty; @@ -458,12 +458,14 @@ static void pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, */ state->duty_cycle = 0; state->enabled = false; - return; + return 0; } state->enabled = true; duty = pca9685_pwm_get_duty(pca, pwm->hwpwm); state->duty_cycle = DIV_ROUND_DOWN_ULL(duty * state->period, PCA9685_COUNTER_RANGE); + + return 0; } static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) diff --git a/drivers/pwm/pwm-raspberrypi-poe.c b/drivers/pwm/pwm-raspberrypi-poe.c index 6ff73029f367..2939b71a7ba7 100644 --- a/drivers/pwm/pwm-raspberrypi-poe.c +++ b/drivers/pwm/pwm-raspberrypi-poe.c @@ -82,9 +82,9 @@ static int raspberrypi_pwm_get_property(struct rpi_firmware *firmware, return 0; } -static void raspberrypi_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int raspberrypi_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct raspberrypi_pwm *rpipwm = raspberrypi_pwm_from_chip(chip); @@ -93,6 +93,8 @@ static void raspberrypi_pwm_get_state(struct pwm_chip *chip, RPI_PWM_MAX_DUTY); state->enabled = !!(rpipwm->duty_cycle); state->polarity = PWM_POLARITY_NORMAL; + + return 0; } static int raspberrypi_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index a5af859217c1..3ec7d1756903 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -57,9 +57,9 @@ static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *c) return container_of(c, struct rockchip_pwm_chip, chip); } -static void rockchip_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int rockchip_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); u32 enable_conf = pc->data->enable_conf; @@ -70,11 +70,11 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip, ret = clk_enable(pc->pclk); if (ret) - return; + return 0; ret = clk_enable(pc->clk); if (ret) - return; + return 0; clk_rate = clk_get_rate(pc->clk); @@ -96,6 +96,8 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip, clk_disable(pc->clk); clk_disable(pc->pclk); + + return 0; } static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 2d4fa5e5fdd4..1e9870aa29e9 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -105,8 +105,8 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata, "New real_period = %u ns\n", ddata->real_period); } -static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); u32 duty, val; @@ -123,6 +123,8 @@ static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->duty_cycle = (u64)duty * ddata->real_period >> PWM_SIFIVE_CMPWIDTH; state->polarity = PWM_POLARITY_INVERSED; + + return 0; } static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-sl28cpld.c b/drivers/pwm/pwm-sl28cpld.c index 589aeaaa6ac8..e64900ad4ba1 100644 --- a/drivers/pwm/pwm-sl28cpld.c +++ b/drivers/pwm/pwm-sl28cpld.c @@ -87,9 +87,9 @@ struct sl28cpld_pwm { #define sl28cpld_pwm_from_chip(_chip) \ container_of(_chip, struct sl28cpld_pwm, pwm_chip) -static void sl28cpld_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int sl28cpld_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct sl28cpld_pwm *priv = sl28cpld_pwm_from_chip(chip); unsigned int reg; @@ -115,6 +115,8 @@ static void sl28cpld_pwm_get_state(struct pwm_chip *chip, * the PWM core. */ state->duty_cycle = min(state->duty_cycle, state->period); + + return 0; } static int sl28cpld_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c index 7004f55bbf11..bda8bc5af976 100644 --- a/drivers/pwm/pwm-sprd.c +++ b/drivers/pwm/pwm-sprd.c @@ -65,8 +65,8 @@ static void sprd_pwm_write(struct sprd_pwm_chip *spc, u32 hwid, writel_relaxed(val, spc->base + offset); } -static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct sprd_pwm_chip *spc = container_of(chip, struct sprd_pwm_chip, chip); @@ -83,7 +83,7 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, if (ret) { dev_err(spc->dev, "failed to enable pwm%u clocks\n", pwm->hwpwm); - return; + return 0; } val = sprd_pwm_read(spc, pwm->hwpwm, SPRD_PWM_ENABLE); @@ -113,6 +113,8 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, /* Disable PWM clocks if the PWM channel is not in enable state. */ if (!state->enabled) clk_bulk_disable_unprepare(SPRD_PWM_CHN_CLKS_NUM, chn->clks); + + return 0; } static int sprd_pwm_config(struct sprd_pwm_chip *spc, struct pwm_device *pwm, diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index 3115abb3f52a..39364c52cfe4 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -157,9 +157,9 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, return ret; } -static void stm32_pwm_lp_get_state(struct pwm_chip *chip, - struct pwm_device *pwm, - struct pwm_state *state) +static int stm32_pwm_lp_get_state(struct pwm_chip *chip, + struct pwm_device *pwm, + struct pwm_state *state) { struct stm32_pwm_lp *priv = to_stm32_pwm_lp(chip); unsigned long rate = clk_get_rate(priv->clk); @@ -185,6 +185,8 @@ static void stm32_pwm_lp_get_state(struct pwm_chip *chip, tmp = prd - val; tmp = (tmp << presc) * NSEC_PER_SEC; state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, rate); + + return 0; } static const struct pwm_ops stm32_pwm_lp_ops = { 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, diff --git a/drivers/pwm/pwm-sunplus.c b/drivers/pwm/pwm-sunplus.c index e776fd16512d..d6ebe9f03b35 100644 --- a/drivers/pwm/pwm-sunplus.c +++ b/drivers/pwm/pwm-sunplus.c @@ -124,8 +124,8 @@ static int sunplus_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, return 0; } -static void sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state) +static int sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) { struct sunplus_pwm *priv = to_sunplus_pwm(chip); u32 mode0, dd_freq, duty; @@ -155,6 +155,8 @@ static void sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, } state->polarity = PWM_POLARITY_NORMAL; + + return 0; } static const struct pwm_ops sunplus_pwm_ops = { diff --git 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 a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c index 4dab2b86c427..f7a50fdcd9a5 100644 --- a/drivers/pwm/pwm-xilinx.c +++ b/drivers/pwm/pwm-xilinx.c @@ -169,9 +169,9 @@ static int xilinx_pwm_apply(struct pwm_chip *chip, struct pwm_device *unused, return 0; } -static void xilinx_pwm_get_state(struct pwm_chip *chip, - struct pwm_device *unused, - struct pwm_state *state) +static int xilinx_pwm_get_state(struct pwm_chip *chip, + struct pwm_device *unused, + struct pwm_state *state) { struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip); u32 tlr0, tlr1, tcsr0, tcsr1; @@ -191,6 +191,8 @@ static void xilinx_pwm_get_state(struct pwm_chip *chip, */ if (state->period == state->duty_cycle) state->duty_cycle = 0; + + return 0; } static const struct pwm_ops xilinx_pwm_ops = { diff --git a/include/linux/pwm.h b/include/linux/pwm.h index d70c6e5a839d..4de09163c968 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -276,8 +276,8 @@ struct pwm_ops { struct pwm_capture *result, unsigned long timeout); int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state); - void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, - struct pwm_state *state); + int (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state); struct module *owner; }; -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König @ 2022-12-01 1:17 ` Baolin Wang 2022-12-01 2:41 ` Tzung-Bi Shih ` (7 subsequent siblings) 8 siblings, 0 replies; 47+ messages in thread From: Baolin Wang @ 2022-12-01 1:17 UTC (permalink / raw) To: Uwe Kleine-König, Thierry Reding Cc: 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, 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On 11/30/2022 11:21 PM, Uwe Kleine-König wrote: > diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c > index 7004f55bbf11..bda8bc5af976 100644 > --- a/drivers/pwm/pwm-sprd.c > +++ b/drivers/pwm/pwm-sprd.c > @@ -65,8 +65,8 @@ static void sprd_pwm_write(struct sprd_pwm_chip *spc, u32 hwid, > writel_relaxed(val, spc->base + offset); > } > > -static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct sprd_pwm_chip *spc = > container_of(chip, struct sprd_pwm_chip, chip); > @@ -83,7 +83,7 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > if (ret) { > dev_err(spc->dev, "failed to enable pwm%u clocks\n", > pwm->hwpwm); > - return; > + return 0; > } > > val = sprd_pwm_read(spc, pwm->hwpwm, SPRD_PWM_ENABLE); > @@ -113,6 +113,8 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > /* Disable PWM clocks if the PWM channel is not in enable state. */ > if (!state->enabled) > clk_bulk_disable_unprepare(SPRD_PWM_CHN_CLKS_NUM, chn->clks); > + > + return 0; > } > > static int sprd_pwm_config(struct sprd_pwm_chip *spc, struct pwm_device *pwm, For sprd pwm parts: Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König 2022-12-01 1:17 ` Baolin Wang @ 2022-12-01 2:41 ` Tzung-Bi Shih 2022-12-01 8:03 ` Neil Armstrong ` (6 subsequent siblings) 8 siblings, 0 replies; 47+ messages in thread From: Tzung-Bi Shih @ 2022-12-01 2:41 UTC (permalink / raw) To: Uwe Kleine-König 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On Wed, Nov 30, 2022 at 04:21:38PM +0100, Uwe Kleine-König wrote: > diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c > index 7f10f56c3eb6..11684edc0620 100644 > --- a/drivers/pwm/pwm-cros-ec.c > +++ b/drivers/pwm/pwm-cros-ec.c > @@ -183,8 +183,8 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); > struct cros_ec_pwm *channel = pwm_get_chip_data(pwm); > @@ -193,7 +193,7 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm); > if (ret < 0) { > dev_err(chip->dev, "error getting initial duty: %d\n", ret); > - return; > + return 0; > } > > state->enabled = (ret > 0); > @@ -212,6 +212,8 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->duty_cycle = channel->duty_cycle; > else > state->duty_cycle = ret; > + > + return 0; > } For the cros-ec part: Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König 2022-12-01 1:17 ` Baolin Wang 2022-12-01 2:41 ` Tzung-Bi Shih @ 2022-12-01 8:03 ` Neil Armstrong 2022-12-01 9:30 ` nobuhiro1.iwamatsu ` (5 subsequent siblings) 8 siblings, 0 replies; 47+ messages in thread From: Neil Armstrong @ 2022-12-01 8:03 UTC (permalink / raw) To: Uwe Kleine-König, Thierry Reding Cc: 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On 30/11/2022 16:21, Uwe Kleine-König wrote: > .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@pengutronix.de> > --- > 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(-) > <snip> > diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c > index 57112f438c6d..16d79ca5d8f5 100644 > --- a/drivers/pwm/pwm-meson.c > +++ b/drivers/pwm/pwm-meson.c > @@ -318,8 +318,8 @@ static unsigned int meson_pwm_cnt_to_ns(struct pwm_chip *chip, > return cnt * fin_ns * (channel->pre_div + 1); > } > > -static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct meson_pwm *meson = to_meson_pwm(chip); > struct meson_pwm_channel_data *channel_data; > @@ -327,7 +327,7 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > u32 value, tmp; > > if (!state) > - return; > + return 0; > > channel = &meson->channels[pwm->hwpwm]; > channel_data = &meson_pwm_per_channel_data[pwm->hwpwm]; > @@ -357,6 +357,8 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->period = 0; > state->duty_cycle = 0; > } > + > + return 0; > } > > static const struct pwm_ops meson_pwm_ops = { <snip> For pwm-meson: Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> ^ permalink raw reply [flat|nested] 47+ messages in thread
* RE: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (2 preceding siblings ...) 2022-12-01 8:03 ` Neil Armstrong @ 2022-12-01 9:30 ` nobuhiro1.iwamatsu 2022-12-01 10:22 ` Andre Przywara ` (4 subsequent siblings) 8 siblings, 0 replies; 47+ messages in thread From: nobuhiro1.iwamatsu @ 2022-12-01 9:30 UTC (permalink / raw) To: u.kleine-koenig, thierry.reding Cc: conor.dooley, linus.walleij, brgl, dianders, pavel, claudiu.beznea, nicolas.ferre, alexandre.belloni, rjui, sbranden, bcm-kernel-feedback-list, bleung, groeck, shawnguo, s.hauer, kernel, festevam, linux-imx, khilman, jbrunet, martin.blumenstingl, matthias.bgg, f.fainelli, heiko, palmer, paul.walmsley, michael, orsonzhai, baolin.wang, zhang.lyra, fabrice.gasnier, mcoquelin.stm32, alexandre.torgue, wens, samuel, hammerh0314, sean.anderson, michal.simek, andersson, swboyd, mka, quic_c_skakit, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi > -----Original Message----- > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Sent: Thursday, December 1, 2022 12:22 AM > To: Thierry Reding <thierry.reding@gmail.com> > Cc: Conor Dooley <conor.dooley@microchip.com>; Linus Walleij > <linus.walleij@linaro.org>; Bartosz Golaszewski <brgl@bgdev.pl>; Douglas > Anderson <dianders@chromium.org>; Pavel Machek <pavel@ucw.cz>; > Claudiu Beznea <claudiu.beznea@microchip.com>; Nicolas Ferre > <nicolas.ferre@microchip.com>; Alexandre Belloni > <alexandre.belloni@bootlin.com>; Ray Jui <rjui@broadcom.com>; Scott > Branden <sbranden@broadcom.com>; Broadcom internal kernel review list > <bcm-kernel-feedback-list@broadcom.com>; Benson Leung > <bleung@chromium.org>; Guenter Roeck <groeck@chromium.org>; Shawn > Guo <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; > Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam > <festevam@gmail.com>; NXP Linux Team <linux-imx@nxp.com>; Kevin > Hilman <khilman@baylibre.com>; Jerome Brunet <jbrunet@baylibre.com>; > Martin Blumenstingl <martin.blumenstingl@googlemail.com>; Matthias > Brugger <matthias.bgg@gmail.com>; Florian Fainelli <f.fainelli@gmail.com>; > Heiko Stuebner <heiko@sntech.de>; Palmer Dabbelt > <palmer@dabbelt.com>; Paul Walmsley <paul.walmsley@sifive.com>; > Michael Walle <michael@walle.cc>; Orson Zhai <orsonzhai@gmail.com>; > Baolin Wang <baolin.wang@linux.alibaba.com>; Chunyan Zhang > <zhang.lyra@gmail.com>; Fabrice Gasnier <fabrice.gasnier@foss.st.com>; > Maxime Coquelin <mcoquelin.stm32@gmail.com>; Alexandre Torgue > <alexandre.torgue@foss.st.com>; Chen-Yu Tsai <wens@csie.org>; Samuel > Holland <samuel@sholland.org>; Hammer Hsieh > <hammerh0314@gmail.com>; iwamatsu nobuhiro(岩松 信洋 □SWC◯AC > T) <nobuhiro1.iwamatsu@toshiba.co.jp>; Sean Anderson > <sean.anderson@seco.com>; Michal Simek <michal.simek@xilinx.com>; > Bjorn Andersson <andersson@kernel.org>; Stephen Boyd > <swboyd@chromium.org>; Matthias Kaehlcke <mka@chromium.org>; Satya > Priya <quic_c_skakit@quicinc.com>; 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: [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@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@toshiba.co.jp> ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (3 preceding siblings ...) 2022-12-01 9:30 ` nobuhiro1.iwamatsu @ 2022-12-01 10:22 ` Andre Przywara 2022-12-01 13:16 ` Uwe Kleine-König 2022-12-01 10:43 ` Dave Stevenson ` (3 subsequent siblings) 8 siblings, 1 reply; 47+ messages in thread From: Andre Przywara @ 2022-12-01 10:22 UTC (permalink / raw) To: Uwe Kleine-König 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On Wed, 30 Nov 2022 16:21:38 +0100 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> 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 <u.kleine-koenig@pengutronix.de> > --- > 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 <andre.przywara@arm.com> 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. ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-12-01 10:22 ` Andre Przywara @ 2022-12-01 13:16 ` Uwe Kleine-König 2022-12-01 14:17 ` Andre Przywara 0 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-01 13:16 UTC (permalink / raw) To: Andre Przywara Cc: Alexandre Belloni, Heiko Stuebner, Linus Walleij, Alexandre Torgue, dri-devel, Douglas Anderson, Conor Dooley, Thierry Reding, Satya Priya, Pavel Machek, Guenter Roeck, Nobuhiro Iwamatsu, Fabio Estevam, linux-riscv, linux-leds, Jerome Brunet, chrome-platform, Florian Fainelli, Samuel Holland, Sean Anderson, Kevin Hilman, Bartosz Golaszewski, Michal Simek, linux-stm32, Hammer Hsieh, linux-rockchip, Chen-Yu Tsai, Matthias Kaehlcke, Broadcom internal kernel review list, NXP Linux Team, Orson Zhai, linux-sunxi, linux-pwm, Maxime Coquelin, Martin Blumenstingl, Ray Jui, Sascha Hauer, Stephen Boyd, linux-gpio, Fabrice Gasnier, linux-mediatek, linux-rpi-kernel, Baolin Wang, Paul Walmsley, Matthias Brugger, linux-amlogic, Benson Leung, linux-arm-kernel, Scott Branden, Bjorn Andersson, Nicolas Ferre, Michael Walle, Palmer Dabbelt, Pengutronix Kernel Team, Chunyan Zhang, Shawn Guo, Claudiu Beznea [-- Attachment #1: Type: text/plain, Size: 682 bytes --] Hello Andre, On Thu, Dec 01, 2022 at 10:22:52AM +0000, Andre Przywara wrote: > 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? That would we very welcome. I mentioned that shortly in the cover letter, I wasn't entirely sure how to handle that prescaler = 0 case. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-12-01 13:16 ` Uwe Kleine-König @ 2022-12-01 14:17 ` Andre Przywara 0 siblings, 0 replies; 47+ messages in thread From: Andre Przywara @ 2022-12-01 14:17 UTC (permalink / raw) To: Uwe Kleine-König Cc: Alexandre Belloni, Heiko Stuebner, Linus Walleij, Alexandre Torgue, dri-devel, Douglas Anderson, Conor Dooley, Thierry Reding, Satya Priya, Pavel Machek, Guenter Roeck, Nobuhiro Iwamatsu, Fabio Estevam, linux-riscv, linux-leds, Jerome Brunet, chrome-platform, Florian Fainelli, Samuel Holland, Sean Anderson, Kevin Hilman, Bartosz Golaszewski, Michal Simek, linux-stm32, Hammer Hsieh, linux-rockchip, Chen-Yu Tsai, Matthias Kaehlcke, Broadcom internal kernel review list, NXP Linux Team, Orson Zhai, linux-sunxi, linux-pwm, Maxime Coquelin, Martin Blumenstingl, Ray Jui, Sascha Hauer, Stephen Boyd, linux-gpio, Fabrice Gasnier, linux-mediatek, linux-rpi-kernel, Baolin Wang, Paul Walmsley, Matthias Brugger, linux-amlogic, Benson Leung, linux-arm-kernel, Scott Branden, Bjorn Andersson, Nicolas Ferre, Michael Walle, Palmer Dabbelt, Pengutronix Kernel Team, Chunyan Zhang, Shawn Guo, Claudiu Beznea On Thu, 1 Dec 2022 14:16:04 +0100 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: Hi Uwe, > Hello Andre, > > On Thu, Dec 01, 2022 at 10:22:52AM +0000, Andre Przywara wrote: > > 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? > > That would we very welcome. I mentioned that shortly in the cover > letter, I wasn't entirely sure how to handle that prescaler = 0 case. Ah right, sorry, I missed that. So the Allwinner manual somehow marks those prescaler encodings as reserved or invalid (it's just a "/" in there), and we never set those values in the driver (there is an explicit check). So it could only be a leftover from firmware/bootloader, or someone poking at this register behind our back. I am tempted to just return some -EINVAL. As the current code stands, we don't manipulate any state flags before that check, so it doesn't really matter, but would be best practise, at least. Cheers, Andre ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (4 preceding siblings ...) 2022-12-01 10:22 ` Andre Przywara @ 2022-12-01 10:43 ` Dave Stevenson 2022-12-01 15:37 ` Doug Anderson ` (2 subsequent siblings) 8 siblings, 0 replies; 47+ messages in thread From: Dave Stevenson @ 2022-12-01 10:43 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Alexandre Belloni, Alexandre Torgue, dri-devel, Nicolas Ferre, Conor Dooley, Satya Priya, Pavel Machek, Guenter Roeck, Nobuhiro Iwamatsu, linux-riscv, linux-leds, Jerome Brunet, chrome-platform, Florian Fainelli, Samuel Holland, Sean Anderson, Kevin Hilman, Bartosz Golaszewski, Michal Simek, linux-stm32, Hammer Hsieh, linux-rockchip, Chen-Yu Tsai, Matthias Kaehlcke, Broadcom internal kernel review list, NXP Linux Team, Orson Zhai, linux-sunxi, linux-pwm, Maxime Coquelin, Martin Blumenstingl, Ray Jui, Sascha Hauer, Stephen Boyd, linux-gpio, Fabrice Gasnier, linux-mediatek, linux-rpi-kernel, Baolin Wang, Paul Walmsley, Matthias Brugger, linux-amlogic, linux-arm-kernel, Scott Branden, Bjorn Andersson, Douglas Anderson, Michael Walle, Palmer Dabbelt, Pengutronix Kernel Team, Chunyan Zhang, Shawn Guo, Claudiu Beznea On Wed, 30 Nov 2022 at 15:23, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > .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@pengutronix.de> > --- > 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/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c > index 1bb317b8dcce..91a4232ee58c 100644 > --- a/drivers/gpio/gpio-mvebu.c > +++ b/drivers/gpio/gpio-mvebu.c > @@ -657,9 +657,10 @@ static void mvebu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) > spin_unlock_irqrestore(&mvpwm->lock, flags); > } > > -static void mvebu_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) { > +static int mvebu_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > +{ > > struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); > struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; > @@ -693,6 +694,8 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, > state->enabled = false; > > spin_unlock_irqrestore(&mvpwm->lock, flags); > + > + return 0; > } > > static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > index 3c3561942eb6..6826d2423ae9 100644 > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > @@ -1500,8 +1500,8 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > -static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct ti_sn65dsi86 *pdata = pwm_chip_to_ti_sn_bridge(chip); > unsigned int pwm_en_inv; > @@ -1512,19 +1512,19 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); > if (ret) > - return; > + return 0; > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); > if (ret) > - return; > + return 0; > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); > if (ret) > - return; > + return 0; > > ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); > if (ret) > - return; > + return 0; > > state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); > if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) > @@ -1539,6 +1539,8 @@ static void ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > if (state->duty_cycle > state->period) > state->duty_cycle = state->period; > + > + return 0; > } > > static const struct pwm_ops ti_sn_pwm_ops = { > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-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, struct pwm_device *pwm, > return ret; > } > > -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 *pwm, > + struct pwm_state *state) > { > struct lpg *lpg = container_of(chip, struct lpg, pwm); > struct lpg_channel *chan = &lpg->channels[pwm->hwpwm]; > @@ -982,20 +982,20 @@ static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); > if (ret) > - return; > + return 0; > > refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; > if (refclk) { > ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); > if (ret) > - return; > + return 0; > > pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; > m = FIELD_GET(PWM_FREQ_EXP_MASK, val); > > ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value)); > if (ret) > - return; > + return 0; > > state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk); > state->duty_cycle = 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 *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val); > if (ret) > - return; > + return 0; > > state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); > state->polarity = PWM_POLARITY_NORMAL; > > if (state->duty_cycle > state->period) > state->duty_cycle = state->period; > + > + return 0; > } > > static const struct pwm_ops lpg_pwm_ops = { > diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c > index 8e00a4286145..cdbc23649032 100644 > --- a/drivers/pwm/pwm-atmel.c > +++ b/drivers/pwm/pwm-atmel.c > @@ -356,8 +356,8 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); > u32 sr, cmr; > @@ -396,6 +396,8 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->polarity = PWM_POLARITY_INVERSED; > else > state->polarity = PWM_POLARITY_NORMAL; > + > + return 0; > } > > static const struct pwm_ops atmel_pwm_ops = { > diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c > index 7251037d4dd5..97ec131eb7c1 100644 > --- a/drivers/pwm/pwm-bcm-iproc.c > +++ b/drivers/pwm/pwm-bcm-iproc.c > @@ -68,8 +68,8 @@ static void iproc_pwmc_disable(struct iproc_pwmc *ip, unsigned int channel) > ndelay(400); > } > > -static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct iproc_pwmc *ip = to_iproc_pwmc(chip); > u64 tmp, multi, rate; > @@ -91,7 +91,7 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > if (rate == 0) { > state->period = 0; > state->duty_cycle = 0; > - return; > + return 0; > } > > value = readl(ip->base + IPROC_PWM_PRESCALE_OFFSET); > @@ -107,6 +107,8 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > value = readl(ip->base + IPROC_PWM_DUTY_CYCLE_OFFSET(pwm->hwpwm)); > tmp = (value & IPROC_PWM_PERIOD_MAX) * multi; > state->duty_cycle = div64_u64(tmp, rate); > + > + return 0; > } > > static int iproc_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-crc.c b/drivers/pwm/pwm-crc.c > index 7b357d1cf642..4099850117ba 100644 > --- a/drivers/pwm/pwm-crc.c > +++ b/drivers/pwm/pwm-crc.c > @@ -121,8 +121,8 @@ static int crc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct crystalcove_pwm *crc_pwm = to_crc_pwm(chip); > struct device *dev = crc_pwm->chip.dev; > @@ -132,13 +132,13 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > error = regmap_read(crc_pwm->regmap, PWM0_CLK_DIV, &clk_div_reg); > if (error) { > dev_err(dev, "Error reading PWM0_CLK_DIV %d\n", error); > - return; > + return 0; > } > > error = regmap_read(crc_pwm->regmap, PWM0_DUTY_CYCLE, &duty_cycle_reg); > if (error) { > dev_err(dev, "Error reading PWM0_DUTY_CYCLE %d\n", error); > - return; > + return 0; > } > > clk_div = (clk_div_reg & ~PWM_OUTPUT_ENABLE) + 1; > @@ -149,6 +149,8 @@ static void crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > DIV_ROUND_UP_ULL(duty_cycle_reg * state->period, PWM_MAX_LEVEL); > state->polarity = PWM_POLARITY_NORMAL; > state->enabled = !!(clk_div_reg & PWM_OUTPUT_ENABLE); > + > + return 0; > } > > static const struct pwm_ops crc_pwm_ops = { > diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c > index 7f10f56c3eb6..11684edc0620 100644 > --- a/drivers/pwm/pwm-cros-ec.c > +++ b/drivers/pwm/pwm-cros-ec.c > @@ -183,8 +183,8 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); > struct cros_ec_pwm *channel = pwm_get_chip_data(pwm); > @@ -193,7 +193,7 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm); > if (ret < 0) { > dev_err(chip->dev, "error getting initial duty: %d\n", ret); > - return; > + return 0; > } > > state->enabled = (ret > 0); > @@ -212,6 +212,8 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->duty_cycle = channel->duty_cycle; > else > state->duty_cycle = ret; > + > + return 0; > } > > static struct pwm_device * > diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c > index 7568300bb11e..bd2308812096 100644 > --- a/drivers/pwm/pwm-dwc.c > +++ b/drivers/pwm/pwm-dwc.c > @@ -163,8 +163,8 @@ static int dwc_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct dwc_pwm *dwc = to_dwc_pwm(chip); > u64 duty, period; > @@ -188,6 +188,8 @@ static void dwc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->polarity = PWM_POLARITY_INVERSED; > > pm_runtime_put_sync(chip->dev); > + > + return 0; > } > > static const struct pwm_ops dwc_pwm_ops = { > diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > index 333f1b18ff4e..12c05c155cab 100644 > --- a/drivers/pwm/pwm-hibvt.c > +++ b/drivers/pwm/pwm-hibvt.c > @@ -128,8 +128,8 @@ static void hibvt_pwm_set_polarity(struct pwm_chip *chip, > PWM_POLARITY_MASK, (0x0 << PWM_POLARITY_SHIFT)); > } > > -static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip); > void __iomem *base; > @@ -146,6 +146,8 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > value = readl(base + PWM_CTRL_ADDR(pwm->hwpwm)); > state->enabled = (PWM_ENABLE_MASK & value); > + > + return 0; > } > > static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c > index e5e7b7c339a8..ed1aad96fff0 100644 > --- a/drivers/pwm/pwm-imx-tpm.c > +++ b/drivers/pwm/pwm-imx-tpm.c > @@ -132,9 +132,9 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip, > return 0; > } > > -static void pwm_imx_tpm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int pwm_imx_tpm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); > u32 rate, val, prescale; > @@ -164,6 +164,8 @@ static void pwm_imx_tpm_get_state(struct pwm_chip *chip, > > /* get channel status */ > state->enabled = FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val) ? true : false; > + > + return 0; > } > > /* this function is supposed to be called with mutex hold */ > diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c > index ea91a2f81a9f..3a22c2fddc45 100644 > --- a/drivers/pwm/pwm-imx27.c > +++ b/drivers/pwm/pwm-imx27.c > @@ -118,8 +118,8 @@ static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) > clk_disable_unprepare(imx->clk_ipg); > } > > -static void pwm_imx27_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, struct pwm_state *state) > +static int pwm_imx27_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, struct pwm_state *state) > { > struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); > u32 period, prescaler, pwm_clk, val; > @@ -128,7 +128,7 @@ static void pwm_imx27_get_state(struct pwm_chip *chip, > > ret = pwm_imx27_clk_prepare_enable(imx); > if (ret < 0) > - return; > + return 0; > > val = readl(imx->mmio_base + MX3_PWMCR); > > @@ -170,6 +170,8 @@ static void pwm_imx27_get_state(struct pwm_chip *chip, > state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk); > > pwm_imx27_clk_disable_unprepare(imx); > + > + return 0; > } > > static void pwm_imx27_sw_reset(struct pwm_chip *chip) > diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c > index b66c35074087..0cd7dd548e82 100644 > --- a/drivers/pwm/pwm-intel-lgm.c > +++ b/drivers/pwm/pwm-intel-lgm.c > @@ -86,8 +86,8 @@ static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return lgm_pwm_enable(chip, 1); > } > > -static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip); > u32 duty, val; > @@ -100,6 +100,8 @@ static void lgm_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > regmap_read(pc->regmap, LGM_PWM_FAN_CON0, &val); > duty = FIELD_GET(LGM_PWM_FAN_DC_MSK, val); > state->duty_cycle = DIV_ROUND_UP(duty * pc->period, LGM_PWM_MAX_DUTY_CYCLE); > + > + return 0; > } > > static const struct pwm_ops lgm_pwm_ops = { > diff --git a/drivers/pwm/pwm-iqs620a.c b/drivers/pwm/pwm-iqs620a.c > index 54bd95a5cab0..15aae53db5ab 100644 > --- a/drivers/pwm/pwm-iqs620a.c > +++ b/drivers/pwm/pwm-iqs620a.c > @@ -104,8 +104,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > -static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct iqs620_pwm_private *iqs620_pwm; > > @@ -126,6 +126,8 @@ static void iqs620_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > mutex_unlock(&iqs620_pwm->lock); > > state->period = IQS620_PWM_PERIOD_NS; > + > + return 0; > } > > static int iqs620_pwm_notifier(struct notifier_block *notifier, > diff --git a/drivers/pwm/pwm-keembay.c b/drivers/pwm/pwm-keembay.c > index 733811b05721..ac02d8bb4a0b 100644 > --- a/drivers/pwm/pwm-keembay.c > +++ b/drivers/pwm/pwm-keembay.c > @@ -89,8 +89,8 @@ static void keembay_pwm_disable(struct keembay_pwm *priv, int ch) > KMB_PWM_LEADIN_OFFSET(ch)); > } > > -static void keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct keembay_pwm *priv = to_keembay_pwm_dev(chip); > unsigned long long high, low; > @@ -113,6 +113,8 @@ static void keembay_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->duty_cycle = DIV_ROUND_UP_ULL(high, clk_rate); > state->period = DIV_ROUND_UP_ULL(high + low, clk_rate); > state->polarity = PWM_POLARITY_NORMAL; > + > + return 0; > } > > static int keembay_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c > index accdef5dd58e..81ac297b8ba5 100644 > --- a/drivers/pwm/pwm-lpss.c > +++ b/drivers/pwm/pwm-lpss.c > @@ -205,8 +205,8 @@ static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > -static void pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct pwm_lpss_chip *lpwm = to_lpwm(chip); > unsigned long base_unit_range; > @@ -236,6 +236,8 @@ static void pwm_lpss_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->enabled = !!(ctrl & PWM_ENABLE); > > pm_runtime_put(chip->dev); > + > + return 0; > } > > static const struct pwm_ops pwm_lpss_ops = { > diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c > index 57112f438c6d..16d79ca5d8f5 100644 > --- a/drivers/pwm/pwm-meson.c > +++ b/drivers/pwm/pwm-meson.c > @@ -318,8 +318,8 @@ static unsigned int meson_pwm_cnt_to_ns(struct pwm_chip *chip, > return cnt * fin_ns * (channel->pre_div + 1); > } > > -static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct meson_pwm *meson = to_meson_pwm(chip); > struct meson_pwm_channel_data *channel_data; > @@ -327,7 +327,7 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > u32 value, tmp; > > if (!state) > - return; > + return 0; > > channel = &meson->channels[pwm->hwpwm]; > channel_data = &meson_pwm_per_channel_data[pwm->hwpwm]; > @@ -357,6 +357,8 @@ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->period = 0; > state->duty_cycle = 0; > } > + > + return 0; > } > > static const struct pwm_ops meson_pwm_ops = { > diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c > index c605013e4114..9a6bb334a31b 100644 > --- a/drivers/pwm/pwm-mtk-disp.c > +++ b/drivers/pwm/pwm-mtk-disp.c > @@ -172,9 +172,9 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void mtk_disp_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int mtk_disp_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); > u64 rate, period, high_width; > @@ -184,14 +184,14 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, > err = clk_prepare_enable(mdp->clk_main); > if (err < 0) { > dev_err(chip->dev, "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); > - return; > + return 0; > } > > err = clk_prepare_enable(mdp->clk_mm); > if (err < 0) { > dev_err(chip->dev, "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); > clk_disable_unprepare(mdp->clk_main); > - return; > + return 0; > } > > rate = clk_get_rate(mdp->clk_main); > @@ -211,6 +211,8 @@ static void mtk_disp_pwm_get_state(struct pwm_chip *chip, > state->polarity = PWM_POLARITY_NORMAL; > clk_disable_unprepare(mdp->clk_mm); > clk_disable_unprepare(mdp->clk_main); > + > + return 0; > } > > static const struct pwm_ops mtk_disp_pwm_ops = { > diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c > index f230c10d28bb..41be244e7dd3 100644 > --- a/drivers/pwm/pwm-pca9685.c > +++ b/drivers/pwm/pwm-pca9685.c > @@ -431,8 +431,8 @@ static int pca9685_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > -static void pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct pca9685 *pca = to_pca(chip); > unsigned long long duty; > @@ -458,12 +458,14 @@ static void pca9685_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > */ > state->duty_cycle = 0; > state->enabled = false; > - return; > + return 0; > } > > state->enabled = true; > duty = pca9685_pwm_get_duty(pca, pwm->hwpwm); > state->duty_cycle = DIV_ROUND_DOWN_ULL(duty * state->period, PCA9685_COUNTER_RANGE); > + > + return 0; > } > > static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) > diff --git a/drivers/pwm/pwm-raspberrypi-poe.c b/drivers/pwm/pwm-raspberrypi-poe.c > index 6ff73029f367..2939b71a7ba7 100644 > --- a/drivers/pwm/pwm-raspberrypi-poe.c > +++ b/drivers/pwm/pwm-raspberrypi-poe.c > @@ -82,9 +82,9 @@ static int raspberrypi_pwm_get_property(struct rpi_firmware *firmware, > return 0; > } > > -static void raspberrypi_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int raspberrypi_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct raspberrypi_pwm *rpipwm = raspberrypi_pwm_from_chip(chip); > > @@ -93,6 +93,8 @@ static void raspberrypi_pwm_get_state(struct pwm_chip *chip, > RPI_PWM_MAX_DUTY); > state->enabled = !!(rpipwm->duty_cycle); > state->polarity = PWM_POLARITY_NORMAL; > + > + return 0; > } > > static int raspberrypi_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, For the pwm-raspberrypi-poe part: Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> > diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c > index a5af859217c1..3ec7d1756903 100644 > --- a/drivers/pwm/pwm-rockchip.c > +++ b/drivers/pwm/pwm-rockchip.c > @@ -57,9 +57,9 @@ static inline struct rockchip_pwm_chip *to_rockchip_pwm_chip(struct pwm_chip *c) > return container_of(c, struct rockchip_pwm_chip, chip); > } > > -static void rockchip_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int rockchip_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); > u32 enable_conf = pc->data->enable_conf; > @@ -70,11 +70,11 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip, > > ret = clk_enable(pc->pclk); > if (ret) > - return; > + return 0; > > ret = clk_enable(pc->clk); > if (ret) > - return; > + return 0; > > clk_rate = clk_get_rate(pc->clk); > > @@ -96,6 +96,8 @@ static void rockchip_pwm_get_state(struct pwm_chip *chip, > > clk_disable(pc->clk); > clk_disable(pc->pclk); > + > + return 0; > } > > static void rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c > index 2d4fa5e5fdd4..1e9870aa29e9 100644 > --- a/drivers/pwm/pwm-sifive.c > +++ b/drivers/pwm/pwm-sifive.c > @@ -105,8 +105,8 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata, > "New real_period = %u ns\n", ddata->real_period); > } > > -static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); > u32 duty, val; > @@ -123,6 +123,8 @@ static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > state->duty_cycle = > (u64)duty * ddata->real_period >> PWM_SIFIVE_CMPWIDTH; > state->polarity = PWM_POLARITY_INVERSED; > + > + return 0; > } > > static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-sl28cpld.c b/drivers/pwm/pwm-sl28cpld.c > index 589aeaaa6ac8..e64900ad4ba1 100644 > --- a/drivers/pwm/pwm-sl28cpld.c > +++ b/drivers/pwm/pwm-sl28cpld.c > @@ -87,9 +87,9 @@ struct sl28cpld_pwm { > #define sl28cpld_pwm_from_chip(_chip) \ > container_of(_chip, struct sl28cpld_pwm, pwm_chip) > > -static void sl28cpld_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int sl28cpld_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct sl28cpld_pwm *priv = sl28cpld_pwm_from_chip(chip); > unsigned int reg; > @@ -115,6 +115,8 @@ static void sl28cpld_pwm_get_state(struct pwm_chip *chip, > * the PWM core. > */ > state->duty_cycle = min(state->duty_cycle, state->period); > + > + return 0; > } > > static int sl28cpld_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c > index 7004f55bbf11..bda8bc5af976 100644 > --- a/drivers/pwm/pwm-sprd.c > +++ b/drivers/pwm/pwm-sprd.c > @@ -65,8 +65,8 @@ static void sprd_pwm_write(struct sprd_pwm_chip *spc, u32 hwid, > writel_relaxed(val, spc->base + offset); > } > > -static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct sprd_pwm_chip *spc = > container_of(chip, struct sprd_pwm_chip, chip); > @@ -83,7 +83,7 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > if (ret) { > dev_err(spc->dev, "failed to enable pwm%u clocks\n", > pwm->hwpwm); > - return; > + return 0; > } > > val = sprd_pwm_read(spc, pwm->hwpwm, SPRD_PWM_ENABLE); > @@ -113,6 +113,8 @@ static void sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > /* Disable PWM clocks if the PWM channel is not in enable state. */ > if (!state->enabled) > clk_bulk_disable_unprepare(SPRD_PWM_CHN_CLKS_NUM, chn->clks); > + > + return 0; > } > > static int sprd_pwm_config(struct sprd_pwm_chip *spc, struct pwm_device *pwm, > diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c > index 3115abb3f52a..39364c52cfe4 100644 > --- a/drivers/pwm/pwm-stm32-lp.c > +++ b/drivers/pwm/pwm-stm32-lp.c > @@ -157,9 +157,9 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > -static void stm32_pwm_lp_get_state(struct pwm_chip *chip, > - struct pwm_device *pwm, > - struct pwm_state *state) > +static int stm32_pwm_lp_get_state(struct pwm_chip *chip, > + struct pwm_device *pwm, > + struct pwm_state *state) > { > struct stm32_pwm_lp *priv = to_stm32_pwm_lp(chip); > unsigned long rate = clk_get_rate(priv->clk); > @@ -185,6 +185,8 @@ static void stm32_pwm_lp_get_state(struct pwm_chip *chip, > tmp = prd - val; > tmp = (tmp << presc) * NSEC_PER_SEC; > state->duty_cycle = DIV_ROUND_CLOSEST_ULL(tmp, rate); > + > + return 0; > } > > static const struct pwm_ops stm32_pwm_lp_ops = { > 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, > diff --git a/drivers/pwm/pwm-sunplus.c b/drivers/pwm/pwm-sunplus.c > index e776fd16512d..d6ebe9f03b35 100644 > --- a/drivers/pwm/pwm-sunplus.c > +++ b/drivers/pwm/pwm-sunplus.c > @@ -124,8 +124,8 @@ static int sunplus_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > } > > -static void sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state) > +static int sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state) > { > struct sunplus_pwm *priv = to_sunplus_pwm(chip); > u32 mode0, dd_freq, duty; > @@ -155,6 +155,8 @@ static void sunplus_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > } > > state->polarity = PWM_POLARITY_NORMAL; > + > + return 0; > } > > static const struct pwm_ops sunplus_pwm_ops = { > diff --git 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 a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c > index 4dab2b86c427..f7a50fdcd9a5 100644 > --- a/drivers/pwm/pwm-xilinx.c > +++ b/drivers/pwm/pwm-xilinx.c > @@ -169,9 +169,9 @@ static int xilinx_pwm_apply(struct pwm_chip *chip, struct pwm_device *unused, > return 0; > } > > -static void xilinx_pwm_get_state(struct pwm_chip *chip, > - struct pwm_device *unused, > - struct pwm_state *state) > +static int xilinx_pwm_get_state(struct pwm_chip *chip, > + struct pwm_device *unused, > + struct pwm_state *state) > { > struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip); > u32 tlr0, tlr1, tcsr0, tcsr1; > @@ -191,6 +191,8 @@ static void xilinx_pwm_get_state(struct pwm_chip *chip, > */ > if (state->period == state->duty_cycle) > state->duty_cycle = 0; > + > + return 0; > } > > static const struct pwm_ops xilinx_pwm_ops = { > diff --git a/include/linux/pwm.h b/include/linux/pwm.h > index d70c6e5a839d..4de09163c968 100644 > --- a/include/linux/pwm.h > +++ b/include/linux/pwm.h > @@ -276,8 +276,8 @@ struct pwm_ops { > struct pwm_capture *result, unsigned long timeout); > int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm, > const struct pwm_state *state); > - void (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, > - struct pwm_state *state); > + int (*get_state)(struct pwm_chip *chip, struct pwm_device *pwm, > + struct pwm_state *state); > struct module *owner; > }; > > -- > 2.38.1 > ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (5 preceding siblings ...) 2022-12-01 10:43 ` Dave Stevenson @ 2022-12-01 15:37 ` Doug Anderson 2022-12-05 20:50 ` Jernej Škrabec 2022-12-05 22:30 ` Pavel Machek 8 siblings, 0 replies; 47+ messages in thread From: Doug Anderson @ 2022-12-01 15:37 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Conor Dooley, Linus Walleij, Bartosz Golaszewski, 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi Hi, On Wed, Nov 30, 2022 at 7:22 AM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > .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@pengutronix.de> > --- > 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(-) For ti-sn65dsi86.c: Acked-by: Douglas Anderson <dianders@chromium.org> ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (6 preceding siblings ...) 2022-12-01 15:37 ` Doug Anderson @ 2022-12-05 20:50 ` Jernej Škrabec 2022-12-05 22:30 ` Pavel Machek 8 siblings, 0 replies; 47+ messages in thread From: Jernej Škrabec @ 2022-12-05 20:50 UTC (permalink / raw) To: Thierry Reding, Uwe Kleine-König Cc: 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi Dne sreda, 30. november 2022 ob 16:21:38 CET je Uwe Kleine-König napisal(a): > .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@pengutronix.de> > --- > 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(-) > <snip> > 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 sun4i: Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Best regards, Jernej ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König ` (7 preceding siblings ...) 2022-12-05 20:50 ` Jernej Škrabec @ 2022-12-05 22:30 ` Pavel Machek 8 siblings, 0 replies; 47+ messages in thread From: Pavel Machek @ 2022-12-05 22:30 UTC (permalink / raw) To: Uwe Kleine-König 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi [-- Attachment #1: Type: text/plain, Size: 3300 bytes --] 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 <u.kleine-koenig@pengutronix.de> LED part: Acked-by: Pavel Machek <pavel@ucw.cz> Best regards, Pavel > static const struct pwm_ops ti_sn_pwm_ops = { > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-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, struct pwm_device *pwm, > return ret; > } > > -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 *pwm, > + struct pwm_state *state) > { > struct lpg *lpg = container_of(chip, struct lpg, pwm); > struct lpg_channel *chan = &lpg->channels[pwm->hwpwm]; > @@ -982,20 +982,20 @@ static void lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); > if (ret) > - return; > + return 0; > > refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; > if (refclk) { > ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); > if (ret) > - return; > + return 0; > > pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; > m = FIELD_GET(PWM_FREQ_EXP_MASK, val); > > ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value)); > if (ret) > - return; > + return 0; > > state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk); > state->duty_cycle = 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 *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val); > if (ret) > - return; > + return 0; > > state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); > state->polarity = PWM_POLARITY_NORMAL; > > if (state->duty_cycle > state->period) > state->duty_cycle = state->period; > + > + return 0; > } -- People of Russia, stop Putin before his war on Ukraine escalates. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-11-30 20:15 ` Steven Rostedt 2022-11-30 15:21 ` [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller Uwe Kleine-König ` (10 subsequent siblings) 12 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding; +Cc: Conor Dooley, Steven Rostedt, Masami Hiramatsu, linux-pwm Record and report an error code for the events. This allows to report about failed calls without ambiguity and so gives a more complete picture. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/core.c | 18 ++++++++---------- include/trace/events/pwm.h | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index d333e7422f4a..21e1553495ee 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -108,8 +108,8 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label) } if (pwm->chip->ops->get_state) { - pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state); - trace_pwm_get(pwm, &pwm->state); + err = pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state); + trace_pwm_get(pwm, &pwm->state, err); if (IS_ENABLED(CONFIG_PWM_DEBUG)) pwm->last = pwm->state; @@ -457,8 +457,8 @@ static void pwm_apply_state_debug(struct pwm_device *pwm, * checks. */ - chip->ops->get_state(chip, pwm, &s1); - trace_pwm_get(pwm, &s1); + err = chip->ops->get_state(chip, pwm, &s1); + trace_pwm_get(pwm, &s1, err); /* * The lowlevel driver either ignored .polarity (which is a bug) or as @@ -514,16 +514,15 @@ static void pwm_apply_state_debug(struct pwm_device *pwm, /* reapply the state that the driver reported being configured. */ err = chip->ops->apply(chip, pwm, &s1); + trace_pwm_apply(pwm, &s1, err); if (err) { *last = s1; dev_err(chip->dev, "failed to reapply current setting\n"); return; } - trace_pwm_apply(pwm, &s1); - - chip->ops->get_state(chip, pwm, last); - trace_pwm_get(pwm, last); + err = chip->ops->get_state(chip, pwm, last); + trace_pwm_get(pwm, last, err); /* reapplication of the current state should give an exact match */ if (s1.enabled != last->enabled || @@ -571,11 +570,10 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state) return 0; err = chip->ops->apply(chip, pwm, state); + trace_pwm_apply(pwm, state, err); if (err) return err; - trace_pwm_apply(pwm, state); - pwm->state = *state; /* diff --git a/include/trace/events/pwm.h b/include/trace/events/pwm.h index cf243de41cc8..12b35e4ff917 100644 --- a/include/trace/events/pwm.h +++ b/include/trace/events/pwm.h @@ -10,9 +10,9 @@ DECLARE_EVENT_CLASS(pwm, - TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state), + TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), - TP_ARGS(pwm, state), + TP_ARGS(pwm, state, err), TP_STRUCT__entry( __field(struct pwm_device *, pwm) @@ -20,6 +20,7 @@ DECLARE_EVENT_CLASS(pwm, __field(u64, duty_cycle) __field(enum pwm_polarity, polarity) __field(bool, enabled) + __field(int, err) ), TP_fast_assign( @@ -28,28 +29,27 @@ DECLARE_EVENT_CLASS(pwm, __entry->duty_cycle = state->duty_cycle; __entry->polarity = state->polarity; __entry->enabled = state->enabled; + __entry->err = err; ), - TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d", + TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d", __entry->pwm, __entry->period, __entry->duty_cycle, - __entry->polarity, __entry->enabled) + __entry->polarity, __entry->enabled, __entry->err) ); DEFINE_EVENT(pwm, pwm_apply, - TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state), - - TP_ARGS(pwm, state) + TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), + TP_ARGS(pwm, state, err) ); DEFINE_EVENT(pwm, pwm_get, - TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state), - - TP_ARGS(pwm, state) + TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), + TP_ARGS(pwm, state, err) ); #endif /* _TRACE_PWM_H */ -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls 2022-11-30 15:21 ` [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls Uwe Kleine-König @ 2022-11-30 20:15 ` Steven Rostedt 2022-12-01 7:09 ` Uwe Kleine-König 0 siblings, 1 reply; 47+ messages in thread From: Steven Rostedt @ 2022-11-30 20:15 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Conor Dooley, Masami Hiramatsu, linux-pwm On Wed, 30 Nov 2022 16:21:39 +0100 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > diff --git a/include/trace/events/pwm.h b/include/trace/events/pwm.h > index cf243de41cc8..12b35e4ff917 100644 > --- a/include/trace/events/pwm.h > +++ b/include/trace/events/pwm.h > @@ -10,9 +10,9 @@ > > DECLARE_EVENT_CLASS(pwm, > > - TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state), > + TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), > > - TP_ARGS(pwm, state), > + TP_ARGS(pwm, state, err), > > TP_STRUCT__entry( > __field(struct pwm_device *, pwm) > @@ -20,6 +20,7 @@ DECLARE_EVENT_CLASS(pwm, > __field(u64, duty_cycle) > __field(enum pwm_polarity, polarity) > __field(bool, enabled) > + __field(int, err) > ), If you are changing this, perhaps order it a bit like: TP_STRUCT__entry( __field(u64, period) __field(u64, duty_cycle) __field(struct pwm_device *, pwm) __field(enum pwm_polarity, polarity) __field(bool, enabled) __field(int, err) ), And that way the struct pwm_device pointer will not cause a 4 byte hole on 32bit architectures. > > TP_fast_assign( > @@ -28,28 +29,27 @@ DECLARE_EVENT_CLASS(pwm, > __entry->duty_cycle = state->duty_cycle; > __entry->polarity = state->polarity; > __entry->enabled = state->enabled; > + __entry->err = err; > ), > > - TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d", > + TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d", > __entry->pwm, __entry->period, __entry->duty_cycle, > - __entry->polarity, __entry->enabled) > + __entry->polarity, __entry->enabled, __entry->err) Hmm, and why not show the values here: TRACE_DEFINE_ENUM(PWM_POLARITY_NORMAL); TRACE_DEFINE_ENUM(PWM_POLARITY_INVERSED); TP_printk("%p: period=%llu duty_cycle=%llu polarity=%s enabled=%d err=%d", __entry->pwm, __entry->period, __entry->duty_cycle, __print_symbolic(__entry->polarity, {PWM_POLARITY_NORMAL, "normal"}, {PWM_POLARITY_INVERSED, "inversed"}), __entry->enabled, __entry->err) -- Steve > > ); ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls 2022-11-30 20:15 ` Steven Rostedt @ 2022-12-01 7:09 ` Uwe Kleine-König 0 siblings, 0 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-01 7:09 UTC (permalink / raw) To: Steven Rostedt; +Cc: Thierry Reding, Conor Dooley, Masami Hiramatsu, linux-pwm [-- Attachment #1: Type: text/plain, Size: 3010 bytes --] Hello Steven, On Wed, Nov 30, 2022 at 03:15:11PM -0500, Steven Rostedt wrote: > On Wed, 30 Nov 2022 16:21:39 +0100 > Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > > diff --git a/include/trace/events/pwm.h b/include/trace/events/pwm.h > > index cf243de41cc8..12b35e4ff917 100644 > > --- a/include/trace/events/pwm.h > > +++ b/include/trace/events/pwm.h > > @@ -10,9 +10,9 @@ > > > > DECLARE_EVENT_CLASS(pwm, > > > > - TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state), > > + TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err), > > > > - TP_ARGS(pwm, state), > > + TP_ARGS(pwm, state, err), > > > > TP_STRUCT__entry( > > __field(struct pwm_device *, pwm) > > @@ -20,6 +20,7 @@ DECLARE_EVENT_CLASS(pwm, > > __field(u64, duty_cycle) > > __field(enum pwm_polarity, polarity) > > __field(bool, enabled) > > + __field(int, err) > > ), > > If you are changing this, perhaps order it a bit like: > > TP_STRUCT__entry( > __field(u64, period) > __field(u64, duty_cycle) > __field(struct pwm_device *, pwm) > __field(enum pwm_polarity, polarity) > __field(bool, enabled) > __field(int, err) > ), > > And that way the struct pwm_device pointer will not cause a 4 byte hole on > 32bit architectures. I'd do that in a separate patch, thanks for the feedback. > > TP_fast_assign( > > @@ -28,28 +29,27 @@ DECLARE_EVENT_CLASS(pwm, > > __entry->duty_cycle = state->duty_cycle; > > __entry->polarity = state->polarity; > > __entry->enabled = state->enabled; > > + __entry->err = err; > > ), > > > > - TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d", > > + TP_printk("%p: period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d", > > __entry->pwm, __entry->period, __entry->duty_cycle, > > - __entry->polarity, __entry->enabled) > > + __entry->polarity, __entry->enabled, __entry->err) > > Hmm, and why not show the values here: > > TRACE_DEFINE_ENUM(PWM_POLARITY_NORMAL); > TRACE_DEFINE_ENUM(PWM_POLARITY_INVERSED); > > TP_printk("%p: period=%llu duty_cycle=%llu polarity=%s enabled=%d err=%d", > __entry->pwm, __entry->period, __entry->duty_cycle, > __print_symbolic(__entry->polarity, > {PWM_POLARITY_NORMAL, "normal"}, > {PWM_POLARITY_INVERSED, "inversed"}), > __entry->enabled, __entry->err) Ditto. @Thierry: While the suggestions by Steven are cleanups that usually come first in a series and only then new stuff is added, I suggest to be not religious about that and implement these in patches based on this series. Independent of that, I'll wait some time to give others a change for feedback. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 15:37 ` Doug Anderson 2022-12-04 21:09 ` Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 04/11] leds: qcom-lpg: " Uwe Kleine-König ` (9 subsequent siblings) 12 siblings, 2 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding; +Cc: Conor Dooley, Douglas Anderson, dri-devel, linux-pwm .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 6826d2423ae9..9671071490d8 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1512,19 +1512,19 @@ static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); if (ret) - return 0; + return ret; ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); if (ret) - return 0; + return ret; ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); if (ret) - return 0; + return ret; ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); if (ret) - return 0; + return ret; state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller Uwe Kleine-König @ 2022-12-01 15:37 ` Doug Anderson 2022-12-04 21:09 ` Uwe Kleine-König 1 sibling, 0 replies; 47+ messages in thread From: Doug Anderson @ 2022-12-01 15:37 UTC (permalink / raw) To: Uwe Kleine-König; +Cc: Thierry Reding, Conor Dooley, dri-devel, linux-pwm Hi, On Wed, Nov 30, 2022 at 7:22 AM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) Acked-by: Douglas Anderson <dianders@chromium.org> ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller Uwe Kleine-König 2022-12-01 15:37 ` Doug Anderson @ 2022-12-04 21:09 ` Uwe Kleine-König 2022-12-04 21:31 ` Laurent Pinchart 2022-12-05 15:25 ` Doug Anderson 1 sibling, 2 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-04 21:09 UTC (permalink / raw) To: Thierry Reding, Andrzej Hajda, Neil Armstrong, Robert Foss Cc: Conor Dooley, Douglas Anderson, dri-devel, linux-pwm, Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Daniel Vetter [-- Attachment #1: Type: text/plain, Size: 1732 bytes --] Hello, my initial Cc-list wasn't optimal. So I added a few people here. On Wed, Nov 30, 2022 at 04:21:40PM +0100, Uwe Kleine-König wrote: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > index 6826d2423ae9..9671071490d8 100644 > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > @@ -1512,19 +1512,19 @@ static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); > if (ret) > - return 0; > + return ret; > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); > if (ret) > - return 0; > + return ret; > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); > if (ret) > - return 0; > + return ret; > > ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); > if (ret) > - return 0; > + return ret; > > state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); > if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) It would be great to get an Ack to take this patch and patch #1 via the PWM tree. (Both got an Ack by Douglas Anderson, I'm unsure if that is already enough.) Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller 2022-12-04 21:09 ` Uwe Kleine-König @ 2022-12-04 21:31 ` Laurent Pinchart 2022-12-05 15:25 ` Doug Anderson 1 sibling, 0 replies; 47+ messages in thread From: Laurent Pinchart @ 2022-12-04 21:31 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Andrzej Hajda, Neil Armstrong, Robert Foss, Conor Dooley, Douglas Anderson, dri-devel, linux-pwm, Jonas Karlman, Jernej Skrabec, Daniel Vetter On Sun, Dec 04, 2022 at 10:09:40PM +0100, Uwe Kleine-König wrote: > Hello, > > my initial Cc-list wasn't optimal. So I added a few people here. > > On Wed, Nov 30, 2022 at 04:21:40PM +0100, Uwe Kleine-König wrote: > > .get_state() can return an error indication. Make use of it to propagate > > failing hardware accesses. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > > --- > > drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > index 6826d2423ae9..9671071490d8 100644 > > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > @@ -1512,19 +1512,19 @@ static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > > > ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); > > if (ret) > > - return 0; > > + return ret; > > > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); > > if (ret) > > - return 0; > > + return ret; > > > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); > > if (ret) > > - return 0; > > + return ret; > > > > ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); > > if (ret) > > - return 0; > > + return ret; > > > > state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); > > if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) > > It would be great to get an Ack to take this patch and patch #1 via the > PWM tree. (Both got an Ack by Douglas Anderson, I'm unsure if that is > already enough.) -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller 2022-12-04 21:09 ` Uwe Kleine-König 2022-12-04 21:31 ` Laurent Pinchart @ 2022-12-05 15:25 ` Doug Anderson 1 sibling, 0 replies; 47+ messages in thread From: Doug Anderson @ 2022-12-05 15:25 UTC (permalink / raw) To: Uwe Kleine-König, Maxime Ripard Cc: Thierry Reding, Andrzej Hajda, Neil Armstrong, Robert Foss, Conor Dooley, dri-devel, linux-pwm, Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Daniel Vetter Hi, On Sun, Dec 4, 2022 at 1:09 PM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > > Hello, > > my initial Cc-list wasn't optimal. So I added a few people here. > > On Wed, Nov 30, 2022 at 04:21:40PM +0100, Uwe Kleine-König wrote: > > .get_state() can return an error indication. Make use of it to propagate > > failing hardware accesses. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > --- > > drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > index 6826d2423ae9..9671071490d8 100644 > > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > > @@ -1512,19 +1512,19 @@ static int ti_sn_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > > > ret = regmap_read(pdata->regmap, SN_PWM_EN_INV_REG, &pwm_en_inv); > > if (ret) > > - return 0; > > + return ret; > > > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_SCALE_REG, &scale); > > if (ret) > > - return 0; > > + return ret; > > > > ret = ti_sn65dsi86_read_u16(pdata, SN_BACKLIGHT_REG, &backlight); > > if (ret) > > - return 0; > > + return ret; > > > > ret = regmap_read(pdata->regmap, SN_PWM_PRE_DIV_REG, &pre_div); > > if (ret) > > - return 0; > > + return ret; > > > > state->enabled = FIELD_GET(SN_PWM_EN_MASK, pwm_en_inv); > > if (FIELD_GET(SN_PWM_INV_MASK, pwm_en_inv)) > > It would be great to get an Ack to take this patch and patch #1 via the > PWM tree. (Both got an Ack by Douglas Anderson, I'm unsure if that is > already enough.) I'm probably the main person who reviews patches to ti-sn65dsi86.c these days and I'm also typically the one landing patches, but officially this driver goes through "drm-misc". IMO it's fine for this to go through your tree and that's what I intended by my Ack. It seems highly unlikely to cause any merge conflicts. That being said, since we're drm-misc it means that the "adults" in the room (the ones who have to deal with fallout if there are merge conflicts) are supposed to be "Daniel, Jani and Sean" according to the docs [1]. ...though it seems like the drm-misc-next pull requests these days come from Maxime, so maybe he would be the right person to confirm that it could go through your tree? [1] https://people.freedesktop.org/~jani/html/drm-misc.html# ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (2 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-04 21:04 ` Uwe Kleine-König 2022-12-05 22:31 ` Pavel Machek 2022-11-30 15:21 ` [PATCH v2 05/11] pwm: crc: " Uwe Kleine-König ` (8 subsequent siblings) 12 siblings, 2 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Pavel Machek, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c index 741cc2fd817d..0dcc046a9a19 100644 --- a/drivers/leds/rgb/leds-qcom-lpg.c +++ b/drivers/leds/rgb/leds-qcom-lpg.c @@ -982,20 +982,20 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); if (ret) - return 0; + return ret; refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; if (refclk) { ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); if (ret) - return 0; + return ret; pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; m = FIELD_GET(PWM_FREQ_EXP_MASK, val); ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value)); if (ret) - return 0; + return ret; state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk); state->duty_cycle = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk); @@ -1006,7 +1006,7 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val); if (ret) - return 0; + return ret; state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); state->polarity = PWM_POLARITY_NORMAL; -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 04/11] leds: qcom-lpg: " Uwe Kleine-König @ 2022-12-04 21:04 ` Uwe Kleine-König 2022-12-04 22:28 ` Pavel Machek 2022-12-05 22:31 ` Pavel Machek 1 sibling, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-04 21:04 UTC (permalink / raw) To: Pavel Machek, Thierry Reding Cc: Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm [-- Attachment #1: Type: text/plain, Size: 2145 bytes --] Hello Pavel, On Wed, Nov 30, 2022 at 04:21:41PM +0100, Uwe Kleine-König wrote: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c > index 741cc2fd817d..0dcc046a9a19 100644 > --- a/drivers/leds/rgb/leds-qcom-lpg.c > +++ b/drivers/leds/rgb/leds-qcom-lpg.c > @@ -982,20 +982,20 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + LPG_SIZE_CLK_REG, &val); > if (ret) > - return 0; > + return ret; > > refclk = lpg_clk_rates[val & PWM_CLK_SELECT_MASK]; > if (refclk) { > ret = regmap_read(lpg->map, chan->base + LPG_PREDIV_CLK_REG, &val); > if (ret) > - return 0; > + return ret; > > pre_div = lpg_pre_divs[FIELD_GET(PWM_FREQ_PRE_DIV_MASK, val)]; > m = FIELD_GET(PWM_FREQ_EXP_MASK, val); > > ret = regmap_bulk_read(lpg->map, chan->base + PWM_VALUE_REG, &pwm_value, sizeof(pwm_value)); > if (ret) > - return 0; > + return ret; > > state->period = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * LPG_RESOLUTION * pre_div * (1 << m), refclk); > state->duty_cycle = DIV_ROUND_UP_ULL((u64)NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk); > @@ -1006,7 +1006,7 @@ static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > > ret = regmap_read(lpg->map, chan->base + PWM_ENABLE_CONTROL_REG, &val); > if (ret) > - return 0; > + return ret; > > state->enabled = FIELD_GET(LPG_ENABLE_CONTROL_OUTPUT, val); > state->polarity = PWM_POLARITY_NORMAL; It would be great to get an Ack from you for this patch and the led part of patch 1 to take it via the PWM tree. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2022-12-04 21:04 ` Uwe Kleine-König @ 2022-12-04 22:28 ` Pavel Machek 0 siblings, 0 replies; 47+ messages in thread From: Pavel Machek @ 2022-12-04 22:28 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm [-- Attachment #1: Type: text/plain, Size: 484 bytes --] Hi! > > .get_state() can return an error indication. Make use of it to propagate > > failing hardware accesses. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > It would be great to get an Ack from you for this patch and the led part > of patch 1 to take it via the PWM tree. Let me take a look at that tommorow. Sorry for the delay. Best regards, Pavel -- People of Russia, stop Putin before his war on Ukraine escalates. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 04/11] leds: qcom-lpg: " Uwe Kleine-König 2022-12-04 21:04 ` Uwe Kleine-König @ 2022-12-05 22:31 ` Pavel Machek 2023-01-04 16:56 ` Lee Jones 1 sibling, 1 reply; 47+ messages in thread From: Pavel Machek @ 2022-12-05 22:31 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm [-- Attachment #1: Type: text/plain, Size: 331 bytes --] Hi! > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Pavel Machek <pavel@ucw.cz> Best regards, Pavel -- People of Russia, stop Putin before his war on Ukraine escalates. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2022-12-05 22:31 ` Pavel Machek @ 2023-01-04 16:56 ` Lee Jones 2023-01-05 13:54 ` Uwe Kleine-König 0 siblings, 1 reply; 47+ messages in thread From: Lee Jones @ 2023-01-04 16:56 UTC (permalink / raw) To: Pavel Machek Cc: Uwe Kleine-König, Thierry Reding, Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm On Mon, 05 Dec 2022, Pavel Machek wrote: > Hi! > > > .get_state() can return an error indication. Make use of it to propagate > > failing hardware accesses. > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > Acked-by: Pavel Machek <pavel@ucw.cz> What's the merge strategy for this? Can it go in on its own? -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2023-01-04 16:56 ` Lee Jones @ 2023-01-05 13:54 ` Uwe Kleine-König 2023-01-05 16:29 ` Lee Jones 0 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2023-01-05 13:54 UTC (permalink / raw) To: Lee Jones Cc: Pavel Machek, Thierry Reding, Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm [-- Attachment #1: Type: text/plain, Size: 692 bytes --] On Wed, Jan 04, 2023 at 04:56:21PM +0000, Lee Jones wrote: > On Mon, 05 Dec 2022, Pavel Machek wrote: > > > Hi! > > > > > .get_state() can return an error indication. Make use of it to propagate > > > failing hardware accesses. > > > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > > Acked-by: Pavel Machek <pavel@ucw.cz> > > What's the merge strategy for this? Can it go in on its own? It's already in Linus's tree as fea768cf68c04d68ea2a8091c559667378f3b77c. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 04/11] leds: qcom-lpg: Propagate errors in .get_state() to the caller 2023-01-05 13:54 ` Uwe Kleine-König @ 2023-01-05 16:29 ` Lee Jones 0 siblings, 0 replies; 47+ messages in thread From: Lee Jones @ 2023-01-05 16:29 UTC (permalink / raw) To: Uwe Kleine-König Cc: Pavel Machek, Thierry Reding, Conor Dooley, Bjorn Andersson, Satya Priya, Marijn Suijten, linux-leds, linux-pwm On Thu, 05 Jan 2023, Uwe Kleine-König wrote: > On Wed, Jan 04, 2023 at 04:56:21PM +0000, Lee Jones wrote: > > On Mon, 05 Dec 2022, Pavel Machek wrote: > > > > > Hi! > > > > > > > .get_state() can return an error indication. Make use of it to propagate > > > > failing hardware accesses. > > > > > > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > > > > Acked-by: Pavel Machek <pavel@ucw.cz> > > > > What's the merge strategy for this? Can it go in on its own? > > It's already in Linus's tree as fea768cf68c04d68ea2a8091c559667378f3b77c. Interesting. All good then, thanks for letting me know. -- Lee Jones [李琼斯] ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 05/11] pwm: crc: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (3 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 04/11] leds: qcom-lpg: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 06/11] pwm: cros-ec: " Uwe Kleine-König ` (7 subsequent siblings) 12 siblings, 0 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding; +Cc: Conor Dooley, linux-pwm .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-crc.c b/drivers/pwm/pwm-crc.c index 4099850117ba..4703b4a0b6e4 100644 --- a/drivers/pwm/pwm-crc.c +++ b/drivers/pwm/pwm-crc.c @@ -132,13 +132,13 @@ static int crc_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, error = regmap_read(crc_pwm->regmap, PWM0_CLK_DIV, &clk_div_reg); if (error) { dev_err(dev, "Error reading PWM0_CLK_DIV %d\n", error); - return 0; + return error; } error = regmap_read(crc_pwm->regmap, PWM0_DUTY_CYCLE, &duty_cycle_reg); if (error) { dev_err(dev, "Error reading PWM0_DUTY_CYCLE %d\n", error); - return 0; + return error; } clk_div = (clk_div_reg & ~PWM_OUTPUT_ENABLE) + 1; -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v2 06/11] pwm: cros-ec: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (4 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 05/11] pwm: crc: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 2:41 ` Tzung-Bi Shih 2022-11-30 15:21 ` [PATCH v2 07/11] pwm: imx27: " Uwe Kleine-König ` (6 subsequent siblings) 12 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Benson Leung, Guenter Roeck, linux-pwm, chrome-platform .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-cros-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c index 11684edc0620..86df6702cb83 100644 --- a/drivers/pwm/pwm-cros-ec.c +++ b/drivers/pwm/pwm-cros-ec.c @@ -193,7 +193,7 @@ static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm); if (ret < 0) { dev_err(chip->dev, "error getting initial duty: %d\n", ret); - return 0; + return ret; } state->enabled = (ret > 0); -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 06/11] pwm: cros-ec: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 06/11] pwm: cros-ec: " Uwe Kleine-König @ 2022-12-01 2:41 ` Tzung-Bi Shih 0 siblings, 0 replies; 47+ messages in thread From: Tzung-Bi Shih @ 2022-12-01 2:41 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, Conor Dooley, Benson Leung, Guenter Roeck, linux-pwm, chrome-platform On Wed, Nov 30, 2022 at 04:21:43PM +0100, Uwe Kleine-König wrote: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 07/11] pwm: imx27: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (5 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 06/11] pwm: cros-ec: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 08/11] pwm: mtk-disp: " Uwe Kleine-König ` (5 subsequent siblings) 12 siblings, 0 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team, linux-pwm, linux-arm-kernel .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-imx27.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 3a22c2fddc45..29a3089c534c 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -128,7 +128,7 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, ret = pwm_imx27_clk_prepare_enable(imx); if (ret < 0) - return 0; + return ret; val = readl(imx->mmio_base + MX3_PWMCR); -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH v2 08/11] pwm: mtk-disp: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (6 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 07/11] pwm: imx27: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 13:11 ` AngeloGioacchino Del Regno 2022-11-30 15:21 ` [PATCH v2 09/11] pwm: rockchip: " Uwe Kleine-König ` (4 subsequent siblings) 12 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Matthias Brugger, linux-pwm, linux-arm-kernel, linux-mediatek .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-mtk-disp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c index 9a6bb334a31b..67e5799dd157 100644 --- a/drivers/pwm/pwm-mtk-disp.c +++ b/drivers/pwm/pwm-mtk-disp.c @@ -184,14 +184,14 @@ static int mtk_disp_pwm_get_state(struct pwm_chip *chip, err = clk_prepare_enable(mdp->clk_main); if (err < 0) { dev_err(chip->dev, "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); - return 0; + return err; } err = clk_prepare_enable(mdp->clk_mm); if (err < 0) { dev_err(chip->dev, "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); clk_disable_unprepare(mdp->clk_main); - return 0; + return err; } rate = clk_get_rate(mdp->clk_main); -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 08/11] pwm: mtk-disp: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 08/11] pwm: mtk-disp: " Uwe Kleine-König @ 2022-12-01 13:11 ` AngeloGioacchino Del Regno 0 siblings, 0 replies; 47+ messages in thread From: AngeloGioacchino Del Regno @ 2022-12-01 13:11 UTC (permalink / raw) To: Uwe Kleine-König, Thierry Reding Cc: Conor Dooley, Matthias Brugger, linux-pwm, linux-arm-kernel, linux-mediatek Il 30/11/22 16:21, Uwe Kleine-König ha scritto: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 09/11] pwm: rockchip: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (7 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 08/11] pwm: mtk-disp: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-11-30 18:37 ` Heiko Stübner 2022-11-30 15:21 ` [PATCH v2 10/11] pwm: sprd: " Uwe Kleine-König ` (3 subsequent siblings) 12 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Heiko Stuebner, linux-pwm, linux-arm-kernel, linux-rockchip .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-rockchip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index 3ec7d1756903..7f084eb34092 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -70,11 +70,11 @@ static int rockchip_pwm_get_state(struct pwm_chip *chip, ret = clk_enable(pc->pclk); if (ret) - return 0; + return ret; ret = clk_enable(pc->clk); if (ret) - return 0; + return ret; clk_rate = clk_get_rate(pc->clk); -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 09/11] pwm: rockchip: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 09/11] pwm: rockchip: " Uwe Kleine-König @ 2022-11-30 18:37 ` Heiko Stübner 0 siblings, 0 replies; 47+ messages in thread From: Heiko Stübner @ 2022-11-30 18:37 UTC (permalink / raw) To: Thierry Reding, Uwe Kleine-König Cc: Conor Dooley, linux-pwm, linux-arm-kernel, linux-rockchip Am Mittwoch, 30. November 2022, 16:21:46 CET schrieb Uwe Kleine-König: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Heiko Stuebner <heiko@sntech.de> ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 10/11] pwm: sprd: Propagate errors in .get_state() to the caller 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (8 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 09/11] pwm: rockchip: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 1:18 ` Baolin Wang 2022-11-30 15:21 ` [PATCH v2 11/11] pwm: Handle .get_state() failures Uwe Kleine-König ` (2 subsequent siblings) 12 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding Cc: Conor Dooley, Orson Zhai, Baolin Wang, Chunyan Zhang, linux-pwm .get_state() can return an error indication. Make use of it to propagate failing hardware accesses. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-sprd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c index bda8bc5af976..d866ce345f97 100644 --- a/drivers/pwm/pwm-sprd.c +++ b/drivers/pwm/pwm-sprd.c @@ -83,7 +83,7 @@ static int sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, if (ret) { dev_err(spc->dev, "failed to enable pwm%u clocks\n", pwm->hwpwm); - return 0; + return ret; } val = sprd_pwm_read(spc, pwm->hwpwm, SPRD_PWM_ENABLE); -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 10/11] pwm: sprd: Propagate errors in .get_state() to the caller 2022-11-30 15:21 ` [PATCH v2 10/11] pwm: sprd: " Uwe Kleine-König @ 2022-12-01 1:18 ` Baolin Wang 0 siblings, 0 replies; 47+ messages in thread From: Baolin Wang @ 2022-12-01 1:18 UTC (permalink / raw) To: Uwe Kleine-König, Thierry Reding Cc: Conor Dooley, Orson Zhai, Chunyan Zhang, linux-pwm On 11/30/2022 11:21 PM, Uwe Kleine-König wrote: > .get_state() can return an error indication. Make use of it to propagate > failing hardware accesses. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> LGTM. Thanks. Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> > --- > drivers/pwm/pwm-sprd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c > index bda8bc5af976..d866ce345f97 100644 > --- a/drivers/pwm/pwm-sprd.c > +++ b/drivers/pwm/pwm-sprd.c > @@ -83,7 +83,7 @@ static int sprd_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, > if (ret) { > dev_err(spc->dev, "failed to enable pwm%u clocks\n", > pwm->hwpwm); > - return 0; > + return ret; > } > > val = sprd_pwm_read(spc, pwm->hwpwm, SPRD_PWM_ENABLE); ^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH v2 11/11] pwm: Handle .get_state() failures 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (9 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 10/11] pwm: sprd: " Uwe Kleine-König @ 2022-11-30 15:21 ` Uwe Kleine-König 2022-12-01 11:11 ` [PATCH v2 00/11] pwm: Allow .get_state to fail Conor Dooley 2022-12-09 21:47 ` Andy Shevchenko 12 siblings, 0 replies; 47+ messages in thread From: Uwe Kleine-König @ 2022-11-30 15:21 UTC (permalink / raw) To: Thierry Reding; +Cc: Conor Dooley, linux-pwm This suppresses diagnosis for PWM_DEBUG routines and makes sure that pwm->state isn't modified in pwm_device_request() if .get_state() fails. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 21e1553495ee..855c3885f94b 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -108,8 +108,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label) } if (pwm->chip->ops->get_state) { - err = pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state); - trace_pwm_get(pwm, &pwm->state, err); + struct pwm_state state; + + err = pwm->chip->ops->get_state(pwm->chip, pwm, &state); + trace_pwm_get(pwm, &state, err); + + if (!err) + pwm->state = state; if (IS_ENABLED(CONFIG_PWM_DEBUG)) pwm->last = pwm->state; @@ -459,6 +464,9 @@ static void pwm_apply_state_debug(struct pwm_device *pwm, err = chip->ops->get_state(chip, pwm, &s1); trace_pwm_get(pwm, &s1, err); + if (err) + /* If that failed there isn't much to debug */ + return; /* * The lowlevel driver either ignored .polarity (which is a bug) or as @@ -523,6 +531,8 @@ static void pwm_apply_state_debug(struct pwm_device *pwm, err = chip->ops->get_state(chip, pwm, last); trace_pwm_get(pwm, last, err); + if (err) + return; /* reapplication of the current state should give an exact match */ if (s1.enabled != last->enabled || -- 2.38.1 ^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (10 preceding siblings ...) 2022-11-30 15:21 ` [PATCH v2 11/11] pwm: Handle .get_state() failures Uwe Kleine-König @ 2022-12-01 11:11 ` Conor Dooley 2022-12-01 13:19 ` Uwe Kleine-König 2022-12-09 21:47 ` Andy Shevchenko 12 siblings, 1 reply; 47+ messages in thread From: Conor Dooley @ 2022-12-01 11:11 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, 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, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi, Steven Rostedt, Masami Hiramatsu, Marijn Suijten Hey Uwe! On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: > Hello, > > I forgot about this series and was remembered when I talked to Conor > Dooley about how .get_state() should behave in an error case. In the context of "my" driver, get_state() the proposal was to fail with -ETIMEDOUT rather than block a caller, potentially, for seconds or report a potentially "random" state. Specifically, values writen to the registers that control the PWM duty cycle are not visible to the cpu until the changes have propagated to the waveform at the start of a new period. The timeout would occur if the bit that signifies that the "shadow registers" contain a value which has not yet propagated. This bit is per PWM "controller" and not per PWM channel. Returning from apply() without waiting, possibly for seconds, for the writes to become visible could cause get_state() to see anything between the new and old states, inclusive! If anyone cares at all, the discussion is here: https://lore.kernel.org/linux-pwm/20221110093512.333881-1-conor.dooley@microchip.com/T/#m800eeabad29067940a5684e54106fd0bb7261944 > In v1 Thierry had the concern: > > | That raises the question about what to do in these cases. If we return > | an error, that could potentially throw off consumers. So perhaps the > | closest would be to return a disabled PWM? > | Or perhaps it'd be up to the > | consumer to provide some fallback configuration for invalidly configured > | or unconfigured PWMs. > > .get_state() is only called in pwm_device_request on a pwm_state that a > consumer might see. Before my series a consumer might have seen a > partial modified pwm_state (because .get_state() might have modified > .period, then stumbled and returned silently). The last patch ensures > that this partial modification isn't given out to the consumer. Instead > they now see the same as if .get_state wasn't implemented at all. Getting the same thing as if get_state() did not exist seems preferable to me in this context than "lying" and pretending that a PWM is disabled or potentially inconsistent reports from get_state() that I mentioned above. TL;DR, I quite like the ability to return an error and not mislead the caller. Thanks for sending a v2 of this so quickly :) Conor. ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-01 11:11 ` [PATCH v2 00/11] pwm: Allow .get_state to fail Conor Dooley @ 2022-12-01 13:19 ` Uwe Kleine-König 2022-12-01 13:28 ` Conor Dooley 0 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-01 13:19 UTC (permalink / raw) To: Conor Dooley Cc: Alexandre Belloni, Heiko Stuebner, Linus Walleij, Alexandre Torgue, dri-devel, Nicolas Ferre, Thierry Reding, Satya Priya, Pavel Machek, Guenter Roeck, Marijn Suijten, Nobuhiro Iwamatsu, Fabio Estevam, linux-riscv, linux-leds, Jerome Brunet, chrome-platform, Florian Fainelli, Samuel Holland, Sean Anderson, Kevin Hilman, Bartosz Golaszewski, Michal Simek, linux-stm32, Hammer Hsieh, linux-rockchip, Chen-Yu Tsai, Matthias Kaehlcke, Broadcom internal kernel review list, NXP Linux Team, Orson Zhai, linux-sunxi, linux-pwm, Maxime Coquelin, Martin Blumenstingl, Ray Jui, Sascha Hauer, Steven Rostedt, Stephen Boyd, linux-gpio, Fabrice Gasnier, linux-mediatek, linux-rpi-kernel, Baolin Wang, Paul Walmsley, Matthias Brugger, linux-amlogic, Benson Leung, linux-arm-kernel, Scott Branden, Bjorn Andersson, Douglas Anderson, Michael Walle, Palmer Dabbelt, Masami Hiramatsu, Pengutronix Kernel Team, Chunyan Zhang, Shawn Guo, Claudiu Beznea [-- Attachment #1: Type: text/plain, Size: 363 bytes --] Hello Conor, On Thu, Dec 01, 2022 at 11:11:51AM +0000, Conor Dooley wrote: > TL;DR, I quite like the ability to return an error and not mislead the > caller. Is this an Ack? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-01 13:19 ` Uwe Kleine-König @ 2022-12-01 13:28 ` Conor Dooley 0 siblings, 0 replies; 47+ messages in thread From: Conor Dooley @ 2022-12-01 13:28 UTC (permalink / raw) To: Uwe Kleine-König Cc: Alexandre Belloni, Alexandre Torgue, dri-devel, Douglas Anderson, Thierry Reding, Satya Priya, Pavel Machek, Guenter Roeck, Marijn Suijten, Nobuhiro Iwamatsu, linux-riscv, linux-leds, Jerome Brunet, chrome-platform, Florian Fainelli, Samuel Holland, Sean Anderson, Kevin Hilman, Bartosz Golaszewski, Michal Simek, linux-stm32, Hammer Hsieh, linux-rockchip, Chen-Yu Tsai, Matthias Kaehlcke, Broadcom internal kernel review list, NXP Linux Team, Orson Zhai, linux-sunxi, linux-pwm, Pengutronix Kernel Team, Martin Blumenstingl, Ray Jui, Sascha Hauer, Steven Rostedt, Stephen Boyd, linux-gpio, Fabrice Gasnier, linux-mediatek, linux-rpi-kernel, Baolin Wang, Paul Walmsley, Matthias Brugger, linux-amlogic, linux-arm-kernel, Scott Branden, Bjorn Andersson, Nicolas Ferre, Michael Walle, Palmer Dabbelt, Masami Hiramatsu, Maxime Coquelin, Chunyan Zhang, Shawn Guo, Claudiu Beznea On Thu, Dec 01, 2022 at 02:19:07PM +0100, Uwe Kleine-König wrote: > Hello Conor, > > On Thu, Dec 01, 2022 at 11:11:51AM +0000, Conor Dooley wrote: > > TL;DR, I quite like the ability to return an error and not mislead the > > caller. > > Is this an Ack? It is if you want it to be! I didn't really feel qualified to do so which is why I gave some context etc. I did check out the callsites for the non-void returning op, and it looked good to me, so sure, why not: Acked-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König ` (11 preceding siblings ...) 2022-12-01 11:11 ` [PATCH v2 00/11] pwm: Allow .get_state to fail Conor Dooley @ 2022-12-09 21:47 ` Andy Shevchenko 2022-12-10 9:18 ` Uwe Kleine-König 12 siblings, 1 reply; 47+ messages in thread From: Andy Shevchenko @ 2022-12-09 21:47 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: > Hello, > > I forgot about this series and was remembered when I talked to Conor > Dooley about how .get_state() should behave in an error case. > > Compared to (implicit) v1, sent with Message-Id: 20220916151506.298488-1-u.kleine-koenig@pengutronix.de > I changed: > > - Patch #1 which does the prototype change now just adds "return 0" to > all implementations and so gets simpler and doesn't change behaviour. > The adaptions to the different .get_state() implementations are split > out into individual patches to ease review. > - One minor inconsistency fixed in "pwm: Handle .get_state() failures" > that I noticed while looking into this patch. > - I skipped changing sun4i.c as I don't know how to handle the error > there. Someone might want to have a look. (That's not ideal, but it's > not worse than the same issue before this series.) > > In v1 Thierry had the concern: > > | That raises the question about what to do in these cases. If we return > | an error, that could potentially throw off consumers. So perhaps the > | closest would be to return a disabled PWM? Or perhaps it'd be up to the > | consumer to provide some fallback configuration for invalidly configured > | or unconfigured PWMs. > > .get_state() is only called in pwm_device_request on a pwm_state that a > consumer might see. Before my series a consumer might have seen a > partial modified pwm_state (because .get_state() might have modified > .period, then stumbled and returned silently). The last patch ensures > that this partial modification isn't given out to the consumer. Instead > they now see the same as if .get_state wasn't implemented at all. I'm wondering why we didn't see a compiler warning about mistyped function prototypes in some drivers. P.S. The series is good thing to do, thank you. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-09 21:47 ` Andy Shevchenko @ 2022-12-10 9:18 ` Uwe Kleine-König 2022-12-10 20:57 ` Andy Shevchenko 0 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-10 9:18 UTC (permalink / raw) To: Andy Shevchenko Cc: Thierry Reding, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi [-- Attachment #1: Type: text/plain, Size: 1482 bytes --] Hello Andy, On Fri, Dec 09, 2022 at 11:47:54PM +0200, Andy Shevchenko wrote: > On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: > > In v1 Thierry had the concern: > > > > | That raises the question about what to do in these cases. If we return > > | an error, that could potentially throw off consumers. So perhaps the > > | closest would be to return a disabled PWM? Or perhaps it'd be up to the > > | consumer to provide some fallback configuration for invalidly configured > > | or unconfigured PWMs. > > > > .get_state() is only called in pwm_device_request on a pwm_state that a > > consumer might see. Before my series a consumer might have seen a > > partial modified pwm_state (because .get_state() might have modified > > .period, then stumbled and returned silently). The last patch ensures > > that this partial modification isn't given out to the consumer. Instead > > they now see the same as if .get_state wasn't implemented at all. > > I'm wondering why we didn't see a compiler warning about mistyped function > prototypes in some drivers. I don't understand where you expected a warning. Care to elaborate? > P.S. The series is good thing to do, thank you. It's already too late for an ack, the series is already in Thierry's tree. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-10 9:18 ` Uwe Kleine-König @ 2022-12-10 20:57 ` Andy Shevchenko 2022-12-10 22:41 ` Uwe Kleine-König 0 siblings, 1 reply; 47+ messages in thread From: Andy Shevchenko @ 2022-12-10 20:57 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On Sat, Dec 10, 2022 at 10:18:33AM +0100, Uwe Kleine-König wrote: > On Fri, Dec 09, 2022 at 11:47:54PM +0200, Andy Shevchenko wrote: > > On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: ... > > I'm wondering why we didn't see a compiler warning about mistyped function > > prototypes in some drivers. > > I don't understand where you expected a warning. Care to elaborate? intel-lpss.c has the prototype that returns an int. IIRC it was like this before your patches. Now the above wondering passage... -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-10 20:57 ` Andy Shevchenko @ 2022-12-10 22:41 ` Uwe Kleine-König 2022-12-11 13:31 ` Andy Shevchenko 0 siblings, 1 reply; 47+ messages in thread From: Uwe Kleine-König @ 2022-12-10 22:41 UTC (permalink / raw) To: Andy Shevchenko Cc: Thierry Reding, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi [-- Attachment #1: Type: text/plain, Size: 927 bytes --] Hello Andy, On Sat, Dec 10, 2022 at 10:57:16PM +0200, Andy Shevchenko wrote: > On Sat, Dec 10, 2022 at 10:18:33AM +0100, Uwe Kleine-König wrote: > > On Fri, Dec 09, 2022 at 11:47:54PM +0200, Andy Shevchenko wrote: > > > On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: > > ... > > > > I'm wondering why we didn't see a compiler warning about mistyped function > > > prototypes in some drivers. > > > > I don't understand where you expected a warning. Care to elaborate? > > intel-lpss.c has the prototype that returns an int. IIRC it was like this Do you mean drivers/mfd/intel-lpss.c? That one doesn't implement a PWM?! And drivers/pwm/pwm-lpss.c is adapted by this series. One of us is confused ... Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH v2 00/11] pwm: Allow .get_state to fail 2022-12-10 22:41 ` Uwe Kleine-König @ 2022-12-11 13:31 ` Andy Shevchenko 0 siblings, 0 replies; 47+ messages in thread From: Andy Shevchenko @ 2022-12-11 13:31 UTC (permalink / raw) To: Uwe Kleine-König Cc: Thierry Reding, linux-pwm, linux-gpio, dri-devel, linux-leds, linux-arm-kernel, chrome-platform, linux-amlogic, linux-mediatek, linux-rpi-kernel, linux-rockchip, linux-riscv, linux-stm32, linux-sunxi On Sat, Dec 10, 2022 at 11:41:54PM +0100, Uwe Kleine-König wrote: > On Sat, Dec 10, 2022 at 10:57:16PM +0200, Andy Shevchenko wrote: > > On Sat, Dec 10, 2022 at 10:18:33AM +0100, Uwe Kleine-König wrote: > > > On Fri, Dec 09, 2022 at 11:47:54PM +0200, Andy Shevchenko wrote: > > > > On Wed, Nov 30, 2022 at 04:21:37PM +0100, Uwe Kleine-König wrote: ... > > > > I'm wondering why we didn't see a compiler warning about mistyped function > > > > prototypes in some drivers. > > > > > > I don't understand where you expected a warning. Care to elaborate? > > > > intel-lpss.c has the prototype that returns an int. IIRC it was like this > > Do you mean drivers/mfd/intel-lpss.c? That one doesn't implement a PWM?! Nope, I meant pwm-lpss.c. > And drivers/pwm/pwm-lpss.c is adapted by this series. That's what I didn't see how. > One of us is confused ... Yes, because when I have checked the branch based on Linux Next I already saw that get_state() returns a code and I wasn't aware that the series is already there. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 47+ messages in thread
end of thread, other threads:[~2023-01-05 16:30 UTC | newest] Thread overview: 47+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-11-30 15:21 [PATCH v2 00/11] pwm: Allow .get_state to fail Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 01/11] pwm: Make .get_state() callback return an error code Uwe Kleine-König 2022-12-01 1:17 ` Baolin Wang 2022-12-01 2:41 ` Tzung-Bi Shih 2022-12-01 8:03 ` Neil Armstrong 2022-12-01 9:30 ` nobuhiro1.iwamatsu 2022-12-01 10:22 ` Andre Przywara 2022-12-01 13:16 ` Uwe Kleine-König 2022-12-01 14:17 ` Andre Przywara 2022-12-01 10:43 ` Dave Stevenson 2022-12-01 15:37 ` Doug Anderson 2022-12-05 20:50 ` Jernej Škrabec 2022-12-05 22:30 ` Pavel Machek 2022-11-30 15:21 ` [PATCH v2 02/11] pwm/tracing: Also record trace events for failed API calls Uwe Kleine-König 2022-11-30 20:15 ` Steven Rostedt 2022-12-01 7:09 ` Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 03/11] drm/bridge: ti-sn65dsi86: Propagate errors in .get_state() to the caller Uwe Kleine-König 2022-12-01 15:37 ` Doug Anderson 2022-12-04 21:09 ` Uwe Kleine-König 2022-12-04 21:31 ` Laurent Pinchart 2022-12-05 15:25 ` Doug Anderson 2022-11-30 15:21 ` [PATCH v2 04/11] leds: qcom-lpg: " Uwe Kleine-König 2022-12-04 21:04 ` Uwe Kleine-König 2022-12-04 22:28 ` Pavel Machek 2022-12-05 22:31 ` Pavel Machek 2023-01-04 16:56 ` Lee Jones 2023-01-05 13:54 ` Uwe Kleine-König 2023-01-05 16:29 ` Lee Jones 2022-11-30 15:21 ` [PATCH v2 05/11] pwm: crc: " Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 06/11] pwm: cros-ec: " Uwe Kleine-König 2022-12-01 2:41 ` Tzung-Bi Shih 2022-11-30 15:21 ` [PATCH v2 07/11] pwm: imx27: " Uwe Kleine-König 2022-11-30 15:21 ` [PATCH v2 08/11] pwm: mtk-disp: " Uwe Kleine-König 2022-12-01 13:11 ` AngeloGioacchino Del Regno 2022-11-30 15:21 ` [PATCH v2 09/11] pwm: rockchip: " Uwe Kleine-König 2022-11-30 18:37 ` Heiko Stübner 2022-11-30 15:21 ` [PATCH v2 10/11] pwm: sprd: " Uwe Kleine-König 2022-12-01 1:18 ` Baolin Wang 2022-11-30 15:21 ` [PATCH v2 11/11] pwm: Handle .get_state() failures Uwe Kleine-König 2022-12-01 11:11 ` [PATCH v2 00/11] pwm: Allow .get_state to fail Conor Dooley 2022-12-01 13:19 ` Uwe Kleine-König 2022-12-01 13:28 ` Conor Dooley 2022-12-09 21:47 ` Andy Shevchenko 2022-12-10 9:18 ` Uwe Kleine-König 2022-12-10 20:57 ` Andy Shevchenko 2022-12-10 22:41 ` Uwe Kleine-König 2022-12-11 13:31 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox