]> Git Repo - J-linux.git/commitdiff
pwm: stm32: Change prototype of a helper to prepare further changes
authorUwe Kleine-König <[email protected]>
Wed, 14 Feb 2024 09:32:41 +0000 (10:32 +0100)
committerUwe Kleine-König <[email protected]>
Thu, 22 Feb 2024 13:39:24 +0000 (14:39 +0100)
This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given stm32_pwm. To just not have to do
that, rework stm32_pwm_raw_capture() to take a pwm_chip.

Link: https://lore.kernel.org/r/33790c64563cb0434d7156d96f189c6037b3eb0b.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <[email protected]>
drivers/pwm/pwm-stm32.c

index 202114c00ad39a5c4b056a5e19dd027d26313972..ec15bc51d930c18be969ca1b9ac0f73031bc2422 100644 (file)
@@ -90,11 +90,12 @@ static u32 active_channels(struct stm32_pwm *dev)
  * - Period     = t2 - t0
  * - Duty cycle = t1 - t0
  */
-static int stm32_pwm_raw_capture(struct stm32_pwm *priv, struct pwm_device *pwm,
+static int stm32_pwm_raw_capture(struct pwm_chip *chip, struct pwm_device *pwm,
                                 unsigned long tmo_ms, u32 *raw_prd,
                                 u32 *raw_dty)
 {
-       struct device *parent = priv->chip.dev->parent;
+       struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
+       struct device *parent = pwmchip_parent(chip)->parent;
        enum stm32_timers_dmas dma_id;
        u32 ccen, ccr;
        int ret;
@@ -170,7 +171,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
 
        ret = clk_enable(priv->clk);
        if (ret) {
-               dev_err(chip->dev, "failed to enable counter clock\n");
+               dev_err(pwmchip_parent(chip), "failed to enable counter clock\n");
                goto unlock;
        }
 
@@ -208,7 +209,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
                           TIM_CCER_CC12P : TIM_CCER_CC34P, pwm->hwpwm < 2 ?
                           TIM_CCER_CC2P : TIM_CCER_CC4P);
 
-       ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty);
+       ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty);
        if (ret)
                goto stop;
 
@@ -229,7 +230,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
                /* 2nd measure with new scale */
                psc /= scale;
                regmap_write(priv->regmap, TIM_PSC, psc);
-               ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd,
+               ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd,
                                            &raw_dty);
                if (ret)
                        goto stop;
@@ -257,7 +258,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
                           FIELD_PREP(TIM_CCMR_IC1PSC, icpsc) |
                           FIELD_PREP(TIM_CCMR_IC2PSC, icpsc));
 
-       ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty);
+       ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty);
        if (ret)
                goto stop;
 
This page took 0.054797 seconds and 4 git commands to generate.