* [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset
@ 2026-12-03 13:39 Rickard Andersson
2026-12-03 13:39 ` [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset Rickard Andersson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Rickard Andersson @ 2026-12-03 13:39 UTC (permalink / raw)
To: hvilleneuve, jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel
Cc: rickard.andersson, kernel
From: Rickard x Andersson <rickard.andersson@axis.com>
The reset GPIO may be provided by a controller that can sleep, such
as an I2C GPIO expander. On some systems this triggers a
WARN_ON(can_sleep) stacktrace in gpiolib.
Use gpiod_set_value_cansleep instead. ads7924_reset is only called
from probe function, so sleeping is allowed.
Fixes: 4d82b2f98a25 ("iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver")
Signed-off-by: Rickard x Andersson <rickard.andersson@axis.com>
---
drivers/iio/adc/ti-ads7924.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c
index ff30a52d2850..b357f131018c 100644
--- a/drivers/iio/adc/ti-ads7924.c
+++ b/drivers/iio/adc/ti-ads7924.c
@@ -323,10 +323,10 @@ static int ads7924_reset(struct iio_dev *indio_dev)
struct ads7924_data *data = iio_priv(indio_dev);
if (data->reset_gpio) {
- gpiod_set_value(data->reset_gpio, 1); /* Assert. */
+ gpiod_set_value_cansleep(data->reset_gpio, 1); /* Assert. */
/* Educated guess: assert time not specified in datasheet... */
mdelay(100);
- gpiod_set_value(data->reset_gpio, 0); /* Deassert. */
+ gpiod_set_value_cansleep(data->reset_gpio, 0); /* Deassert. */
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset
2026-12-03 13:39 [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Rickard Andersson
@ 2026-12-03 13:39 ` Rickard Andersson
2026-12-03 14:40 ` Joshua Crofts
2026-12-03 13:39 ` [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse Rickard Andersson
2026-12-03 14:20 ` [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Rickard Andersson @ 2026-12-03 13:39 UTC (permalink / raw)
To: hvilleneuve, jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel
Cc: rickard.andersson, kernel
From: Rickard x Andersson <rickard.andersson@axis.com>
After the reset GPIO is deasserted, the driver immediately writes
MODECNTRL. On a board where the reset line is on an I2C GPIO
expander (TCA6424), this first write fails:
ads7924 2-0049: failed to set awake mode (-EIO)
ads7924 2-0049: error -EIO: failed to set conversion mode
The device responds normally on the bus some time later. The
datasheet does not specify a startup time after reset, so wait
10 ms before the first register access.
Fixes: 4d82b2f98a25 ("iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver")
Signed-off-by: Rickard x Andersson <rickard.andersson@axis.com>
---
drivers/iio/adc/ti-ads7924.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c
index b357f131018c..82700cb4e932 100644
--- a/drivers/iio/adc/ti-ads7924.c
+++ b/drivers/iio/adc/ti-ads7924.c
@@ -327,6 +327,11 @@ static int ads7924_reset(struct iio_dev *indio_dev)
/* Educated guess: assert time not specified in datasheet... */
mdelay(100);
gpiod_set_value_cansleep(data->reset_gpio, 0); /* Deassert. */
+ /*
+ * Startup time after reset is not specified in the datasheet.
+ * Need to wait before the first register access on some systems.
+ */
+ fsleep(10 * USEC_PER_MSEC);
return 0;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse
2026-12-03 13:39 [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Rickard Andersson
2026-12-03 13:39 ` [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset Rickard Andersson
@ 2026-12-03 13:39 ` Rickard Andersson
2026-12-03 14:22 ` Andy Shevchenko
2026-12-03 14:20 ` [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Rickard Andersson @ 2026-12-03 13:39 UTC (permalink / raw)
To: hvilleneuve, jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel
Cc: rickard.andersson, kernel
From: Rickard x Andersson <rickard.andersson@axis.com>
The reset pulse in ads7924_reset is generated with mdelay, which
busy-waits. ads7924_reset is only called from probe,
which runs in process context, so sleeping is allowed.
Replace mdelay with fsleep to make whole reset function
being able to sleep.
Signed-off-by: Rickard x Andersson <rickard.andersson@axis.com>
---
drivers/iio/adc/ti-ads7924.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c
index 82700cb4e932..8d23b15a384c 100644
--- a/drivers/iio/adc/ti-ads7924.c
+++ b/drivers/iio/adc/ti-ads7924.c
@@ -325,7 +325,7 @@ static int ads7924_reset(struct iio_dev *indio_dev)
if (data->reset_gpio) {
gpiod_set_value_cansleep(data->reset_gpio, 1); /* Assert. */
/* Educated guess: assert time not specified in datasheet... */
- mdelay(100);
+ fsleep(100 * USEC_PER_MSEC);
gpiod_set_value_cansleep(data->reset_gpio, 0); /* Deassert. */
/*
* Startup time after reset is not specified in the datasheet.
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset
2026-12-03 13:39 [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Rickard Andersson
2026-12-03 13:39 ` [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset Rickard Andersson
2026-12-03 13:39 ` [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse Rickard Andersson
@ 2026-12-03 14:20 ` Andy Shevchenko
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-12-03 14:20 UTC (permalink / raw)
To: Rickard Andersson
Cc: hvilleneuve, jic23, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, kernel
On Thu, Dec 03, 2026 at 02:39:20PM +0100, Rickard Andersson wrote:
>
> The reset GPIO may be provided by a controller that can sleep, such
> as an I2C GPIO expander. On some systems this triggers a
> WARN_ON(can_sleep) stacktrace in gpiolib.
>
> Use gpiod_set_value_cansleep instead. ads7924_reset is only called
> from probe function, so sleeping is allowed.
Can we switch to use reset-gpio driver and hence reset APIs here?
It would be a better fix in my opinion.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse
2026-12-03 13:39 ` [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse Rickard Andersson
@ 2026-12-03 14:22 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-12-03 14:22 UTC (permalink / raw)
To: Rickard Andersson
Cc: hvilleneuve, jic23, dlechner, nuno.sa, andy, linux-iio,
linux-kernel, kernel
On Thu, Dec 03, 2026 at 02:39:22PM +0100, Rickard Andersson wrote:
>
> The reset pulse in ads7924_reset is generated with mdelay, which
> busy-waits. ads7924_reset is only called from probe,
In all your commit messages please refer to the functions as func().
Exempli gratia, mdelay(), ads7924_reset().
> which runs in process context, so sleeping is allowed.
>
> Replace mdelay with fsleep to make whole reset function
> being able to sleep.
...
> if (data->reset_gpio) {
> gpiod_set_value_cansleep(data->reset_gpio, 1); /* Assert. */
> /* Educated guess: assert time not specified in datasheet... */
> - mdelay(100);
> + fsleep(100 * USEC_PER_MSEC);
> gpiod_set_value_cansleep(data->reset_gpio, 0); /* Deassert. */
When such a long delay (usually >= 20ms) in in place we use msleep() directly.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset
2026-12-03 13:39 ` [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset Rickard Andersson
@ 2026-12-03 14:40 ` Joshua Crofts
0 siblings, 0 replies; 6+ messages in thread
From: Joshua Crofts @ 2026-12-03 14:40 UTC (permalink / raw)
To: Rickard Andersson, hvilleneuve, jic23, dlechner, nuno.sa, andy,
linux-iio, linux-kernel
Cc: kernel
On 03-Dec-26 14:39, Rickard Andersson wrote:
> From: Rickard x Andersson <rickard.andersson@axis.com>
>
> After the reset GPIO is deasserted, the driver immediately writes
> MODECNTRL. On a board where the reset line is on an I2C GPIO
> expander (TCA6424), this first write fails:
>
> ads7924 2-0049: failed to set awake mode (-EIO)
> ads7924 2-0049: error -EIO: failed to set conversion mode
>
> The device responds normally on the bus some time later. The
> datasheet does not specify a startup time after reset, so wait
> 10 ms before the first register access.
>
> Fixes: 4d82b2f98a25 ("iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver")
> Signed-off-by: Rickard x Andersson <rickard.andersson@axis.com>
> ---
Makes sense.
Reviewed-by: Joshua Crofts <crofts@kernel.org>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 14:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 13:39 [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Rickard Andersson
2026-12-03 13:39 ` [PATCH 2/3] iio: adc: ti-ads7924: Wait after hardware reset Rickard Andersson
2026-12-03 14:40 ` Joshua Crofts
2026-12-03 13:39 ` [PATCH 3/3] iio: adc: ti-ads7924: Use fsleep for reset pulse Rickard Andersson
2026-12-03 14:22 ` Andy Shevchenko
2026-12-03 14:20 ` [PATCH 1/3] iio: adc: ti-ads7924: Allow sleepable GPIO for reset Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®