Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pwm: mediatek: Rework parameters for clk helper function

Convert pwm_mediatek_clk_enable() and pwm_mediatek_clk_disable() to take
lower level parameters. This enables these functions to be used in the next
commit when there is no valid pwm_chip and pwm_device yet.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20250725154506.2610172-13-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
f43e1280 88863c9d

+11 -13
+11 -13
drivers/pwm/pwm-mediatek.c
··· 65 65 return pwmchip_get_drvdata(chip); 66 66 } 67 67 68 - static int pwm_mediatek_clk_enable(struct pwm_chip *chip, 69 - struct pwm_device *pwm) 68 + static int pwm_mediatek_clk_enable(struct pwm_mediatek_chip *pc, 69 + unsigned int hwpwm) 70 70 { 71 - struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); 72 71 int ret; 73 72 74 73 ret = clk_prepare_enable(pc->clk_top); ··· 78 79 if (ret < 0) 79 80 goto disable_clk_top; 80 81 81 - ret = clk_prepare_enable(pc->clk_pwms[pwm->hwpwm]); 82 + ret = clk_prepare_enable(pc->clk_pwms[hwpwm]); 82 83 if (ret < 0) 83 84 goto disable_clk_main; 84 85 ··· 92 93 return ret; 93 94 } 94 95 95 - static void pwm_mediatek_clk_disable(struct pwm_chip *chip, 96 - struct pwm_device *pwm) 96 + static void pwm_mediatek_clk_disable(struct pwm_mediatek_chip *pc, 97 + unsigned int hwpwm) 97 98 { 98 - struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); 99 - 100 - clk_disable_unprepare(pc->clk_pwms[pwm->hwpwm]); 99 + clk_disable_unprepare(pc->clk_pwms[hwpwm]); 101 100 clk_disable_unprepare(pc->clk_main); 102 101 clk_disable_unprepare(pc->clk_top); 103 102 } ··· 138 141 u64 resolution; 139 142 int ret; 140 143 141 - ret = pwm_mediatek_clk_enable(chip, pwm); 144 + ret = pwm_mediatek_clk_enable(pc, pwm->hwpwm); 142 145 if (ret < 0) 143 146 return ret; 144 147 ··· 195 198 } 196 199 197 200 out: 198 - pwm_mediatek_clk_disable(chip, pwm); 201 + pwm_mediatek_clk_disable(pc, pwm->hwpwm); 199 202 200 203 return ret; 201 204 } ··· 203 206 static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm, 204 207 const struct pwm_state *state) 205 208 { 209 + struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip); 206 210 int err; 207 211 208 212 if (state->polarity != PWM_POLARITY_NORMAL) ··· 212 214 if (!state->enabled) { 213 215 if (pwm->state.enabled) { 214 216 pwm_mediatek_disable(chip, pwm); 215 - pwm_mediatek_clk_disable(chip, pwm); 217 + pwm_mediatek_clk_disable(pc, pwm->hwpwm); 216 218 } 217 219 218 220 return 0; ··· 223 225 return err; 224 226 225 227 if (!pwm->state.enabled) 226 - err = pwm_mediatek_clk_enable(chip, pwm); 228 + err = pwm_mediatek_clk_enable(pc, pwm->hwpwm); 227 229 228 230 return err; 229 231 }