diff options
| author | David Lechner <dlechner@baylibre.com> | 2025-09-11 16:42:00 -0500 |
|---|---|---|
| committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2025-09-13 14:37:59 +0100 |
| commit | faf7f9e72a57481448f5047bb3c7a951e9683952 (patch) | |
| tree | b10e37a6991489c2efb06c76b155eef32a6c7cbc | |
| parent | 08a9e5f8bb1e2233d19fb0c12f454e2d625532f5 (diff) | |
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>
| -rw-r--r-- | drivers/iio/adc/ad7124.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 6f4629c4a2f0..8213f625bb3e 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -15,6 +15,7 @@ #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/kfifo.h> +#include <linux/minmax.h> #include <linux/module.h> #include <linux/mod_devicetable.h> #include <linux/property.h> @@ -299,11 +300,7 @@ static void ad7124_set_channel_odr(struct ad7124_state *st, unsigned int channel * FS[10:0] can have a value from 1 to 2047 */ factor = 32 * 4; /* N = 4 for default sinc4 filter. */ - odr_sel_bits = DIV_ROUND_CLOSEST(fclk, odr * factor); - if (odr_sel_bits < 1) - odr_sel_bits = 1; - else if (odr_sel_bits > 2047) - odr_sel_bits = 2047; + odr_sel_bits = clamp(DIV_ROUND_CLOSEST(fclk, odr * factor), 1, 2047); if (odr_sel_bits != st->channels[channel].cfg.odr_sel_bits) st->channels[channel].cfg.live = false; |
