From: Olliver Schinagl <[email protected]>

The I2C tools suggest they can do block read/writes using either
's'(mbus) or 'i'(2c) access. However the current code limits reads
specifically to a single block, which depending on the driver, may limit
this to even less bytes. Looking closer, we actually see that the commands
to read via either access is really the same, where the only difference
is, that SMBus access can at most read 32 bytes (but can read less) but
cannot be told to read less, and I2C access can read up to 1 byte
granularity. Everything else works the same, and thus the loop to read
multiple bytes works for both cases equally well. This change thus also
reduces the code a tiny bit, but makes it more readable at the least.

Further more, while here, a little bit of cleanup. One cosmetic and one
where instead of always returning -1 (which is horrible to debug when
your console just tells you this) instead returns errno that ioctl had
already set for us anyway.

Olliver Schinagl (3):
  i2c_tools: cosmetic: Avoid hardcoded values
  i2c_tools: Return proper errno from ioctl
  i2c_tools: Read all data in both block reads

 miscutils/i2c_tools.c | 54 ++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 29 deletions(-)

-- 
2.51.1.dirty

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to