Skip to content

Commit ce94b5a

Browse files
ecsvgregkh
authored andcommitted
i2c: rtl9300: Add missing count byte for SMBus Block Ops
commit 82b350d upstream. The expected on-wire format of an SMBus Block Write is S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P Everything starting from the Count byte is provided by the I2C subsystem in the array data->block. But the driver was skipping the Count byte (data->block[0]) when sending it to the RTL93xx I2C controller. Only the actual data could be seen on the wire: S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P This wire format is not SMBus Block Write compatible but matches the format of an I2C Block Write. Simply adding the count byte to the buffer for the I2C controller is enough to fix the transmission. This also affects read because the I2C controller must receive the count byte + $count * data bytes. Fixes: c366be7 ("i2c: Add driver for the RTL9300 I2C controller") Signed-off-by: Sven Eckelmann <sven@narfation.org> Cc: <stable@vger.kernel.org> # v6.13+ Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250810-i2c-rtl9300-multi-byte-v5-4-cd9dca0db722@narfation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2245a5e commit ce94b5a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/i2c/busses/i2c-rtl9300.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,15 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
285285
ret = -EINVAL;
286286
goto out_unlock;
287287
}
288-
ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0]);
288+
ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0] + 1);
289289
if (ret)
290290
goto out_unlock;
291291
if (read_write == I2C_SMBUS_WRITE) {
292-
ret = rtl9300_i2c_write(i2c, &data->block[1], data->block[0]);
292+
ret = rtl9300_i2c_write(i2c, &data->block[0], data->block[0] + 1);
293293
if (ret)
294294
goto out_unlock;
295295
}
296-
len = data->block[0];
296+
len = data->block[0] + 1;
297297
break;
298298

299299
default:

0 commit comments

Comments
 (0)