Commit 97aee715 authored by Herve Codina's avatar Herve Codina Committed by Mark Brown

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: default avatarHerve Codina <herve.codina@bootlin.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-9-herve.codina@bootlin.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c952c748
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <linux/err.h> #include <linux/err.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/minmax.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -875,11 +876,7 @@ static int iio_channel_read_max(struct iio_channel *chan, ...@@ -875,11 +876,7 @@ static int iio_channel_read_max(struct iio_channel *chan,
return -EINVAL; return -EINVAL;
switch (*type) { switch (*type) {
case IIO_VAL_INT: case IIO_VAL_INT:
*val = vals[--length]; *val = max_array(vals, length);
while (length) {
if (vals[--length] > *val)
*val = vals[length];
}
break; break;
default: default:
/* FIXME: learn about max for other iio values */ /* FIXME: learn about max for other iio values */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment