Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Piyush Patle <piyushpatle228@gmail.com>
Cc: ak@it-klinger.de, andriy.shevchenko@linux.intel.com,
	dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 v8 11/11] iio: adc: hx711: add support for HX710B
Date: Tue, 12 May 2026 13:38:06 +0100	[thread overview]
Message-ID: <20260512133806.74c566e0@jic23-huawei> (raw)
In-Reply-To: <20260511174342.123820-12-piyushpatle228@gmail.com>

On Mon, 11 May 2026 23:13:36 +0530
Piyush Patle <piyushpatle228@gmail.com> wrote:

> Add support for the AVIA HX710B ADC, which shares the HX711 GPIO
> interface but uses trailing PD_SCK pulses to select the active mode.
> 
> Model the HX710B with variant-specific channel tables and IIO info,
> track the active channel across conversions, and use the fixed gain
> value when computing scale.
> 
> Also update the adjacent Kconfig text, file header, and module
> description so the driver text matches the newly supported variant.
> 
> Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Hi Piyush,

A few things I'd missed that Sashiko mentioned.
Note that most of what it calls out in v7 of this patch is wrong because
of the whole active_scan_mask / timestamp bit being set or not thing.

The channel representation is indeed odd and I think that bit needs
a rethink unfortunately.  I'd failed to notice it wasn't just two different
channels but instead is one physical set of inputs measured at different
sampling rates.


> @@ -403,16 +442,16 @@ static irqreturn_t hx711_trigger(int irq, void *p)
>  
>  	mutex_lock(&hx711_data->lock);
>  
> -	memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer));
> +	memset(hx711_data->buffer, 0, sizeof(hx711_data->buffer));
>  
>  	iio_for_each_active_channel(indio_dev, i) {
> -		hx711_data->buffer.channel[j] =
> +		hx711_data->buffer[j] =
>  			hx711_reset_read(hx711_data, &indio_dev->channels[i]);

Sashiko pointed out (v7 review) that this can return an error. We should
really be checking for negative values and if they occur don't push data
to the buffer.  Given this is unlikely to happen except when the device
is very broken, a rate limited dev_err is usual way to report this then
carry on without calling iio_push_to_buffers_with_timestamp().

>  		j++;
>  	}
>  
> -	iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
> -							pf->timestamp);
> +	iio_push_to_buffers_with_timestamp(indio_dev, hx711_data->buffer,
> +					   pf->timestamp);
>  
>  	mutex_unlock(&hx711_data->lock);
>  
> @@ -463,6 +502,10 @@ static const struct iio_info hx711_iio_info = {
>  	.attrs			= &hx711_attribute_group,
>  };

> +/*
> + * HX710B channels (Table 3 in datasheet).
> + * 25 pulses (1 trailing): differential input, 10 SPS -> channel 0
> + * 26 pulses (2 trailing): DVDD-AVDD supply monitor, 40 SPS -> channel 2
> + * 27 pulses (3 trailing): differential input, 40 SPS -> channel 3

I'd missed this previously but sashiko raised a question on it.
Why are we representing the same physical input channel as two different IIO channels
based only on the sampling rate?  That doesn't seem to make a lot of sense.
Should be one channel with a sampling_frequency control.


> + * .address stores the trailing pulse count for hx711_set_hx710b_channel().
> + * Channel 2 is used for the supply monitor to avoid aliasing the
> + * channel2 terminal of the first differential pair.
> + */
> +static const struct iio_chan_spec hx710b_chan_spec[] = {
> +	{
> +		.type = IIO_VOLTAGE,
> +		.differential = 1,
> +		.channel = 0,
> +		.channel2 = 1,
> +		.indexed = 1,
> +		.address = 1,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = 0,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 24,
> +			.storagebits = 32,
> +			.endianness = IIO_CPU,
> +		},
> +	},
> +	{
> +		.type = IIO_VOLTAGE,
> +		.channel = 2,
> +		.indexed = 1,
> +		.address = 2,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = 1,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 24,
> +			.storagebits = 32,
> +			.endianness = IIO_CPU,
> +		},
> +	},
> +	{
> +		.type = IIO_VOLTAGE,
> +		.differential = 1,
> +		.channel = 3,
> +		.channel2 = 4,
> +		.indexed = 1,
> +		.address = 3,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = 2,
> +		.scan_type = {
> +			.sign = 'u',
> +			.realbits = 24,
> +			.storagebits = 32,
> +			.endianness = IIO_CPU,
> +		},
> +	},
> +	IIO_CHAN_SOFT_TIMESTAMP(3),
> +};


      reply	other threads:[~2026-05-12 12:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 17:43 [PATCH v8 00/11] iio: adc: hx711: add HX710B support Piyush Patle
2026-05-11 17:43 ` [PATCH v8 v8 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Piyush Patle
2026-05-12 12:05   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Piyush Patle
2026-05-12 12:06   ` Jonathan Cameron
2026-05-12 12:08     ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Piyush Patle
2026-05-12 12:08   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 04/11] dt-bindings: iio: adc: hx711: add HX710B support Piyush Patle
2026-05-12 12:13   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 05/11] iio: adc: hx711: move scale computation to per-device storage Piyush Patle
2026-05-12 12:14   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 06/11] iio: adc: hx711: introduce hx711_chip_info structure Piyush Patle
2026-05-12 12:19   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Piyush Patle
2026-05-11 17:43 ` [PATCH v8 v8 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Piyush Patle
2026-05-11 17:43 ` [PATCH v8 v8 09/11] iio: adc: hx711: localize loop iterators in hx711_read Piyush Patle
2026-05-11 17:43 ` [PATCH v8 v8 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Piyush Patle
2026-05-12 12:21   ` Jonathan Cameron
2026-05-11 17:43 ` [PATCH v8 v8 11/11] iio: adc: hx711: add support for HX710B Piyush Patle
2026-05-12 12:38   ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260512133806.74c566e0@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=piyushpatle228@gmail.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox