Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7124: use clamp()

Use clamp() instead of open-coding clamping.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
faf7f9e7 08a9e5f8

+2 -5
+2 -5
drivers/iio/adc/ad7124.c
··· 15 15 #include <linux/interrupt.h> 16 16 #include <linux/kernel.h> 17 17 #include <linux/kfifo.h> 18 + #include <linux/minmax.h> 18 19 #include <linux/module.h> 19 20 #include <linux/mod_devicetable.h> 20 21 #include <linux/property.h> ··· 300 299 * FS[10:0] can have a value from 1 to 2047 301 300 */ 302 301 factor = 32 * 4; /* N = 4 for default sinc4 filter. */ 303 - odr_sel_bits = DIV_ROUND_CLOSEST(fclk, odr * factor); 304 - if (odr_sel_bits < 1) 305 - odr_sel_bits = 1; 306 - else if (odr_sel_bits > 2047) 307 - odr_sel_bits = 2047; 302 + odr_sel_bits = clamp(DIV_ROUND_CLOSEST(fclk, odr * factor), 1, 2047); 308 303 309 304 if (odr_sel_bits != st->channels[channel].cfg.odr_sel_bits) 310 305 st->channels[channel].cfg.live = false;