Skip to content

Commit 3efa3f2

Browse files
ukleineknunojsa
authored andcommitted
iio: adc: ltc2387: Fix for PWM driver rounding down duty cycle
The normal behaviour for PWM drivers in upstream is to round down the duty cycle value (FTR: also period and duty offset). The pwm-axipwmgen driver implements that behaviour since commit ea33133 ("pwm: Replace axi-pwmgen driver by a backport of the mainline driver"). That means that if .duty_cycle = DIV_ROUND_CLOSEST(NSEC_PER_SEC, ltc->ref_clk_rate) is requested and that division happens to round down, the duty cycle programmed will be zero and don't toggle at all. So use up-rounding for the duty_cycle value. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
1 parent cd94eae commit 3efa3f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/adc/ltc2387.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int ltc2387_set_sampling_freq(struct ltc2387_dev *ltc, int freq)
158158
int ret, clk_en_time;
159159
u32 rem;
160160

161-
ref_clk_period_ns = DIV_ROUND_CLOSEST(NSEC_PER_SEC, ltc->ref_clk_rate);
161+
ref_clk_period_ns = DIV_ROUND_UP(NSEC_PER_SEC, ltc->ref_clk_rate);
162162

163163
cnv_state = (struct pwm_state) {
164164
.duty_cycle = ref_clk_period_ns,

0 commit comments

Comments
 (0)