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

From: Jonathan Cameron

Date: Mon Apr 27 2026 - 05:55:19 EST


On Mon, 27 Apr 2026 10:31:28 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> 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;
>

Done and applied. Thanks.

J