diff mbox series

[5/5] iio: adc: ad4030: explain rearranging raw sample data

Message ID 20250310-iio-adc-ad4030-check-scan-type-err-v1-5-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
Add a comment explaining why the raw sample data is rearranged in the
in the ad4030_conversion() function. It is not so obvious from the code
why this is done.

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

Comments

Nuno Sá March 11, 2025, 9:30 a.m. UTC | #1
On Mon, 2025-03-10 at 15:43 -0500, David Lechner wrote:
> Add a comment explaining why the raw sample data is rearranged in the
> in the ad4030_conversion() function. It is not so obvious from the code
> why this is done.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---

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

(BTW, for some reason I started to send the tags without first checking the
complete series. So I could have just replied to the cover :facepalm:

- Nuno Sá

>  drivers/iio/adc/ad4030.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
> index
> 54ad74b96c9f256a67848330f875379edc828b0b..636f9f33e66af73d102722b984dc1230e141
> 7d1e 100644
> --- a/drivers/iio/adc/ad4030.c
> +++ b/drivers/iio/adc/ad4030.c
> @@ -646,6 +646,12 @@ static int ad4030_conversion(struct iio_dev *indio_dev)
>  					   &st->rx_data.dual.diff[0],
>  					   &st->rx_data.dual.diff[1]);
>  
> +	/*
> +	 * If no common mode voltage channel is enabled, we can use the raw
> +	 * data as is. Otherwise, we need to rearrange the data a bit to
> match
> +	 * the natural alignment of the IIO buffer.
> +	 */
> +
>  	if (st->mode != AD4030_OUT_DATA_MD_16_DIFF_8_COM &&
>  	    st->mode != AD4030_OUT_DATA_MD_24_DIFF_8_COM)
>  		return 0;
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
index 54ad74b96c9f256a67848330f875379edc828b0b..636f9f33e66af73d102722b984dc1230e1417d1e 100644
--- a/drivers/iio/adc/ad4030.c
+++ b/drivers/iio/adc/ad4030.c
@@ -646,6 +646,12 @@  static int ad4030_conversion(struct iio_dev *indio_dev)
 					   &st->rx_data.dual.diff[0],
 					   &st->rx_data.dual.diff[1]);
 
+	/*
+	 * If no common mode voltage channel is enabled, we can use the raw
+	 * data as is. Otherwise, we need to rearrange the data a bit to match
+	 * the natural alignment of the IIO buffer.
+	 */
+
 	if (st->mode != AD4030_OUT_DATA_MD_16_DIFF_8_COM &&
 	    st->mode != AD4030_OUT_DATA_MD_24_DIFF_8_COM)
 		return 0;