diff options
| author | Herve Codina <[email protected]> | 2023-06-23 10:58:25 +0200 |
|---|---|---|
| committer | Mark Brown <[email protected]> | 2023-07-09 22:48:15 +0100 |
| commit | 97aee7157eeadaf628e7f76da5e49cee91f19901 (patch) | |
| tree | 6e97cf1209e05a099989623b483987226a6a44e5 | |
| parent | c952c748c7a983a8bda9112984e6f2c1f6e441a5 (diff) | |
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 <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Acked-by: Jonathan Cameron <[email protected]>
Reviewed-by: Christophe Leroy <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
| -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 */ |