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

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.

Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
---
 drivers/iio/chemical/ccs811.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c
index 998c9239c4c7..94c83937d1d7 100644
--- a/drivers/iio/chemical/ccs811.c
+++ b/drivers/iio/chemical/ccs811.c
@@ -198,20 +198,22 @@ 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] 3+ messages in thread

* Re: [PATCH] iio: ccs811: Deassert WAKE GPIO on error paths
  2026-10-14 15:22 [PATCH] iio: ccs811: Deassert WAKE GPIO on error paths Nikhil Gautam
@ 2026-10-15  9:11 ` Joshua Crofts
  2026-10-15 12:06   ` Nikhil Gautam
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Crofts @ 2026-10-15  9:11 UTC (permalink / raw)
  To: Nikhil Gautam; +Cc: linux-iio, linux-kernel, jic23, dlechner, nuno.sa, andy

On Wed, 14 Oct 2026 20:52:50 +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.
> 
> Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>

Please add a Fixes tag.

...

>  	ret = i2c_smbus_read_i2c_block_data(data->client,
>  					    CCS811_ALG_RESULT_DATA, 8,
>  					    (char *)&data->buffer);
> +out:
>  	ccs811_set_wakeup(data, false);
> -

Keep the blank line.

>  	return ret;
>  }
>  


Otherwise,

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

-- 
Kind regards,
Joshua Crofts

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

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


Hi Joshua,

Thanks for the review.

> Please add a Fixes tag.
>
> ...
Sure, will add Fixes tag in next version
>>   	ret = i2c_smbus_read_i2c_block_data(data->client,
>>   					    CCS811_ALG_RESULT_DATA, 8,
>>   					    (char *)&data->buffer);
>> +out:
>>   	ccs811_set_wakeup(data, false);
>> -
> Keep the blank line.
Noted.
> Otherwise,
>
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Regards,
Nikhil

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

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

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

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