pwm: sun4i: Remove redundant needs_delay
'needs_delay' does now always evaluate to true, so remove all occurrences. Signed-off-by: Pascal Roeleven <dev@pascalroeleven.nl> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
6b28fb6f3c
commit
d3817a6470
|
@ -90,7 +90,6 @@ struct sun4i_pwm_chip {
|
||||||
spinlock_t ctrl_lock;
|
spinlock_t ctrl_lock;
|
||||||
const struct sun4i_pwm_data *data;
|
const struct sun4i_pwm_data *data;
|
||||||
unsigned long next_period[2];
|
unsigned long next_period[2];
|
||||||
bool needs_delay[2];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip)
|
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,
|
||||||
sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm));
|
sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm));
|
||||||
sun4i_pwm->next_period[pwm->hwpwm] = jiffies +
|
sun4i_pwm->next_period[pwm->hwpwm] = jiffies +
|
||||||
usecs_to_jiffies(cstate.period / 1000 + 1);
|
usecs_to_jiffies(cstate.period / 1000 + 1);
|
||||||
sun4i_pwm->needs_delay[pwm->hwpwm] = true;
|
|
||||||
|
|
||||||
if (state->polarity != PWM_POLARITY_NORMAL)
|
if (state->polarity != PWM_POLARITY_NORMAL)
|
||||||
ctrl &= ~BIT_CH(PWM_ACT_STATE, pwm->hwpwm);
|
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,
|
||||||
|
|
||||||
if (state->enabled) {
|
if (state->enabled) {
|
||||||
ctrl |= BIT_CH(PWM_EN, pwm->hwpwm);
|
ctrl |= BIT_CH(PWM_EN, pwm->hwpwm);
|
||||||
} else if (!sun4i_pwm->needs_delay[pwm->hwpwm]) {
|
} else {
|
||||||
ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm);
|
ctrl &= ~BIT_CH(PWM_EN, pwm->hwpwm);
|
||||||
ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
|
ctrl &= ~BIT_CH(PWM_CLK_GATING, pwm->hwpwm);
|
||||||
}
|
}
|
||||||
|
@ -310,15 +308,9 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
if (state->enabled)
|
if (state->enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!sun4i_pwm->needs_delay[pwm->hwpwm]) {
|
|
||||||
clk_disable_unprepare(sun4i_pwm->clk);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We need a full period to elapse before disabling the channel. */
|
/* We need a full period to elapse before disabling the channel. */
|
||||||
now = jiffies;
|
now = jiffies;
|
||||||
if (sun4i_pwm->needs_delay[pwm->hwpwm] &&
|
if (time_before(now, sun4i_pwm->next_period[pwm->hwpwm])) {
|
||||||
time_before(now, sun4i_pwm->next_period[pwm->hwpwm])) {
|
|
||||||
delay_us = jiffies_to_usecs(sun4i_pwm->next_period[pwm->hwpwm] -
|
delay_us = jiffies_to_usecs(sun4i_pwm->next_period[pwm->hwpwm] -
|
||||||
now);
|
now);
|
||||||
if ((delay_us / 500) > MAX_UDELAY_MS)
|
if ((delay_us / 500) > MAX_UDELAY_MS)
|
||||||
|
@ -326,7 +318,6 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
else
|
else
|
||||||
usleep_range(delay_us, delay_us * 2);
|
usleep_range(delay_us, delay_us * 2);
|
||||||
}
|
}
|
||||||
sun4i_pwm->needs_delay[pwm->hwpwm] = false;
|
|
||||||
|
|
||||||
spin_lock(&sun4i_pwm->ctrl_lock);
|
spin_lock(&sun4i_pwm->ctrl_lock);
|
||||||
ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG);
|
ctrl = sun4i_pwm_readl(sun4i_pwm, PWM_CTRL_REG);
|
||||||
|
|
Loading…
Reference in New Issue