[PATCH] Extend I2C tools to read unlimited lengths

Olliver Schinagl oliver+busybox at schinagl.nl
Fri May 12 08:35:22 UTC 2023


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.




More information about the busybox mailing list