Skip to content

Commit cb601b0

Browse files
committed
pwm-pio: Remove resolution-restriction on duty cycle
1 parent ea23f08 commit cb601b0

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/pwm/pwm-pio-rp1.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,8 @@ static int pwm_pio_rp1_apply(struct pwm_chip *chip, struct pwm_device *pwm,
101101
uint32_t new_duty_cycle;
102102
uint32_t new_period;
103103

104-
if (state->duty_cycle && state->duty_cycle < pwm_pio_resolution)
105-
return -EINVAL;
106-
107-
if (state->duty_cycle != state->period &&
108-
(state->period - state->duty_cycle < pwm_pio_resolution))
109-
return -EINVAL;
110-
111-
new_period = state->period / pwm_pio_resolution;
112-
new_duty_cycle = state->duty_cycle / pwm_pio_resolution;
104+
new_period = DIV_ROUND_CLOSEST(state->period, pwm_pio_resolution);
105+
new_duty_cycle = DIV_ROUND_CLOSEST(state->duty_cycle, pwm_pio_resolution);
113106

114107
mutex_lock(&ppwm->mutex);
115108

0 commit comments

Comments
 (0)