Linux IIO development
 help / color / mirror / Atom feed
* [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers
@ 2026-07-16  0:57 Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 01/22] iio: adc: ltc2471: Remove redundant i2c_master_recv() length check Jonathan Cameron
                   ` (23 more replies)
  0 siblings, 24 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

Resend to include linux-iio. Sorry to all who get it twice.

This came up in a recent review and I realised I have been giving incorrect
review feedback for years. Both i2_master_send() and i2c_master_recv() plus
the dma safe variants only ever return either an error or the full buffer
size.  Short accesses do not occur.

This series (also my first upstream series prepared by poking claude)
removes the redundant checks from all IIO drivers.

Thanks,

Jonathan

Jonathan Cameron (22):
  iio: adc: ltc2471: Remove redundant i2c_master_recv() length check
  iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks
  iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}()
    length checks
  iio: chemical: scd30: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: chemical: scd4x: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: chemical: sgp30: Remove redundant i2c_master_recv() length check
  iio: chemical: sgp40: Remove redundant i2c_master_recv() length check
  iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: dac: ad5446: Remove redundant i2c_master_send() length check
  iio: dac: ad5696: Remove redundant i2c_master_send() length check
  iio: dac: m62332: Remove redundant i2c_master_send() length check
  iio: dac: max517: Remove redundant i2c_master_send() length check
  iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: dac: mcp4725: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: dac: mcp4728: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: light: lv0104cs: Remove redundant i2c_master_{send,recv}() length
    checks
  iio: potentiometer: ad5110: Remove redundant i2c_master_{send,recv}()
    length checks
  iio: pressure: abp2030pa: Remove redundant i2c_master_{send,recv}()
    length checks
  iio: pressure: adp810: Remove redundant i2c_master_{send,recv}()
    length checks
  iio: pressure: icp10100: Remove redundant i2c_master_send() length
    check
  iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}()
    length checks
  iio: pressure: sdp500: Remove redundant i2c_master_recv() length check

 drivers/iio/adc/ltc2471.c              |  2 --
 drivers/iio/adc/ti-ads7138.c           |  4 ----
 drivers/iio/adc/versal-sysmon-i2c.c    |  6 ------
 drivers/iio/chemical/scd30_i2c.c       |  4 ----
 drivers/iio/chemical/scd4x.c           |  8 --------
 drivers/iio/chemical/sgp30.c           |  2 --
 drivers/iio/chemical/sgp40.c           |  4 ----
 drivers/iio/chemical/sps30_i2c.c       |  4 ----
 drivers/iio/dac/ad5446-i2c.c           |  2 --
 drivers/iio/dac/ad5696-i2c.c           |  2 +-
 drivers/iio/dac/m62332.c               |  2 --
 drivers/iio/dac/max517.c               |  6 ++----
 drivers/iio/dac/max5821.c              | 14 ++------------
 drivers/iio/dac/mcp4725.c              | 22 ++++++----------------
 drivers/iio/dac/mcp4728.c              | 13 +------------
 drivers/iio/light/lv0104cs.c           |  4 ----
 drivers/iio/potentiometer/ad5110.c     | 18 +++---------------
 drivers/iio/pressure/abp2030pa_i2c.c   |  4 ----
 drivers/iio/pressure/adp810.c          |  4 ----
 drivers/iio/pressure/icp10100.c        |  2 --
 drivers/iio/pressure/mprls0025pa_i2c.c |  4 ----
 drivers/iio/pressure/sdp500.c          |  4 ----
 22 files changed, 15 insertions(+), 120 deletions(-)

-- 
2.43.0


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

* [PATCH 01/22] iio: adc: ltc2471: Remove redundant i2c_master_recv() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 02/22] iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks Jonathan Cameron
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_recv() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/adc/ltc2471.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c
index 369af700969f..0223824782de 100644
--- a/drivers/iio/adc/ltc2471.c
+++ b/drivers/iio/adc/ltc2471.c
@@ -35,8 +35,6 @@ static int ltc2471_get_value(struct i2c_client *client)
 	ret = i2c_master_recv(client, (char *)&buf, sizeof(buf));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(buf))
-		return -EIO;
 
 	/* MSB first */
 	return be16_to_cpu(buf);
-- 
2.43.0


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

* [PATCH 02/22] iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 01/22] iio: adc: ltc2471: Remove redundant i2c_master_recv() length check Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 03/22] iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}() " Jonathan Cameron
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() returns either a negative errno or exactly the count
passed in, so a length check after the 'ret < 0' test can never be true.
Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/adc/ti-ads7138.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/adc/ti-ads7138.c b/drivers/iio/adc/ti-ads7138.c
index af87f5f19a0f..afb20accc170 100644
--- a/drivers/iio/adc/ti-ads7138.c
+++ b/drivers/iio/adc/ti-ads7138.c
@@ -116,8 +116,6 @@ static int ads7138_i2c_write_block(const struct i2c_client *client, u8 reg,
 	ret = i2c_master_send(client, buf, len);
 	if (ret < 0)
 		return ret;
-	if (ret != len)
-		return -EIO;
 
 	return 0;
 }
@@ -131,8 +129,6 @@ static int ads7138_i2c_write_with_opcode(const struct i2c_client *client,
 	ret = i2c_master_send(client, buf, ARRAY_SIZE(buf));
 	if (ret < 0)
 		return ret;
-	if (ret != ARRAY_SIZE(buf))
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 03/22] iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 01/22] iio: adc: ltc2471: Remove redundant i2c_master_recv() length check Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 02/22] iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 04/22] iio: chemical: scd30: " Jonathan Cameron
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/adc/versal-sysmon-i2c.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/iio/adc/versal-sysmon-i2c.c b/drivers/iio/adc/versal-sysmon-i2c.c
index e9a7629159ab..afdcc4e93771 100644
--- a/drivers/iio/adc/versal-sysmon-i2c.c
+++ b/drivers/iio/adc/versal-sysmon-i2c.c
@@ -44,14 +44,10 @@ static int sysmon_i2c_reg_read(void *context, unsigned int reg,
 	ret = i2c_master_send(client, write_buf, sizeof(write_buf));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(write_buf))
-		return -EIO;
 
 	ret = i2c_master_recv(client, read_buf, sizeof(read_buf));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(read_buf))
-		return -EIO;
 
 	*val = get_unaligned_le32(read_buf);
 
@@ -72,8 +68,6 @@ static int sysmon_i2c_reg_write(void *context, unsigned int reg,
 	ret = i2c_master_send(client, write_buf, sizeof(write_buf));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(write_buf))
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 04/22] iio: chemical: scd30: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (2 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 03/22] iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}() " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 05/22] iio: chemical: scd4x: " Jonathan Cameron
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/chemical/scd30_i2c.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/chemical/scd30_i2c.c b/drivers/iio/chemical/scd30_i2c.c
index bcef1e473e34..78acc965b0f7 100644
--- a/drivers/iio/chemical/scd30_i2c.c
+++ b/drivers/iio/chemical/scd30_i2c.c
@@ -47,8 +47,6 @@ static int scd30_i2c_xfer(struct scd30_state *state, char *txbuf, int txsize,
 	ret = i2c_master_send(client, txbuf, txsize);
 	if (ret < 0)
 		return ret;
-	if (ret != txsize)
-		return -EIO;
 
 	if (!rxbuf)
 		return 0;
@@ -56,8 +54,6 @@ static int scd30_i2c_xfer(struct scd30_state *state, char *txbuf, int txsize,
 	ret = i2c_master_recv(client, rxbuf, rxsize);
 	if (ret < 0)
 		return ret;
-	if (ret != rxsize)
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 05/22] iio: chemical: scd4x: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (3 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 04/22] iio: chemical: scd30: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 06/22] iio: chemical: sgp30: Remove redundant i2c_master_recv() length check Jonathan Cameron
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/chemical/scd4x.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
index 23a326fb62a7..b52072a4eb65 100644
--- a/drivers/iio/chemical/scd4x.c
+++ b/drivers/iio/chemical/scd4x.c
@@ -82,8 +82,6 @@ static int scd4x_i2c_xfer(struct scd4x_state *state, char *txbuf, int txsize,
 
 	if (ret < 0)
 		return ret;
-	if (ret != txsize)
-		return -EIO;
 
 	if (rxsize == 0)
 		return 0;
@@ -91,8 +89,6 @@ static int scd4x_i2c_xfer(struct scd4x_state *state, char *txbuf, int txsize,
 	ret = i2c_master_recv(client, rxbuf, rxsize);
 	if (ret < 0)
 		return ret;
-	if (ret != rxsize)
-		return -EIO;
 
 	return 0;
 }
@@ -241,10 +237,6 @@ static int scd4x_write_and_fetch(struct scd4x_state *state, enum scd4x_cmd cmd,
 	ret = i2c_master_recv(client, buf, response_sz);
 	if (ret < 0)
 		goto err;
-	if (ret != response_sz) {
-		ret = -EIO;
-		goto err;
-	}
 
 	for (i = 0; i < response_sz; i += 3) {
 		crc = crc8(scd4x_crc8_table, buf + i, 2, CRC8_INIT_VALUE);
-- 
2.43.0


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

* [PATCH 06/22] iio: chemical: sgp30: Remove redundant i2c_master_recv() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (4 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 05/22] iio: chemical: scd4x: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 07/22] iio: chemical: sgp40: " Jonathan Cameron
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_recv() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/chemical/sgp30.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c
index f10bbebc29e4..8152606c6495 100644
--- a/drivers/iio/chemical/sgp30.c
+++ b/drivers/iio/chemical/sgp30.c
@@ -254,8 +254,6 @@ static int sgp_read_cmd(struct sgp_data *data, enum sgp_cmd cmd,
 	ret = i2c_master_recv(client, data_buf, size);
 	if (ret < 0)
 		return ret;
-	if (ret != size)
-		return -EIO;
 
 	return sgp_verify_buffer(data, buf, word_count);
 }
-- 
2.43.0


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

* [PATCH 07/22] iio: chemical: sgp40: Remove redundant i2c_master_recv() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (5 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 06/22] iio: chemical: sgp30: Remove redundant i2c_master_recv() length check Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 08/22] iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_recv() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/chemical/sgp40.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/chemical/sgp40.c b/drivers/iio/chemical/sgp40.c
index b2b5e32a9eb2..090469e620fd 100644
--- a/drivers/iio/chemical/sgp40.c
+++ b/drivers/iio/chemical/sgp40.c
@@ -196,10 +196,6 @@ static int sgp40_measure_resistance_raw(struct sgp40_data *data, u16 *resistance
 	ret = i2c_master_recv(client, (u8 *)&tgres, sizeof(tgres));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(tgres)) {
-		dev_warn(data->dev, "i2c_master_recv ret: %d sizeof: %zu\n", ret, sizeof(tgres));
-		return -EIO;
-	}
 
 	crc = crc8(sgp40_crc8_table, (u8 *)&tgres.res_ticks, 2, SGP40_CRC8_INIT);
 	if (crc != tgres.res_crc) {
-- 
2.43.0


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

* [PATCH 08/22] iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (6 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 07/22] iio: chemical: sgp40: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 09/22] iio: dac: ad5446: Remove redundant i2c_master_send() length check Jonathan Cameron
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/chemical/sps30_i2c.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/chemical/sps30_i2c.c b/drivers/iio/chemical/sps30_i2c.c
index 2d3a876cc06e..284b10ef63e9 100644
--- a/drivers/iio/chemical/sps30_i2c.c
+++ b/drivers/iio/chemical/sps30_i2c.c
@@ -46,8 +46,6 @@ static int sps30_i2c_xfer(struct sps30_state *state, unsigned char *txbuf, size_
 	ret = i2c_master_send(client, txbuf, txsize);
 	if (ret < 0)
 		return ret;
-	if (ret != txsize)
-		return -EIO;
 
 	if (!rxsize)
 		return 0;
@@ -55,8 +53,6 @@ static int sps30_i2c_xfer(struct sps30_state *state, unsigned char *txbuf, size_
 	ret = i2c_master_recv(client, rxbuf, rxsize);
 	if (ret < 0)
 		return ret;
-	if (ret != rxsize)
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 09/22] iio: dac: ad5446: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (7 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 08/22] iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 10/22] iio: dac: ad5696: " Jonathan Cameron
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send_dmasafe() returns either a negative errno or exactly
the count passed in, so the length check after the 'ret < 0' test can
never be true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/ad5446-i2c.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/dac/ad5446-i2c.c b/drivers/iio/dac/ad5446-i2c.c
index 9797fc3e57a9..0a01445f7a82 100644
--- a/drivers/iio/dac/ad5446-i2c.c
+++ b/drivers/iio/dac/ad5446-i2c.c
@@ -22,8 +22,6 @@ static int ad5622_write(struct ad5446_state *st, unsigned int val)
 	ret = i2c_master_send_dmasafe(client, (char *)&st->d16, sizeof(st->d16));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(st->d16))
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 10/22] iio: dac: ad5696: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (8 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 09/22] iio: dac: ad5446: Remove redundant i2c_master_send() length check Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 11/22] iio: dac: m62332: " Jonathan Cameron
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/ad5696-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index d49946adbde3..95b4956f9376 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -58,7 +58,7 @@ static int ad5686_i2c_write(struct ad5686_state *st,
 	if (ret < 0)
 		return ret;
 
-	return (ret != 3) ? -EIO : 0;
+	return 0;
 }
 
 static const struct ad5686_bus_ops ad5686_i2c_ops = {
-- 
2.43.0


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

* [PATCH 11/22] iio: dac: m62332: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (9 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 10/22] iio: dac: ad5696: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 12/22] iio: dac: max517: " Jonathan Cameron
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() returns either a negative errno or exactly the count
passed in, so the 'res >= 0 && res != ARRAY_SIZE(outbuf)' condition can
never be true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/m62332.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index 7e80c0eb5cc1..a945533a596e 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -50,8 +50,6 @@ static int m62332_set_value(struct iio_dev *indio_dev, u8 val, int channel)
 	}
 
 	res = i2c_master_send(client, outbuf, ARRAY_SIZE(outbuf));
-	if (res >= 0 && res != ARRAY_SIZE(outbuf))
-		res = -EIO;
 	if (res < 0)
 		goto out;
 
-- 
2.43.0


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

* [PATCH 12/22] iio: dac: max517: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (10 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 11/22] iio: dac: m62332: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  7:45   ` Joshua Crofts
  2026-07-16  0:57 ` [PATCH 13/22] iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
                   ` (11 subsequent siblings)
  23 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/max517.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index d2ddc72e0e50..e0d1a26c4f73 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -55,10 +55,8 @@ static int max517_set_value(struct iio_dev *indio_dev,
 	res = i2c_master_send(client, outbuf, 2);
 	if (res < 0)
 		return res;
-	else if (res != 2)
-		return -EIO;
-	else
-		return 0;
+
+	return 0;
 }
 
 static int max517_read_raw(struct iio_dev *indio_dev,
-- 
2.43.0


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

* [PATCH 13/22] iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (11 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 12/22] iio: dac: max517: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 14/22] iio: dac: mcp4725: " Jonathan Cameron
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/max5821.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c
index 45def245626b..fadc37eec999 100644
--- a/drivers/iio/dac/max5821.c
+++ b/drivers/iio/dac/max5821.c
@@ -103,8 +103,6 @@ static int max5821_sync_powerdown_mode(struct max5821_data *data,
 	ret = i2c_master_send(data->client, outbuf, sizeof(outbuf));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(outbuf))
-		return -EIO;
 
 	return 0;
 }
@@ -188,18 +186,12 @@ static int max5821_get_value(struct iio_dev *indio_dev,
 	if (ret < 0) {
 		mutex_unlock(&data->lock);
 		return ret;
-	} else if (ret != 1) {
-		mutex_unlock(&data->lock);
-		return -EIO;
 	}
 
 	ret = i2c_master_recv(client, inbuf, 2);
 	if (ret < 0) {
 		mutex_unlock(&data->lock);
 		return ret;
-	} else if (ret != 2) {
-		mutex_unlock(&data->lock);
-		return -EIO;
 	}
 
 	mutex_unlock(&data->lock);
@@ -230,10 +222,8 @@ static int max5821_set_value(struct iio_dev *indio_dev,
 	ret = i2c_master_send(client, outbuf, 2);
 	if (ret < 0)
 		return ret;
-	else if (ret != 2)
-		return -EIO;
-	else
-		return 0;
+
+	return 0;
 }
 
 static int max5821_read_raw(struct iio_dev *indio_dev,
-- 
2.43.0


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

* [PATCH 14/22] iio: dac: mcp4725: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (12 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 13/22] iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 15/22] iio: dac: mcp4728: " Jonathan Cameron
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/mcp4725.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index 3fa7acc69aeb..92c1f0ca369c 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -58,8 +58,7 @@ static int mcp4725_suspend(struct device *dev)
 	ret = i2c_master_send(data->client, outbuf, 2);
 	if (ret < 0)
 		return ret;
-	else if (ret != 2)
-		return -EIO;
+
 	return 0;
 }
 
@@ -78,8 +77,7 @@ static int mcp4725_resume(struct device *dev)
 	ret = i2c_master_send(data->client, outbuf, 2);
 	if (ret < 0)
 		return ret;
-	else if (ret != 2)
-		return -EIO;
+
 	return 0;
 }
 static DEFINE_SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend,
@@ -111,8 +109,6 @@ static ssize_t mcp4725_store_eeprom(struct device *dev,
 	ret = i2c_master_send(data->client, inoutbuf, 3);
 	if (ret < 0)
 		return ret;
-	else if (ret != 3)
-		return -EIO;
 
 	/* wait for write complete, takes up to 50ms */
 	while (tries--) {
@@ -120,8 +116,6 @@ static ssize_t mcp4725_store_eeprom(struct device *dev,
 		ret = i2c_master_recv(data->client, inoutbuf, 3);
 		if (ret < 0)
 			return ret;
-		else if (ret != 3)
-			return -EIO;
 
 		if (inoutbuf[0] & 0x80)
 			break;
@@ -291,10 +285,8 @@ static int mcp4725_set_value(struct iio_dev *indio_dev, int val)
 	ret = i2c_master_send(data->client, outbuf, 2);
 	if (ret < 0)
 		return ret;
-	else if (ret != 2)
-		return -EIO;
-	else
-		return 0;
+
+	return 0;
 }
 
 static int mcp4726_set_cfg(struct iio_dev *indio_dev)
@@ -313,10 +305,8 @@ static int mcp4726_set_cfg(struct iio_dev *indio_dev)
 	ret = i2c_master_send(data->client, outbuf, 3);
 	if (ret < 0)
 		return ret;
-	else if (ret != 3)
-		return -EIO;
-	else
-		return 0;
+
+	return 0;
 }
 
 static int mcp4725_read_raw(struct iio_dev *indio_dev,
-- 
2.43.0


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

* [PATCH 15/22] iio: dac: mcp4728: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (13 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 14/22] iio: dac: mcp4725: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 16/22] iio: light: lv0104cs: " Jonathan Cameron
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/dac/mcp4728.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/iio/dac/mcp4728.c b/drivers/iio/dac/mcp4728.c
index 1fe184d49fc5..c238bc572014 100644
--- a/drivers/iio/dac/mcp4728.c
+++ b/drivers/iio/dac/mcp4728.c
@@ -147,8 +147,6 @@ static ssize_t mcp4728_store_eeprom(struct device *dev,
 	ret = i2c_master_send(data->client, outbuf, MCP4728_WRITE_EEPROM_LEN);
 	if (ret < 0)
 		return ret;
-	else if (ret != MCP4728_WRITE_EEPROM_LEN)
-		return -EIO;
 
 	/* wait RDY signal for write complete, takes up to 50ms */
 	while (tries--) {
@@ -156,8 +154,6 @@ static ssize_t mcp4728_store_eeprom(struct device *dev,
 		ret = i2c_master_recv(data->client, inbuf, 3);
 		if (ret < 0)
 			return ret;
-		else if (ret != 3)
-			return -EIO;
 
 		if (FIELD_GET(MCP4728_RDY_MASK, inbuf[0]))
 			break;
@@ -205,8 +201,6 @@ static int mcp4728_program_channel_cfg(int channel, struct iio_dev *indio_dev)
 	ret = i2c_master_send(data->client, outbuf, 3);
 	if (ret < 0)
 		return ret;
-	else if (ret != 3)
-		return -EIO;
 
 	return 0;
 }
@@ -498,14 +492,9 @@ static int mcp4728_init_channels_data(struct mcp4728_data *data)
 	unsigned int i;
 
 	ret = i2c_master_recv(data->client, inbuf, MCP4728_READ_RESPONSE_LEN);
-	if (ret < 0) {
+	if (ret < 0)
 		return dev_err_probe(&data->client->dev, ret,
 				     "failed to read mcp4728 conf.\n");
-	} else if (ret != MCP4728_READ_RESPONSE_LEN) {
-		return dev_err_probe(&data->client->dev, -EIO,
-			"failed to read mcp4728 conf. Wrong Response Len ret=%d\n",
-			ret);
-	}
 
 	for (i = 0; i < MCP4728_N_CHANNELS; i++) {
 		struct mcp4728_channel_data *ch = &data->chdata[i];
-- 
2.43.0


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

* [PATCH 16/22] iio: light: lv0104cs: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (14 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 15/22] iio: dac: mcp4728: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 17/22] iio: potentiometer: ad5110: " Jonathan Cameron
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/light/lv0104cs.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/light/lv0104cs.c b/drivers/iio/light/lv0104cs.c
index eba82c334d70..41526c4886d7 100644
--- a/drivers/iio/light/lv0104cs.c
+++ b/drivers/iio/light/lv0104cs.c
@@ -135,8 +135,6 @@ static int lv0104cs_write_reg(struct i2c_client *client, u8 regval)
 	ret = i2c_master_send(client, (char *)&regval, sizeof(regval));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(regval))
-		return -EIO;
 
 	return 0;
 }
@@ -149,8 +147,6 @@ static int lv0104cs_read_adc(struct i2c_client *client, u16 *adc_output)
 	ret = i2c_master_recv(client, (char *)&regval, sizeof(regval));
 	if (ret < 0)
 		return ret;
-	if (ret != sizeof(regval))
-		return -EIO;
 
 	*adc_output = be16_to_cpu(regval);
 
-- 
2.43.0


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

* [PATCH 17/22] iio: potentiometer: ad5110: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (15 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 16/22] iio: light: lv0104cs: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 18/22] iio: pressure: abp2030pa: " Jonathan Cameron
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send_dmasafe() and i2c_master_recv_dmasafe() return either a
negative errno or exactly the count passed in, so a length check after
the 'ret < 0' test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/potentiometer/ad5110.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/potentiometer/ad5110.c b/drivers/iio/potentiometer/ad5110.c
index aaf02cc7aeba..0885f972ccea 100644
--- a/drivers/iio/potentiometer/ad5110.c
+++ b/drivers/iio/potentiometer/ad5110.c
@@ -87,20 +87,12 @@ static int ad5110_read(struct ad5110_data *data, u8 cmd, int *val)
 	data->buf[1] = *val;
 
 	ret = i2c_master_send_dmasafe(data->client, data->buf, sizeof(data->buf));
-	if (ret < 0) {
+	if (ret < 0)
 		goto error;
-	} else if (ret != sizeof(data->buf)) {
-		ret = -EIO;
-		goto error;
-	}
 
 	ret = i2c_master_recv_dmasafe(data->client, data->buf, 1);
-	if (ret < 0) {
-		goto error;
-	} else if (ret != 1) {
-		ret = -EIO;
+	if (ret < 0)
 		goto error;
-	}
 
 	*val = data->buf[0];
 	ret = 0;
@@ -119,12 +111,8 @@ static int ad5110_write(struct ad5110_data *data, u8 cmd, u8 val)
 	data->buf[1] = val;
 
 	ret = i2c_master_send_dmasafe(data->client, data->buf, sizeof(data->buf));
-	if (ret < 0) {
-		goto error;
-	} else if (ret != sizeof(data->buf)) {
-		ret = -EIO;
+	if (ret < 0)
 		goto error;
-	}
 
 	ret = 0;
 
-- 
2.43.0


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

* [PATCH 18/22] iio: pressure: abp2030pa: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (16 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 17/22] iio: potentiometer: ad5110: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 19/22] iio: pressure: adp810: " Jonathan Cameron
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/pressure/abp2030pa_i2c.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/pressure/abp2030pa_i2c.c b/drivers/iio/pressure/abp2030pa_i2c.c
index fa4d290cfd3e..bb9c0a1a5888 100644
--- a/drivers/iio/pressure/abp2030pa_i2c.c
+++ b/drivers/iio/pressure/abp2030pa_i2c.c
@@ -24,8 +24,6 @@ static int abp2_i2c_read(struct abp2_data *data, u8 unused, u8 nbytes)
 	ret = i2c_master_recv(client, data->rx_buf, nbytes);
 	if (ret < 0)
 		return ret;
-	if (ret != nbytes)
-		return -EIO;
 
 	return 0;
 }
@@ -42,8 +40,6 @@ static int abp2_i2c_write(struct abp2_data *data, u8 cmd, u8 nbytes)
 	ret = i2c_master_send(client, data->tx_buf, nbytes);
 	if (ret < 0)
 		return ret;
-	if (ret != nbytes)
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 19/22] iio: pressure: adp810: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (17 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 18/22] iio: pressure: abp2030pa: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 20/22] iio: pressure: icp10100: Remove redundant i2c_master_send() length check Jonathan Cameron
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/pressure/adp810.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/pressure/adp810.c b/drivers/iio/pressure/adp810.c
index 82aa433548d2..6c740a9383e5 100644
--- a/drivers/iio/pressure/adp810.c
+++ b/drivers/iio/pressure/adp810.c
@@ -64,8 +64,6 @@ static int adp810_measure(struct adp810_data *data, struct adp810_read_buf *buf)
 		dev_err(dev, "Error sending trigger command\n");
 		return ret;
 	}
-	if (ret != sizeof(trig_cmd))
-		return -EIO;
 
 	/*
 	 * Wait for the sensor to acquire data. As per datasheet section 5.3.1,
@@ -81,8 +79,6 @@ static int adp810_measure(struct adp810_data *data, struct adp810_read_buf *buf)
 		dev_err(dev, "Error reading from sensor\n");
 		return ret;
 	}
-	if (ret != sizeof(*buf))
-		return -EIO;
 
 	/* CRC checks */
 	crc8_populate_msb(crc_table, ADP810_CRC8_POLYNOMIAL);
-- 
2.43.0


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

* [PATCH 20/22] iio: pressure: icp10100: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (18 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 19/22] iio: pressure: adp810: " Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 21/22] iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/pressure/icp10100.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c
index 82824e3e8db9..783d306bd959 100644
--- a/drivers/iio/pressure/icp10100.c
+++ b/drivers/iio/pressure/icp10100.c
@@ -201,8 +201,6 @@ static int icp10100_read_cal_otp(struct icp10100_state *st)
 			      ARRAY_SIZE(icp10100_switch_mode_otp));
 	if (ret < 0)
 		return ret;
-	if (ret != ARRAY_SIZE(icp10100_switch_mode_otp))
-		return -EIO;
 
 	/* read 4 calibration values */
 	for (i = 0; i < 4; ++i) {
-- 
2.43.0


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

* [PATCH 21/22] iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}() length checks
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (19 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 20/22] iio: pressure: icp10100: Remove redundant i2c_master_send() length check Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  0:57 ` [PATCH 22/22] iio: pressure: sdp500: Remove redundant i2c_master_recv() length check Jonathan Cameron
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_send() and i2c_master_recv() return either a negative errno
or exactly the count passed in, so a length check after the 'ret < 0'
test can never be true. Drop the dead branches.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/pressure/mprls0025pa_i2c.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/pressure/mprls0025pa_i2c.c b/drivers/iio/pressure/mprls0025pa_i2c.c
index 06907b64a596..061d9156b3db 100644
--- a/drivers/iio/pressure/mprls0025pa_i2c.c
+++ b/drivers/iio/pressure/mprls0025pa_i2c.c
@@ -27,8 +27,6 @@ static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt)
 	ret = i2c_master_recv(client, data->rx_buf, cnt);
 	if (ret < 0)
 		return ret;
-	else if (ret != cnt)
-		return -EIO;
 
 	return 0;
 }
@@ -42,8 +40,6 @@ static int mpr_i2c_write(struct mpr_data *data, const u8 cmd, const u8 unused)
 	ret = i2c_master_send(client, data->tx_buf, MPR_PKT_SYNC_LEN);
 	if (ret < 0)
 		return ret;
-	else if (ret != MPR_PKT_SYNC_LEN)
-		return -EIO;
 
 	return 0;
 }
-- 
2.43.0


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

* [PATCH 22/22] iio: pressure: sdp500: Remove redundant i2c_master_recv() length check
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (20 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 21/22] iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
@ 2026-07-16  0:57 ` Jonathan Cameron
  2026-07-16  8:01 ` [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Joshua Crofts
  2026-07-16 10:15 ` Nuno Sá
  23 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-07-16  0:57 UTC (permalink / raw)
  To: linux-iio; +Cc: David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron

i2c_master_recv() returns either a negative errno or exactly the count
passed in, so the length check after the 'ret < 0' test can never be
true. Drop the dead branch.

Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Assisted-by: Claude:claude-opus-4-8
---
 drivers/iio/pressure/sdp500.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/iio/pressure/sdp500.c b/drivers/iio/pressure/sdp500.c
index 153f335ebf1e..f18b459114dd 100644
--- a/drivers/iio/pressure/sdp500.c
+++ b/drivers/iio/pressure/sdp500.c
@@ -54,10 +54,6 @@ static int sdp500_read_raw(struct iio_dev *indio_dev,
 			dev_err(data->dev, "Failed to receive data");
 			return ret;
 		}
-		if (ret != SDP500_READ_SIZE) {
-			dev_err(data->dev, "Data is received wrongly");
-			return -EIO;
-		}
 
 		received_crc = rxbuf[2];
 		calculated_crc = crc8(sdp500_crc8_table, rxbuf,
-- 
2.43.0


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

* Re: [PATCH 12/22] iio: dac: max517: Remove redundant i2c_master_send() length check
  2026-07-16  0:57 ` [PATCH 12/22] iio: dac: max517: " Jonathan Cameron
@ 2026-07-16  7:45   ` Joshua Crofts
  0 siblings, 0 replies; 26+ messages in thread
From: Joshua Crofts @ 2026-07-16  7:45 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá; +Cc: linux-iio, David Lechner, Andy Shevchenko

On Wed, 15 Jul 2026 17:57:27 -0700
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> wrote:

> i2c_master_send() returns either a negative errno or exactly the count
> passed in, so the length check after the 'ret < 0' test can never be
> true. Drop the dead branch.
> 
> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> Assisted-by: Claude:claude-opus-4-8
> ---
>  drivers/iio/dac/max517.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
> index d2ddc72e0e50..e0d1a26c4f73 100644
> --- a/drivers/iio/dac/max517.c
> +++ b/drivers/iio/dac/max517.c
> @@ -55,10 +55,8 @@ static int max517_set_value(struct iio_dev *indio_dev,
>  	res = i2c_master_send(client, outbuf, 2);

Someone should also remove all the hard-coded sizes, they appear in multiple
drivers you're touching.

-- 
Kind regards

CJD

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

* Re: [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (21 preceding siblings ...)
  2026-07-16  0:57 ` [PATCH 22/22] iio: pressure: sdp500: Remove redundant i2c_master_recv() length check Jonathan Cameron
@ 2026-07-16  8:01 ` Joshua Crofts
  2026-07-16 10:15 ` Nuno Sá
  23 siblings, 0 replies; 26+ messages in thread
From: Joshua Crofts @ 2026-07-16  8:01 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, David Lechner, Nuno Sá, Andy Shevchenko

On Wed, 15 Jul 2026 17:57:15 -0700
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com> wrote:

> Resend to include linux-iio. Sorry to all who get it twice.
> 
> This came up in a recent review and I realised I have been giving incorrect
> review feedback for years. Both i2_master_send() and i2c_master_recv() plus
> the dma safe variants only ever return either an error or the full buffer
> size.  Short accesses do not occur.
> 
> This series (also my first upstream series prepared by poking claude)
> removes the redundant checks from all IIO drivers.
> 
> Thanks,
> 
> Jonathan

FWIW, for the whole series:

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

Also, as trivial as this change is - if you were hoping on Sashiko picking this
up then it failed to apply, as you didn't add a baseline.

-- 
Kind regards

CJD

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

* Re: [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers
  2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
                   ` (22 preceding siblings ...)
  2026-07-16  8:01 ` [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Joshua Crofts
@ 2026-07-16 10:15 ` Nuno Sá
  23 siblings, 0 replies; 26+ messages in thread
From: Nuno Sá @ 2026-07-16 10:15 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, David Lechner, Nuno Sá, Andy Shevchenko

On Wed, Jul 15, 2026 at 05:57:15PM -0700, Jonathan Cameron wrote:
> Resend to include linux-iio. Sorry to all who get it twice.
> 
> This came up in a recent review and I realised I have been giving incorrect
> review feedback for years. Both i2_master_send() and i2c_master_recv() plus
> the dma safe variants only ever return either an error or the full buffer
> size.  Short accesses do not occur.
> 

Interesting! I had the same wrong assumptions! I guess the same is true
for the smbus variants?

Anyways,

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

> This series (also my first upstream series prepared by poking claude)
> removes the redundant checks from all IIO drivers.
> 
> Thanks,
> 
> Jonathan
> 
> Jonathan Cameron (22):
>   iio: adc: ltc2471: Remove redundant i2c_master_recv() length check
>   iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks
>   iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}()
>     length checks
>   iio: chemical: scd30: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: chemical: scd4x: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: chemical: sgp30: Remove redundant i2c_master_recv() length check
>   iio: chemical: sgp40: Remove redundant i2c_master_recv() length check
>   iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: dac: ad5446: Remove redundant i2c_master_send() length check
>   iio: dac: ad5696: Remove redundant i2c_master_send() length check
>   iio: dac: m62332: Remove redundant i2c_master_send() length check
>   iio: dac: max517: Remove redundant i2c_master_send() length check
>   iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: dac: mcp4725: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: dac: mcp4728: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: light: lv0104cs: Remove redundant i2c_master_{send,recv}() length
>     checks
>   iio: potentiometer: ad5110: Remove redundant i2c_master_{send,recv}()
>     length checks
>   iio: pressure: abp2030pa: Remove redundant i2c_master_{send,recv}()
>     length checks
>   iio: pressure: adp810: Remove redundant i2c_master_{send,recv}()
>     length checks
>   iio: pressure: icp10100: Remove redundant i2c_master_send() length
>     check
>   iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}()
>     length checks
>   iio: pressure: sdp500: Remove redundant i2c_master_recv() length check
> 
>  drivers/iio/adc/ltc2471.c              |  2 --
>  drivers/iio/adc/ti-ads7138.c           |  4 ----
>  drivers/iio/adc/versal-sysmon-i2c.c    |  6 ------
>  drivers/iio/chemical/scd30_i2c.c       |  4 ----
>  drivers/iio/chemical/scd4x.c           |  8 --------
>  drivers/iio/chemical/sgp30.c           |  2 --
>  drivers/iio/chemical/sgp40.c           |  4 ----
>  drivers/iio/chemical/sps30_i2c.c       |  4 ----
>  drivers/iio/dac/ad5446-i2c.c           |  2 --
>  drivers/iio/dac/ad5696-i2c.c           |  2 +-
>  drivers/iio/dac/m62332.c               |  2 --
>  drivers/iio/dac/max517.c               |  6 ++----
>  drivers/iio/dac/max5821.c              | 14 ++------------
>  drivers/iio/dac/mcp4725.c              | 22 ++++++----------------
>  drivers/iio/dac/mcp4728.c              | 13 +------------
>  drivers/iio/light/lv0104cs.c           |  4 ----
>  drivers/iio/potentiometer/ad5110.c     | 18 +++---------------
>  drivers/iio/pressure/abp2030pa_i2c.c   |  4 ----
>  drivers/iio/pressure/adp810.c          |  4 ----
>  drivers/iio/pressure/icp10100.c        |  2 --
>  drivers/iio/pressure/mprls0025pa_i2c.c |  4 ----
>  drivers/iio/pressure/sdp500.c          |  4 ----
>  22 files changed, 15 insertions(+), 120 deletions(-)
> 
> -- 
> 2.43.0
> 

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

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

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  0:57 [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Jonathan Cameron
2026-07-16  0:57 ` [PATCH 01/22] iio: adc: ltc2471: Remove redundant i2c_master_recv() length check Jonathan Cameron
2026-07-16  0:57 ` [PATCH 02/22] iio: adc: ti-ads7138: Remove redundant i2c_master_send() length checks Jonathan Cameron
2026-07-16  0:57 ` [PATCH 03/22] iio: adc: versal-sysmon: Remove redundant i2c_master_{send,recv}() " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 04/22] iio: chemical: scd30: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 05/22] iio: chemical: scd4x: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 06/22] iio: chemical: sgp30: Remove redundant i2c_master_recv() length check Jonathan Cameron
2026-07-16  0:57 ` [PATCH 07/22] iio: chemical: sgp40: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 08/22] iio: chemical: sps30: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
2026-07-16  0:57 ` [PATCH 09/22] iio: dac: ad5446: Remove redundant i2c_master_send() length check Jonathan Cameron
2026-07-16  0:57 ` [PATCH 10/22] iio: dac: ad5696: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 11/22] iio: dac: m62332: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 12/22] iio: dac: max517: " Jonathan Cameron
2026-07-16  7:45   ` Joshua Crofts
2026-07-16  0:57 ` [PATCH 13/22] iio: dac: max5821: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
2026-07-16  0:57 ` [PATCH 14/22] iio: dac: mcp4725: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 15/22] iio: dac: mcp4728: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 16/22] iio: light: lv0104cs: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 17/22] iio: potentiometer: ad5110: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 18/22] iio: pressure: abp2030pa: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 19/22] iio: pressure: adp810: " Jonathan Cameron
2026-07-16  0:57 ` [PATCH 20/22] iio: pressure: icp10100: Remove redundant i2c_master_send() length check Jonathan Cameron
2026-07-16  0:57 ` [PATCH 21/22] iio: pressure: mprls0025pa: Remove redundant i2c_master_{send,recv}() length checks Jonathan Cameron
2026-07-16  0:57 ` [PATCH 22/22] iio: pressure: sdp500: Remove redundant i2c_master_recv() length check Jonathan Cameron
2026-07-16  8:01 ` [RESEND PATCH 00/22] IIO: Clean out superfluous I2C checks for single transfers Joshua Crofts
2026-07-16 10:15 ` Nuno Sá

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