diff mbox series

[10/16] iio: ad7606: Fix type incompatibility with non-macro find_closest

Message ID 20250515081332.151250-11-asoponar@taladin.ro
State New
Headers show
Series lib: Refactor find_closest() and find_closest_descending() from macros to lib functions | expand

Commit Message

Alexandru Soponar May 15, 2025, 8:13 a.m. UTC
The ad7606_oversampling_avail and ad7616_oversampling_avail arrays were
previously declared as unsigned int but used with find_closest(). With
find_closest() now implemented as a function taking signed int parameters
instead of a macro, passing unsigned arrays causes type incompatibility
errors. This patch changes the arrays type from unsigned int to int to
ensure compatibility with the function signature and prevent compilation
errors.

Signed-off-by: Alexandru Soponar <asoponar@taladin.ro>
---
 drivers/iio/adc/ad7606.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jonathan Cameron May 15, 2025, 5:13 p.m. UTC | #1
On Thu, 15 May 2025 11:13:26 +0300
Alexandru Soponar <asoponar@taladin.ro> wrote:

> The ad7606_oversampling_avail and ad7616_oversampling_avail arrays were
> previously declared as unsigned int but used with find_closest(). With
> find_closest() now implemented as a function taking signed int parameters
> instead of a macro, passing unsigned arrays causes type incompatibility
> errors. This patch changes the arrays type from unsigned int to int to
> ensure compatibility with the function signature and prevent compilation
> errors.
> 
> Signed-off-by: Alexandru Soponar <asoponar@taladin.ro>
Assuming overall approach is fine, this change is fine wrt to ranges
etc.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ad7606.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index d8e3c7a43678..41b477ea386d 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -81,11 +81,11 @@ static const unsigned int ad7609_hw_scale_avail[2][2] = {
>  	{ 0, 152588 }, { 0, 305176 }
>  };
>  
> -static const unsigned int ad7606_oversampling_avail[7] = {
> +static const int ad7606_oversampling_avail[7] = {
>  	1, 2, 4, 8, 16, 32, 64,
>  };
>  
> -static const unsigned int ad7616_oversampling_avail[8] = {
> +static const int ad7616_oversampling_avail[8] = {
>  	1, 2, 4, 8, 16, 32, 64, 128,
>  };
>  
> @@ -835,7 +835,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>  			    long mask)
>  {
>  	struct ad7606_state *st = iio_priv(indio_dev);
> -	unsigned int scale_avail_uv[AD760X_MAX_SCALES];
> +	int scale_avail_uv[AD760X_MAX_SCALES];
>  	struct ad7606_chan_scale *cs;
>  	int i, ret, ch = 0;
>  
> @@ -884,7 +884,7 @@ static ssize_t ad7606_oversampling_ratio_avail(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct ad7606_state *st = iio_priv(indio_dev);
> -	const unsigned int *vals = st->oversampling_avail;
> +	const int *vals = st->oversampling_avail;
>  	unsigned int i;
>  	size_t len = 0;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index d8e3c7a43678..41b477ea386d 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -81,11 +81,11 @@  static const unsigned int ad7609_hw_scale_avail[2][2] = {
 	{ 0, 152588 }, { 0, 305176 }
 };
 
-static const unsigned int ad7606_oversampling_avail[7] = {
+static const int ad7606_oversampling_avail[7] = {
 	1, 2, 4, 8, 16, 32, 64,
 };
 
-static const unsigned int ad7616_oversampling_avail[8] = {
+static const int ad7616_oversampling_avail[8] = {
 	1, 2, 4, 8, 16, 32, 64, 128,
 };
 
@@ -835,7 +835,7 @@  static int ad7606_write_raw(struct iio_dev *indio_dev,
 			    long mask)
 {
 	struct ad7606_state *st = iio_priv(indio_dev);
-	unsigned int scale_avail_uv[AD760X_MAX_SCALES];
+	int scale_avail_uv[AD760X_MAX_SCALES];
 	struct ad7606_chan_scale *cs;
 	int i, ret, ch = 0;
 
@@ -884,7 +884,7 @@  static ssize_t ad7606_oversampling_ratio_avail(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct ad7606_state *st = iio_priv(indio_dev);
-	const unsigned int *vals = st->oversampling_avail;
+	const int *vals = st->oversampling_avail;
 	unsigned int i;
 	size_t len = 0;