mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-24 15:02:54 -04:00
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>
This commit is contained in:
committed by
Jonathan Cameron
parent
74c3923344
commit
c09f950fd8
@@ -175,12 +175,12 @@ enum ad7960_mode {
|
||||
|
||||
static int ad7625_set_sampling_freq(struct ad7625_state *st, u32 freq)
|
||||
{
|
||||
u32 target;
|
||||
struct pwm_waveform clk_gate_wf = { }, cnv_wf = { };
|
||||
unsigned long target;
|
||||
int ret;
|
||||
|
||||
target = DIV_ROUND_UP(NSEC_PER_SEC, freq);
|
||||
cnv_wf.period_length_ns = clamp(target, 100, 10 * KILO);
|
||||
cnv_wf.period_length_ns = clamp(target, 100UL, 10UL * NSEC_PER_USEC);
|
||||
|
||||
/*
|
||||
* Use the maximum conversion time t_CNVH from the datasheet as
|
||||
|
||||
Reference in New Issue
Block a user