public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
Cc: antoniu.miclaus@analog.com, lars@metafoo.de,
	Michael.Hennerich@analog.com, jic23@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad7625: fix type mismatch in clamp() macro
Date: Wed, 22 Apr 2026 19:21:33 +0300	[thread overview]
Message-ID: <aej1jTYHP0tgJOcD@ashevche-desk.local> (raw)
In-Reply-To: <aej1MTgpzToqxOXD@ashevche-desk.local>

On Wed, Apr 22, 2026 at 07:20:06PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 22, 2026 at 06:25:42PM +0400, Giorgi Tchankvetadze wrote:
> > Smatch reports a type mismatch warning in ad7625_set_sampling_freq()
> > where the clamp() macro is evaluating differing types:
> > - `target` is a u32
> > - `100` evaluates as a signed int
> > - `10 * KILO` evaluates as an unsigned long (due to KILO being 1000UL)
> 
> > Replace clamp() with clamp_t(u32, ...) to explicitly cast the bounds
> > to match the u32 target variable.
> 
> No. Try to avoid as much as possible use of _t variants of max(), clamp(),
> and min() (the list is sorted from the least critical to the most),
> 
> Also we have constant multipliers for frequency in units.h.

Reading again it seems like one from time.h actually fits better NSEC_PER_USEC.

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-04-22 16:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 14:25 [PATCH] iio: adc: ad7625: fix type mismatch in clamp() macro Giorgi Tchankvetadze
2026-04-22 16:20 ` Andy Shevchenko
2026-04-22 16:21   ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aej1jTYHP0tgJOcD@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=giorgitchankvetadze1997@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox