diff mbox series

[2/5] iio: adc: ad4030: remove some duplicate code

Message ID 20250310-iio-adc-ad4030-check-scan-type-err-v1-2-589e4ebd9711@baylibre.com (mailing list archive)
State New
Headers show
Series iio: adc: ad4030: scan_type cleanups | expand

Commit Message

David Lechner March 10, 2025, 8:43 p.m. UTC
Remove some duplicate code in the ad4030_get_chan_scale() function by
simplifying the if statement.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/adc/ad4030.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Nuno Sá March 11, 2025, 9:27 a.m. UTC | #1
On Mon, 2025-03-10 at 15:43 -0500, David Lechner wrote:
> Remove some duplicate code in the ad4030_get_chan_scale() function by
> simplifying the if statement.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/iio/adc/ad4030.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
> index
> af7a817e8273496e8856a5ba1a9c2e66a11f0a84..f24b46164a477f9b6b5c93ffeba0a335f7b3
> de5a 100644
> --- a/drivers/iio/adc/ad4030.c
> +++ b/drivers/iio/adc/ad4030.c
> @@ -394,14 +394,13 @@ static int ad4030_get_chan_scale(struct iio_dev
> *indio_dev,
>  	if (IS_ERR(scan_type))
>  		return PTR_ERR(scan_type);
>  
> -	if (chan->differential) {
> +	if (chan->differential)
>  		*val = (st->vref_uv * 2) / MILLI;
> -		*val2 = scan_type->realbits;
> -		return IIO_VAL_FRACTIONAL_LOG2;
> -	}
> +	else
> +		*val = st->vref_uv / MILLI;
>  
> -	*val = st->vref_uv / MILLI;
>  	*val2 = scan_type->realbits;
> +
>  	return IIO_VAL_FRACTIONAL_LOG2;
>  }
>  
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
index af7a817e8273496e8856a5ba1a9c2e66a11f0a84..f24b46164a477f9b6b5c93ffeba0a335f7b3de5a 100644
--- a/drivers/iio/adc/ad4030.c
+++ b/drivers/iio/adc/ad4030.c
@@ -394,14 +394,13 @@  static int ad4030_get_chan_scale(struct iio_dev *indio_dev,
 	if (IS_ERR(scan_type))
 		return PTR_ERR(scan_type);
 
-	if (chan->differential) {
+	if (chan->differential)
 		*val = (st->vref_uv * 2) / MILLI;
-		*val2 = scan_type->realbits;
-		return IIO_VAL_FRACTIONAL_LOG2;
-	}
+	else
+		*val = st->vref_uv / MILLI;
 
-	*val = st->vref_uv / MILLI;
 	*val2 = scan_type->realbits;
+
 	return IIO_VAL_FRACTIONAL_LOG2;
 }