From: Antoniu Miclaus Date: Thu, 29 Jan 2026 18:14:52 +0000 (+0200) Subject: iio: pressure: hsc030pa: Improve i2c_transfer return value handling X-Git-Tag: v7.1-rc1~17^2~120^2~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f4e466aac34013904d81acfacf1f2453068578a2;p=thirdparty%2Flinux.git iio: pressure: hsc030pa: Improve i2c_transfer return value handling The i2c_transfer() function returns the number of messages successfully transferred. The function sends 1 message but checks for ret == 2, which can never be true. In practice this has no impact since the caller checks ret < 0, and the erroneous return value of 1 is not treated as an error. Improve the return value handling to properly distinguish between I2C errors and unexpected transfer counts. Signed-off-by: Antoniu Miclaus Tested-by: Petre Rodan Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/pressure/hsc030pa_i2c.c b/drivers/iio/pressure/hsc030pa_i2c.c index a34ef4653f342..3500bda03d750 100644 --- a/drivers/iio/pressure/hsc030pa_i2c.c +++ b/drivers/iio/pressure/hsc030pa_i2c.c @@ -34,8 +34,13 @@ static int hsc_i2c_recv(struct hsc_data *data) msg.buf = data->buffer; ret = i2c_transfer(client->adapter, &msg, 1); + if (ret < 0) + return ret; - return (ret == 2) ? 0 : ret; + if (ret != 1) + return -EIO; + + return 0; } static int hsc_i2c_probe(struct i2c_client *client)