diff options
author | Herve Codina <herve.codina@bootlin.com> | 2023-06-23 11:58:25 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-07-10 00:48:15 +0300 |
commit | 97aee7157eeadaf628e7f76da5e49cee91f19901 (patch) | |
tree | 6e97cf1209e05a099989623b483987226a6a44e5 | |
parent | c952c748c7a983a8bda9112984e6f2c1f6e441a5 (diff) | |
download | linux-97aee7157eeadaf628e7f76da5e49cee91f19901.tar.xz |
iio: inkern: Use max_array() to get the maximum value from an array
Use max_array() to get the maximum value from an array instead of a
custom local loop.
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-9-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/iio/inkern.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 71d0424383b6..8bfd91f74101 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -5,6 +5,7 @@ */ #include <linux/err.h> #include <linux/export.h> +#include <linux/minmax.h> #include <linux/mutex.h> #include <linux/property.h> #include <linux/slab.h> @@ -875,11 +876,7 @@ static int iio_channel_read_max(struct iio_channel *chan, return -EINVAL; switch (*type) { case IIO_VAL_INT: - *val = vals[--length]; - while (length) { - if (vals[--length] > *val) - *val = vals[length]; - } + *val = max_array(vals, length); break; default: /* FIXME: learn about max for other iio values */ |