Skip to content

Commit d3817a6

Browse files
pascalljthierryreding
authored andcommitted
pwm: sun4i: Remove redundant needs_delay
'needs_delay' does now always evaluate to true, so remove all occurrences. Signed-off-by: Pascal Roeleven <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 6b28fb6 commit d3817a6

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/pwm/pwm-sun4i.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ struct sun4i_pwm_chip {
9090
spinlock_t ctrl_lock;
9191
const struct sun4i_pwm_data *data;
9292
unsigned long next_period[2];
93-
bool needs_delay[2];
9493
};
9594

9695
static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip)
@@ -287,7 +286,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
287286
sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm));
288287
sun4i_pwm->next_period[pwm->hwpwm] = jiffies +
289288
usecs_to_jiffies(cstate.period / 1000 + 1);
290-
sun4i_pwm->needs_delay[pwm->hwpwm] = true;
291289

292290
if (state->polarity != PWM_POLARITY_NORMAL)
293291
ctrl &= ~BIT_CH(PWM_ACT_STATE, pwm->hwpwm);
@@ -298,7 +296,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
298296

299297
if (state->enabled) {
300298
ctrl |= BIT_CH(PWM_EN, pwm->hwpwm);
301-
} else if (!sun4i_pwm->needs_delay[pwm->hwpwm]) {
299+
} else {
302300
ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm);
303301
ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
304302
}
@@ -310,23 +308,16 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
310308
if (state->enabled)
311309
return 0;
312310

313-
if (!sun4i_pwm->needs_delay[pwm->hwpwm]) {
314-
clk_disable_unprepare(sun4i_pwm->clk);
315-
return 0;
316-
}
317-
318311
/* We need a full period to elapse before disabling the channel. */
319312
now = jiffies;
320-
if (sun4i_pwm->needs_delay[pwm->hwpwm] &&
321-
time_before(now, sun4i_pwm->next_period[pwm->hwpwm])) {
313+
if (time_before(now, sun4i_pwm->next_period[pwm->hwpwm])) {
322314
delay_us = jiffies_to_usecs(sun4i_pwm->next_period[pwm->hwpwm] -
323315
now);
324316
if ((delay_us / 500) > MAX_UDELAY_MS)
325317
msleep(delay_us / 1000 + 1);
326318
else
327319
usleep_range(delay_us, delay_us * 2);
328320
}
329-
sun4i_pwm->needs_delay[pwm->hwpwm] = false;
330321

331322
spin_lock(&sun4i_pwm->ctrl_lock);
332323
ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG);

0 commit comments

Comments
 (0)