summary refs log tree commit diff stats
path: root/hw/i2c/core.c
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2016-10-24 10:42:33 -0500
committerPeter Maydell <peter.maydell@linaro.org>2016-10-24 16:48:02 +0100
commitcc083d8a25e0a886c3cd4bea0bf57ac4e896fa3f (patch)
treef19623fb6ecd678d87d0cbd769ba8d979aeace2a /hw/i2c/core.c
parent19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e (diff)
downloadfocaccia-qemu-cc083d8a25e0a886c3cd4bea0bf57ac4e896fa3f.tar.gz
focaccia-qemu-cc083d8a25e0a886c3cd4bea0bf57ac4e896fa3f.zip
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>
Diffstat (limited to 'hw/i2c/core.c')
-rw-r--r--hw/i2c/core.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index bd8f16759d..abd4c4cddb 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -88,7 +88,12 @@ int i2c_bus_busy(I2CBus *bus)
     return !QLIST_EMPTY(&bus->current_devs);
 }
 
-/* Returns non-zero if the address is not valid.  */
+/*
+ * Returns non-zero if the address is not valid.  If this is called
+ * again without an intervening i2c_end_transfer(), like in the SMBus
+ * case where the operation is switched from write to read, this
+ * function will not rescan the bus and thus cannot fail.
+ */
 /* TODO: Make this handle multiple masters.  */
 int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
 {