i2c-stub: Allow increasing the SMBus block write length
Subsystems (3)
PATCH v2 1/1 i2c-stub: Allow increasing the SMBus block write length
This is no good reason to not allow SMBus block writes longer than the first one was. Lift this limitation, this makes the code more simple.
Signed-off-by Jean Delvare <[email protected]>
Reviewed-by Guenter Roeck <[email protected]>
---
Changes since v1:
* Sent in a separate thread
* Added Guenter's Reviewed-by
* Fixed subject
Documentation/i2c/i2c-stub | 5 ++--- drivers/i2c/i2c-stub.c | 12 +++--------- 2 files changed, 5 insertions(+), 12 deletions(-)
Documentation/i2c/i2c-stub +2 -3
@@ -20,9 +20,8 @@ operations. This allows for continuous EEPROMs, among others. SMBus block commands must be written to configure an SMBus command for -SMBus block operations. The first SMBus block write selects the block length. -Subsequent writes can be partial. Block read commands always return -the number of bytes selected with the first write. +SMBus block operations. Writes can be partial. Block read commands always +return the number of bytes selected with the largest write so far. The typical use-case is like this: 1. load this module
drivers/i2c/i2c-stub.c +3 -9
@@ -254,13 +254,6 @@ static s32 stub_xfer(struct i2c_adapter ret = -EINVAL ;break ; } -if (b && len > b->len) { -dev_dbg (&adap->dev, -"Attempt to write more data (%d) than with initial SMBus block write (%d)\n" , - len, b->len); - ret = -EINVAL ; -break ; - }if (b ==NULL ) { b =stub_find_block (&adap->dev, chip, command, true);
@@ -268,9 +261,10 @@ static s32 stub_xfer(struct i2c_adapter ret = -ENOMEM ;break ; } -/* First write sets block length */ - b->len = len; } +/* Largest write sets read block length */ +if (len > b->len) + b->len = len;for (i =0 ; i < len; i++) b->block[i] = data->block[i +1 ];/* update for byte and word commands */
Signature · 2 lines
Jean Delvare SUSE L3 Support
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Jean Delvare
This is no good reason to not allow SMBus block writes longer than the first one was. Lift this limitation, this makes the code more simple.
Signed-off-by Jean Delvare <[email protected]>Reviewed-by Guenter Roeck <[email protected]>
Applied to my system and working, so you can also add
Tested-by Guenter Roeck <[email protected]>
Guenter