[PATCH v5 6/8] pwm: stm32: Implementation of the waveform callbacks
Kees Bakker
kees at ijzerbout.nl
Tue Oct 1 12:17:47 PDT 2024
Op 20-09-2024 om 10:58 schreef Uwe Kleine-König:
> Convert the stm32 pwm driver to use the new callbacks for hardware
> programming.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at baylibre.com>
[...]
> +static int stm32_pwm_write_waveform(struct pwm_chip *chip,
> + struct pwm_device *pwm,
> + const void *_wfhw)
> +{
> + const struct stm32_pwm_waveform *wfhw = _wfhw;
> + struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
> + unsigned int ch = pwm->hwpwm;
> + int ret;
> +
> + ret = clk_enable(priv->clk);
> + if (ret)
> + return ret;
> +
> + if (wfhw->ccer & TIM_CCER_CCxE(ch + 1)) {
> + u32 ccer, mask;
> + unsigned int shift;
> + u32 ccmr;
> +
> + ret = regmap_read(priv->regmap, TIM_CCER, &ccer);
> + if (ret)
> + goto out;
> +
> + /* If there are other channels enabled, don't update PSC and ARR */
> + if (ccer & ~TIM_CCER_CCxE(ch + 1) & TIM_CCER_CCXE) {
> + u32 psc, arr;
> +
> + ret = regmap_read(priv->regmap, TIM_PSC, &psc);
> + if (ret)
> + goto out;
> +
> + if (psc != wfhw->psc) {
> + ret = -EBUSY;
> + goto out;
> + }
> +
> + regmap_read(priv->regmap, TIM_ARR, &arr);
Did you forget to assign to ret?
> + if (ret)
> + goto out;
> +
> [...]
More information about the linux-arm-kernel
mailing list