Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2] iio: ccs811: Deassert WAKE GPIO on error paths
@ 2026-10-15 12:30 Nikhil Gautam
  2026-10-15 12:50 ` Joshua Crofts
  0 siblings, 1 reply; 2+ messages in thread
From: Nikhil Gautam @ 2026-10-15 12:30 UTC (permalink / raw)
  To: linux-iio
  Cc: linux-kernel, jic23, dlechner, nuno.sa, andy, Nikhil Gautam,
	Joshua Crofts

Ensure the WAKE GPIO is deasserted when status polling fails or
the data-ready timeout expires. Early returns could leave WAKE asserted,
preventing the sensor from returning to its low-power state and
potentially disrupting subsequent I2C transactions.

Route error paths through a common cleanup label to ensure WAKE is
deasserted before returning.

Fixes: c6644f7201f3 ("iio: chemical: Add support for external Reset and Wakeup in CCS811")
Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/iio/chemical/ccs811.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c
index 998c9239c4c7..dad54f66ebb3 100644
--- a/drivers/iio/chemical/ccs811.c
+++ b/drivers/iio/chemical/ccs811.c
@@ -198,18 +198,21 @@ static int ccs811_get_measurement(struct ccs811_data *data)
 	while (tries-- > 0) {
 		ret = i2c_smbus_read_byte_data(data->client, CCS811_STATUS);
 		if (ret < 0)
-			return ret;
+			goto out;
 
 		if ((ret & CCS811_STATUS_DATA_READY) || tries == 0)
 			break;
 		msleep(100);
 	}
-	if (!(ret & CCS811_STATUS_DATA_READY))
-		return -EIO;
+	if (!(ret & CCS811_STATUS_DATA_READY)) {
+		ret = -EIO;
+		goto out;
+	}
 
 	ret = i2c_smbus_read_i2c_block_data(data->client,
 					    CCS811_ALG_RESULT_DATA, 8,
 					    (char *)&data->buffer);
+out:
 	ccs811_set_wakeup(data, false);
 
 	return ret;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] iio: ccs811: Deassert WAKE GPIO on error paths
  2026-10-15 12:30 [PATCH v2] iio: ccs811: Deassert WAKE GPIO on error paths Nikhil Gautam
@ 2026-10-15 12:50 ` Joshua Crofts
  0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-10-15 12:50 UTC (permalink / raw)
  To: Nikhil Gautam; +Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy

On Thu, 15 Oct 2026 18:00:23 +0530
Nikhil Gautam <nikhilgtr@gmail.com> wrote:

> Ensure the WAKE GPIO is deasserted when status polling fails or
> the data-ready timeout expires. Early returns could leave WAKE asserted,
> preventing the sensor from returning to its low-power state and
> potentially disrupting subsequent I2C transactions.
> 
> Route error paths through a common cleanup label to ensure WAKE is
> deasserted before returning.
> 
> Fixes: c6644f7201f3 ("iio: chemical: Add support for external Reset and Wakeup in CCS811")
> Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>

Ideally your signed-off-by should be last in the tag block.
No need to resend though.

> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---

You were too fast! Wait at least 24 hours before submitting a new
patch, you might get more reviews.

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-15 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 12:30 [PATCH v2] iio: ccs811: Deassert WAKE GPIO on error paths Nikhil Gautam
2026-10-15 12:50 ` Joshua Crofts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox