Skip to content

Commit 2771b71

Browse files
ukleineknunojsa
authored andcommitted
iio: adc: ad400x: Specify PWM parameters in nanoseconds
With ref_clk running with a rate not bigger than 1 GHz there is no gain in using picosecond units as two different PWM settings differ by at least one nanosecond. So there is no need to differ from upstream where the pwm subsystem uses nanoseconds to specify PWM parameters. With the goal to drop support for time_unit, don't explicitly set cnv_state.time_unit = PWM_UNIT_NSEC but rely on this being the default. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
1 parent 7fdbc5b commit 2771b71

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/iio/adc/ad400x.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,16 @@ static int ad400x_get_sampling_freq(struct ad400x_state *st)
204204

205205
static int __ad400x_set_sampling_freq(struct ad400x_state *st, int freq)
206206
{
207-
unsigned long long ref_clk_period_ps;
207+
unsigned long long ref_clk_period_ns;
208208
struct pwm_state cnv_state;
209209

210210
/* Sync up PWM state and prepare for pwm_apply_state(). */
211211
pwm_init_state(st->cnv_trigger, &cnv_state);
212212

213-
ref_clk_period_ps = DIV_ROUND_CLOSEST_ULL(1000000000000,
213+
ref_clk_period_ns = DIV_ROUND_CLOSEST_ULL(NSEC_PER_SEC,
214214
st->ref_clk_rate);
215-
cnv_state.period = DIV_ROUND_CLOSEST_ULL(1000000000000, freq);
216-
cnv_state.duty_cycle = ref_clk_period_ps;
217-
cnv_state.time_unit = PWM_UNIT_PSEC;
215+
cnv_state.period = DIV_ROUND_CLOSEST_ULL(NSEC_PER_SEC, freq);
216+
cnv_state.duty_cycle = ref_clk_period_ns;
218217
return pwm_apply_state(st->cnv_trigger, &cnv_state);
219218
}
220219

0 commit comments

Comments
 (0)