Skip to content

Commit 7339233

Browse files
committed
Merge tag 'pwm/for-6.16-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux
Pull pwm fixes from Uwe Kleine-König: "Two fixes for v6.16-rc6 The first patch fixes an embarrassing bug in the pwm core. I really wonder this wasn't found earlier since it's introduction in v6.11-rc1 as it greatly disturbs driving a PWM via sysfs. The second and last patch fixes a clock balance issue in an error path of the Mediatek PWM driver" * tag 'pwm/for-6.16-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux: pwm: mediatek: Ensure to disable clocks in error path pwm: Fix invalid state detection
2 parents 7278212 + 505b730 commit 7339233

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

drivers/pwm/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ static bool pwm_state_valid(const struct pwm_state *state)
596596
* and supposed to be ignored. So also ignore any strange values and
597597
* consider the state ok.
598598
*/
599-
if (state->enabled)
599+
if (!state->enabled)
600600
return true;
601601

602602
if (!state->period)

drivers/pwm/pwm-mediatek.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
130130
return ret;
131131

132132
clk_rate = clk_get_rate(pc->clk_pwms[pwm->hwpwm]);
133-
if (!clk_rate)
134-
return -EINVAL;
133+
if (!clk_rate) {
134+
ret = -EINVAL;
135+
goto out;
136+
}
135137

136138
/* Make sure we use the bus clock and not the 26MHz clock */
137139
if (pc->soc->has_ck_26m_sel)
@@ -150,9 +152,9 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
150152
}
151153

152154
if (clkdiv > PWM_CLK_DIV_MAX) {
153-
pwm_mediatek_clk_disable(chip, pwm);
154155
dev_err(pwmchip_parent(chip), "period of %d ns not supported\n", period_ns);
155-
return -EINVAL;
156+
ret = -EINVAL;
157+
goto out;
156158
}
157159

158160
if (pc->soc->pwm45_fixup && pwm->hwpwm > 2) {
@@ -169,9 +171,10 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
169171
pwm_mediatek_writel(pc, pwm->hwpwm, reg_width, cnt_period);
170172
pwm_mediatek_writel(pc, pwm->hwpwm, reg_thres, cnt_duty);
171173

174+
out:
172175
pwm_mediatek_clk_disable(chip, pwm);
173176

174-
return 0;
177+
return ret;
175178
}
176179

177180
static int pwm_mediatek_enable(struct pwm_chip *chip, struct pwm_device *pwm)

0 commit comments

Comments
 (0)