mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
i2c: Add asserts for second smbus i2c_start_transfer()
Some SMBus operations restart the transfer to convert from write to read mode without an intervening i2c_end_transfer(). The second call cannot fail, so the return code is unchecked, but this causes Coverity to complain. So add some asserts and documentation about this. Signed-off-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
19a6e31c9d
commit
cc083d8a25
2 changed files with 15 additions and 4 deletions
|
@ -248,7 +248,9 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
|
|||
return -1;
|
||||
}
|
||||
i2c_send(bus, command);
|
||||
i2c_start_transfer(bus, addr, 1);
|
||||
if (i2c_start_transfer(bus, addr, 1)) {
|
||||
assert(0);
|
||||
}
|
||||
data = i2c_recv(bus);
|
||||
i2c_nack(bus);
|
||||
i2c_end_transfer(bus);
|
||||
|
@ -273,7 +275,9 @@ int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
|
|||
return -1;
|
||||
}
|
||||
i2c_send(bus, command);
|
||||
i2c_start_transfer(bus, addr, 1);
|
||||
if (i2c_start_transfer(bus, addr, 1)) {
|
||||
assert(0);
|
||||
}
|
||||
data = i2c_recv(bus);
|
||||
data |= i2c_recv(bus) << 8;
|
||||
i2c_nack(bus);
|
||||
|
@ -302,7 +306,9 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
|
|||
return -1;
|
||||
}
|
||||
i2c_send(bus, command);
|
||||
i2c_start_transfer(bus, addr, 1);
|
||||
if (i2c_start_transfer(bus, addr, 1)) {
|
||||
assert(0);
|
||||
}
|
||||
len = i2c_recv(bus);
|
||||
if (len > 32) {
|
||||
len = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue