Skip to content

Commit c09f950

Browse files
Giorgi Tchankvetadzejic23
authored andcommitted
iio: adc: ad7625: fix type mismatch in clamp() macro
clamp() expects compatible operand types. The period calculation uses nanosecond constants, while the local target variable was narrower than the upper bound expression. Make target unsigned long and use unsigned long bounds, including NSEC_PER_USEC for the upper limit. This keeps the operands naturally aligned without adding casts. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 74c3923 commit c09f950

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/iio/adc/ad7625.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ enum ad7960_mode {
175175

176176
static int ad7625_set_sampling_freq(struct ad7625_state *st, u32 freq)
177177
{
178-
u32 target;
179178
struct pwm_waveform clk_gate_wf = { }, cnv_wf = { };
179+
unsigned long target;
180180
int ret;
181181

182182
target = DIV_ROUND_UP(NSEC_PER_SEC, freq);
183-
cnv_wf.period_length_ns = clamp(target, 100, 10 * KILO);
183+
cnv_wf.period_length_ns = clamp(target, 100UL, 10UL * NSEC_PER_USEC);
184184

185185
/*
186186
* Use the maximum conversion time t_CNVH from the datasheet as

0 commit comments

Comments
 (0)