From: sashiko-bot@kernel.org
To: "Piyush Patle" <piyushpatle228@gmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
krzk+dt@kernel.org
Subject: Re: [PATCH v8 v8 11/11] iio: adc: hx711: add support for HX710B
Date: Wed, 13 May 2026 01:13:11 +0000 [thread overview]
Message-ID: <20260513011312.412FAC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511174342.123820-12-piyushpatle228@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect scale returned for the HX710B supply monitor channel (channel 2).
--
commit 7c73b66947438720fd9e5f95112049924938a086
Author: Piyush Patle <piyushpatle228@gmail.com>
iio: adc: hx711: add support for HX710B
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, and track the active channel
across conversions.
> diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
> index 8ec4dee1f451e..49c14489d5ec4 100644
> --- a/drivers/iio/adc/hx711.c
> +++ b/drivers/iio/adc/hx711.c
> @@ -463,6 +502,10 @@ static const struct iio_info hx711_iio_info = {
> .attrs = &hx711_attribute_group,
> };
>
> +static const struct iio_info hx710b_iio_info = {
> + .read_raw = hx711_read_raw,
> +};
> +
[ ... ]
> @@ -495,6 +538,68 @@ static const struct iio_chan_spec hx711_chan_spec[] = {
> IIO_CHAN_SOFT_TIMESTAMP(2),
> };
>
> +/*
> + * 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
> + * .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,
> + .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,
> + },
> + },
Could this regression result in an incorrect scale being returned for the
HX710B supply monitor channel?
The driver defines BIT(IIO_CHAN_INFO_SCALE) in info_mask_separate for the
HX710B channels, advertising a separate scale per channel.
However, looking at hx711_read_raw(), when mask == IIO_CHAN_INFO_SCALE the
chan parameter is ignored and the scale is unconditionally returned using
hx711_data->gain_set:
case IIO_CHAN_INFO_SCALE:
*val = 0;
mutex_lock(&hx711_data->lock);
*val2 = hx711_get_gain_to_scale(hx711_data->gain_scale,
hx711_data->gain_set);
For the HX710B, hx711_data->gain_set is fixed at 128.
Because channel 2 is a DVDD-AVDD supply monitor, it typically bypasses the
PGA and has an effective gain of 1 rather than 128.
Returning the scale for a gain of 128 causes userspace to calculate a voltage
that is 128 times too small.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511174342.123820-1-piyushpatle228@gmail.com?part=11
prev parent reply other threads:[~2026-05-13 1:13 UTC|newest]
Thread overview: 24+ 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-12 22:34 ` sashiko-bot
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-12 23:30 ` sashiko-bot
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
2026-05-13 1:13 ` sashiko-bot [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=20260513011312.412FAC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=piyushpatle228@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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