]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pwm: imx27: Don't use pwm consumer API
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 26 Jan 2024 10:16:25 +0000 (11:16 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 15 Feb 2024 11:28:02 +0000 (12:28 +0100)
Lowlevel driver callbacks are not supposed to use the consumer API
functions. Currently this works, but with the upcoming locking changes
this maybe results in dead locks. So directly access pwm->state.

Link: https://lore.kernel.org/r/20240126101624.2056801-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-imx27.c

index 7d9bc43f12b0e96cf33b15e1a6f4247f8555d907..c825d3bcb329ac15eaf1f49ef88e403628e16b95 100644 (file)
@@ -204,8 +204,8 @@ static void pwm_imx27_wait_fifo_slot(struct pwm_chip *chip,
        sr = readl(imx->mmio_base + MX3_PWMSR);
        fifoav = FIELD_GET(MX3_PWMSR_FIFOAV, sr);
        if (fifoav == MX3_PWMSR_FIFOAV_4WORDS) {
-               period_ms = DIV_ROUND_UP_ULL(pwm_get_period(pwm),
-                                        NSEC_PER_MSEC);
+               period_ms = DIV_ROUND_UP_ULL(pwm->state.period,
+                                            NSEC_PER_MSEC);
                msleep(period_ms);
 
                sr = readl(imx->mmio_base + MX3_PWMSR);
@@ -219,14 +219,11 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 {
        unsigned long period_cycles, duty_cycles, prescale;
        struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip);
-       struct pwm_state cstate;
        unsigned long long c;
        unsigned long long clkrate;
        int ret;
        u32 cr;
 
-       pwm_get_state(pwm, &cstate);
-
        clkrate = clk_get_rate(imx->clk_per);
        c = clkrate * state->period;
 
@@ -254,7 +251,7 @@ static int pwm_imx27_apply(struct pwm_chip *chip, struct pwm_device *pwm,
         * Wait for a free FIFO slot if the PWM is already enabled, and flush
         * the FIFO if the PWM was disabled and is about to be enabled.
         */
-       if (cstate.enabled) {
+       if (pwm->state.enabled) {
                pwm_imx27_wait_fifo_slot(chip, pwm);
        } else {
                ret = pwm_imx27_clk_prepare_enable(imx);