From: sashiko-bot@kernel.org
To: "Piyush Patle" <piyushpatle228@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v10 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read
Date: Mon, 25 May 2026 11:10:28 +0000 [thread overview]
Message-ID: <20260525111028.CAFA01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260525105127.180156-8-piyushpatle228@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver calls `gpiod_set_value()` inside a `local_irq_save()` block in `hx711_cycle()`. If the provided GPIO is on a sleeping bus (like an I2C or SPI expander), this will attempt to sleep with interrupts disabled, leading to a system panic or deadlock.
--
commit 06c110d4ea7407a2f984ef3a29933a8a8f62d351
Author: Piyush Patle <piyushpatle228@gmail.com>
Subject: iio: adc: hx711: pass trailing pulse count into hx711_read
This commit modifies hx711_read() to accept the number of trailing pulses
as a parameter. It moves the selection of trailing pulses from the read
function to its callers, preparing the driver for variant-specific code
without needing a separate read path.
> diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c
> index 062d6860da7d6..a18ac3ecf2c59 100644
> --- a/drivers/iio/adc/hx711.c
> +++ b/drivers/iio/adc/hx711.c
> @@ -155,7 +155,7 @@ static int hx711_cycle(struct hx711_data *hx711_data)
> return gpiod_get_value(hx711_data->gpiod_dout);
> }
>
> -static int hx711_read(struct hx711_data *hx711_data)
> +static int hx711_read(struct hx711_data *hx711_data, int trailing_pulses)
> {
[ ... ]
> - for (i = 0; i < hx711_get_gain_to_pulse(hx711_data->gain_set); i++)
> + for (i = 0; i < trailing_pulses; i++)
> hx711_cycle(hx711_data);
[Severity: High]
This is a pre-existing issue, but does this driver ensure the requested
GPIOs are not on a sleeping bus?
Looking at hx711_cycle(), the driver disables interrupts via
local_irq_save() to meet strict timing constraints, and then calls
gpiod_set_value() inside that atomic block:
hx711_cycle()
local_irq_save(flags);
gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
If a user wires the HX711 to a GPIO controller on a sleeping bus (like
an I2C or SPI expander), calling gpiod_set_value() will trigger the
underlying controller's set operation, which might attempt to acquire a
mutex or wait for I/O completion.
Could this attempt to sleep inside an atomic context and trigger a
"scheduling while atomic" panic or deadlock?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260525105127.180156-1-piyushpatle228@gmail.com?part=7
next prev parent reply other threads:[~2026-05-25 11:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 10:51 [PATCH v10 00/11] iio: adc: Add support for AVIA HX710B ADC Piyush Patle
2026-05-25 10:51 ` [PATCH v10 01/11] dt-bindings: iio: adc: hx711: clean up existing binding text Piyush Patle
2026-05-25 10:51 ` [PATCH v10 02/11] dt-bindings: iio: adc: hx711: add VSUP supply property Piyush Patle
2026-05-25 10:58 ` sashiko-bot
2026-05-27 17:34 ` Jonathan Cameron
2026-05-25 10:51 ` [PATCH v10 03/11] dt-bindings: iio: adc: hx711: add RATE GPIO property Piyush Patle
2026-05-25 10:51 ` [PATCH v10 04/11] dt-bindings: iio: adc: hx711: add HX710B support Piyush Patle
2026-05-25 11:11 ` sashiko-bot
2026-05-25 17:01 ` Conor Dooley
2026-05-27 17:41 ` Jonathan Cameron
2026-05-28 8:54 ` Conor Dooley
2026-05-28 13:08 ` Jonathan Cameron
2026-05-28 14:09 ` Conor Dooley
2026-05-27 17:37 ` Jonathan Cameron
2026-05-25 10:51 ` [PATCH v10 05/11] iio: adc: hx711: move scale computation to per-device storage Piyush Patle
2026-05-25 10:51 ` [PATCH v10 06/11] iio: adc: hx711: introduce hx711_chip_info structure Piyush Patle
2026-05-25 11:34 ` sashiko-bot
2026-05-25 10:51 ` [PATCH v10 07/11] iio: adc: hx711: pass trailing pulse count into hx711_read Piyush Patle
2026-05-25 11:10 ` sashiko-bot [this message]
2026-05-25 10:51 ` [PATCH v10 08/11] iio: adc: hx711: split variable assignments in hx711_read and hx711_reset Piyush Patle
2026-05-25 10:51 ` [PATCH v10 09/11] iio: adc: hx711: localize loop iterators in hx711_read Piyush Patle
2026-05-25 10:51 ` [PATCH v10 10/11] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read Piyush Patle
2026-05-25 11:25 ` sashiko-bot
2026-05-25 10:51 ` [PATCH v10 11/11] iio: adc: hx711: add support for HX710B Piyush Patle
2026-05-25 11:33 ` sashiko-bot
2026-05-27 17:54 ` Jonathan Cameron
2026-05-27 17:32 ` [PATCH v10 00/11] iio: adc: Add support for AVIA HX710B ADC Jonathan Cameron
2026-05-27 17:45 ` Jonathan Cameron
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=20260525111028.CAFA01F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.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