@@ -90,7 +90,6 @@ struct sun4i_pwm_chip {
90
90
spinlock_t ctrl_lock ;
91
91
const struct sun4i_pwm_data * data ;
92
92
unsigned long next_period [2 ];
93
- bool needs_delay [2 ];
94
93
};
95
94
96
95
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,
287
286
sun4i_pwm_writel (sun4i_pwm , val , PWM_CH_PRD (pwm -> hwpwm ));
288
287
sun4i_pwm -> next_period [pwm -> hwpwm ] = jiffies +
289
288
usecs_to_jiffies (cstate .period / 1000 + 1 );
290
- sun4i_pwm -> needs_delay [pwm -> hwpwm ] = true;
291
289
292
290
if (state -> polarity != PWM_POLARITY_NORMAL )
293
291
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,
298
296
299
297
if (state -> enabled ) {
300
298
ctrl |= BIT_CH (PWM_EN , pwm -> hwpwm );
301
- } else if (! sun4i_pwm -> needs_delay [ pwm -> hwpwm ]) {
299
+ } else {
302
300
ctrl &= ~BIT_CH (PWM_EN , pwm -> hwpwm );
303
301
ctrl &= ~BIT_CH (PWM_CLK_GATING , pwm -> hwpwm );
304
302
}
@@ -310,23 +308,16 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
310
308
if (state -> enabled )
311
309
return 0 ;
312
310
313
- if (!sun4i_pwm -> needs_delay [pwm -> hwpwm ]) {
314
- clk_disable_unprepare (sun4i_pwm -> clk );
315
- return 0 ;
316
- }
317
-
318
311
/* We need a full period to elapse before disabling the channel. */
319
312
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 ])) {
322
314
delay_us = jiffies_to_usecs (sun4i_pwm -> next_period [pwm -> hwpwm ] -
323
315
now );
324
316
if ((delay_us / 500 ) > MAX_UDELAY_MS )
325
317
msleep (delay_us / 1000 + 1 );
326
318
else
327
319
usleep_range (delay_us , delay_us * 2 );
328
320
}
329
- sun4i_pwm -> needs_delay [pwm -> hwpwm ] = false;
330
321
331
322
spin_lock (& sun4i_pwm -> ctrl_lock );
332
323
ctrl = sun4i_pwm_readl (sun4i_pwm , PWM_CTRL_REG );
0 commit comments