mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-29 17:09:25 +00:00
[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:
parent
473e45ee0f
commit
b4e47f4994
@ -1,5 +1,5 @@
|
||||
{
|
||||
"coverage_score": 43.2,
|
||||
"coverage_score": 42.9,
|
||||
"exclude_path": "",
|
||||
"crate_features": ""
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ impl SmbusMsg {
|
||||
read_write,
|
||||
command: reqs[0].buf[0],
|
||||
size: I2C_SMBUS_BYTE,
|
||||
data: None,
|
||||
data: Some(data),
|
||||
}),
|
||||
|
||||
// Write requests
|
||||
@ -456,14 +456,12 @@ impl<D: I2cDevice> I2cAdapter<D> {
|
||||
self.device.smbus(&mut msg)?;
|
||||
|
||||
if msg.read_write == I2C_SMBUS_READ {
|
||||
// data is guaranteed to be valid here.
|
||||
let data = msg.data.unwrap();
|
||||
|
||||
match msg.size {
|
||||
I2C_SMBUS_BYTE => reqs[0].buf[0] = data.read_byte(),
|
||||
I2C_SMBUS_BYTE_DATA => reqs[1].buf[0] = data.read_byte(),
|
||||
I2C_SMBUS_QUICK => {}
|
||||
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 => {
|
||||
let word = data.read_word();
|
||||
let word = msg.data.unwrap().read_word();
|
||||
|
||||
reqs[1].buf[0] = (word & 0xff) as u8;
|
||||
reqs[1].buf[1] = (word >> 8) as u8;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user