pwm: fsl-ftm: Change prototype of a helper to prepare further changes
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 14 Feb 2024 09:31:24 +0000 (10:31 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 19 Feb 2024 10:04:08 +0000 (11:04 +0100)
This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given fsl_pwm_chip. To just not have to
do that, rework fsl_pwm_apply_config() to take a pwm_chip.

Link: https://lore.kernel.org/r/5f0e88afe25d6a218032891a34f963980814b760.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-fsl-ftm.c

index d1b6d1aa477369e4db5ffbd93a9319c137a367a7..5792c6ca449fd9e0426bb1b4f2a54a95b3d4da33 100644 (file)
@@ -221,10 +221,11 @@ static bool fsl_pwm_is_other_pwm_enabled(struct fsl_pwm_chip *fpc,
                return false;
 }
 
-static int fsl_pwm_apply_config(struct fsl_pwm_chip *fpc,
+static int fsl_pwm_apply_config(struct pwm_chip *chip,
                                struct pwm_device *pwm,
                                const struct pwm_state *newstate)
 {
+       struct fsl_pwm_chip *fpc = to_fsl_chip(chip);
        unsigned int duty;
        u32 reg_polarity;
 
@@ -232,7 +233,7 @@ static int fsl_pwm_apply_config(struct fsl_pwm_chip *fpc,
        bool do_write_period = false;
 
        if (!fsl_pwm_calculate_period(fpc, newstate->period, &periodcfg)) {
-               dev_err(fpc->chip.dev, "failed to calculate new period\n");
+               dev_err(chip->dev, "failed to calculate new period\n");
                return -EINVAL;
        }
 
@@ -246,7 +247,7 @@ static int fsl_pwm_apply_config(struct fsl_pwm_chip *fpc,
         */
        else if (!fsl_pwm_periodcfg_are_equal(&fpc->period, &periodcfg)) {
                if (fsl_pwm_is_other_pwm_enabled(fpc, pwm)) {
-                       dev_err(fpc->chip.dev,
+                       dev_err(chip->dev,
                                "Cannot change period for PWM %u, disable other PWMs first\n",
                                pwm->hwpwm);
                        return -EBUSY;
@@ -322,7 +323,7 @@ static int fsl_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                goto end_mutex;
        }
 
-       ret = fsl_pwm_apply_config(fpc, pwm, newstate);
+       ret = fsl_pwm_apply_config(chip, pwm, newstate);
        if (ret)
                goto end_mutex;