HomeFreeBSD

rk_i2c_fill_tx: fix a number of issues

Description

rk_i2c_fill_tx: fix a number of issues

  • maximum number of bytes that can be sent is 32, not 8;
  • previous interface required callers to bump sc->msg->len in addition to setting sc->tx_slave_addr;
  • because of the above there was an issue with writing one too many bytes because sc->cnt is not advanced when the slave address is written;
  • the inetraction between outer and inner loops was confusing as the former was bounded on the number of bytes to write and the counter was incremented by one, but the inner loop advanced four bytes at a time;
  • the return value was incorrect in the tx_slave_addr case; one call place had to use its own (and incorrect in some cases) notion of the write lenth.

All of the above issues should be fixed.
Some sanity asserts are added.
All callers use the return value to program RK_I2C_MTXCNT.
iic_msg::len no longer needs to be hacked.
A constant is added to reflect the maximum number of octets that can be
sent or received in one go (they are the same).

(cherry picked from commit c6635459510c9c03a439bc5b59fef37259d21967)
(cherry picked from commit b7bcd21d2da50364a512092cb4e75f2d53070ba6)

Details

Provenance
avgAuthored on Dec 15 2021, 11:00 AM
Parents
rGee74d0c3619e: rk_i2c_transfer: minor improvement to bit twiddling
Branches
Unknown
Tags
Unknown