Re: [PATCH v2] iio: adc: ad7625: fix type mismatch in clamp() macro

From: Andy Shevchenko

Date: Mon Apr 27 2026 - 03:34:45 EST


On Sat, Apr 25, 2026 at 11:16:16AM +0400, Giorgi Tchankvetadze wrote:
> 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.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

...

> - u32 target;
> + unsigned long target;
> struct pwm_waveform clk_gate_wf = { }, cnv_wf = { };
> int ret;

Preferred to keep the reversed xmas tree order (no need to resend, hopefully
Jonathan tweaks this whilst applying).

struct pwm_waveform clk_gate_wf = { }, cnv_wf = { };
unsigned long target;
int ret;

--
With Best Regards,
Andy Shevchenko