Re: [PATCH v2 1/5] iio: chemical: sgp40: Do not convert I2C errors to EIO
From: Joshua Crofts
Date: Mon Nov 02 2026 - 04:59:32 EST
On Mon, 2 Nov 2026 11:12:54 +0200
Jaakko Koivisto <jmatko@xxxxxx> wrote:
> Any negative error returned by i2c_master_send() in
> sgp40_measure_resistance_raw() was caught by the
> branch guarding against short sends, and the error
> was subsequently replaced with -EIO.
Please wrap the commit message to ~75 characters per line next
time. Otherwise LGTM.
Reviewed-by: Joshua Crofts <crofts@xxxxxxxxxx>
> Check for any negative errors first and propagate
> the error without conversion.
>
> Fixes: 1081b9d97152 ("iio: chemical: Add driver support for sgp40")
>
Also, no blank lines in the tag block.
> Signed-off-by: Jaakko Koivisto <jmatko@xxxxxx>
> ---
> Tested by forcing i2c clock to ground. The resulting ETIMEDOUT and
> EREMOTEIO are now correctly communicated to userspace instead of
> converting to EIO.
>
> drivers/iio/chemical/sgp40.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iio/chemical/sgp40.c b/drivers/iio/chemical/sgp40.c
> index b2b5e32a9eb2..3a239fb6847f 100644
> --- a/drivers/iio/chemical/sgp40.c
> +++ b/drivers/iio/chemical/sgp40.c
> @@ -187,6 +187,8 @@ static int sgp40_measure_resistance_raw(struct sgp40_data *data, u16 *resistance
> mutex_unlock(&data->lock);
>
> ret = i2c_master_send(client, (const char *)&tg, sizeof(tg));
> + if (ret < 0)
> + return ret;
> if (ret != sizeof(tg)) {
> dev_warn(data->dev, "i2c_master_send ret: %d sizeof: %zu\n", ret, sizeof(tg));
> return -EIO;
--
Kind regards,
Joshua Crofts