[i2c] Send data for I2C_SMBUS_BYTE command

The data needs to be sent for I2C_SMBUS_BYTE command and we need to make
sure we don't access the same for I2C_SMBUS_QUICK command after the
command is processed.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
Viresh Kumar 2021-11-16 16:44:57 +05:30
parent 473e45ee0f
commit b4e47f4994
2 changed files with 6 additions and 8 deletions

View file

@ -1,5 +1,5 @@
{ {
"coverage_score": 43.2, "coverage_score": 42.9,
"exclude_path": "", "exclude_path": "",
"crate_features": "" "crate_features": ""
} }

View file

@ -203,7 +203,7 @@ impl SmbusMsg {
read_write, read_write,
command: reqs[0].buf[0], command: reqs[0].buf[0],
size: I2C_SMBUS_BYTE, size: I2C_SMBUS_BYTE,
data: None, data: Some(data),
}), }),
// Write requests // Write requests
@ -456,14 +456,12 @@ impl<D: I2cDevice> I2cAdapter<D> {
self.device.smbus(&mut msg)?; self.device.smbus(&mut msg)?;
if msg.read_write == I2C_SMBUS_READ { if msg.read_write == I2C_SMBUS_READ {
// data is guaranteed to be valid here.
let data = msg.data.unwrap();
match msg.size { match msg.size {
I2C_SMBUS_BYTE => reqs[0].buf[0] = data.read_byte(), I2C_SMBUS_QUICK => {}
I2C_SMBUS_BYTE_DATA => reqs[1].buf[0] = data.read_byte(), I2C_SMBUS_BYTE => reqs[0].buf[0] = msg.data.unwrap().read_byte(),
I2C_SMBUS_BYTE_DATA => reqs[1].buf[0] = msg.data.unwrap().read_byte(),
I2C_SMBUS_WORD_DATA => { I2C_SMBUS_WORD_DATA => {
let word = data.read_word(); let word = msg.data.unwrap().read_word();
reqs[1].buf[0] = (word & 0xff) as u8; reqs[1].buf[0] = (word & 0xff) as u8;
reqs[1].buf[1] = (word >> 8) as u8; reqs[1].buf[1] = (word >> 8) as u8;