|
@@ -41,9 +41,9 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|
|
/* The highest acceptable divisor is 256, which is represented by 0 */
|
|
|
period_cycles = div64_u64(c * period_ns,
|
|
|
(unsigned long long)NSEC_PER_SEC * 256);
|
|
|
- if (!period_cycles)
|
|
|
- period_cycles = 1;
|
|
|
- if (period_cycles > 255)
|
|
|
+ if (!period_cycles || period_cycles > 256)
|
|
|
+ return -ERANGE;
|
|
|
+ if (period_cycles == 256)
|
|
|
period_cycles = 0;
|
|
|
|
|
|
/* Compute 256 x #duty/period value and care for corner cases */
|