[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-1.4 v4 3/6] tmp105: Fix I2C protocol bug
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH for-1.4 v4 3/6] tmp105: Fix I2C protocol bug |
Date: |
Wed, 16 Jan 2013 01:57:56 +0100 |
An early length postincrement in the TMP105's I2C TX path led to
transfers of more than one byte to place the second byte in the third
byte's place within the buffer and the third byte to get discarded.
Fix this by explictly incrementing the length after the checks but
before the callback is called, which again checks the length.
Adjust the Coding Style while at it.
Signed-off-by: Alex Horn <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
Reviewed-by: Anthony Liguori <address@hidden>
---
hw/tmp105.c | 9 ++++++---
1 Datei geändert, 6 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
diff --git a/hw/tmp105.c b/hw/tmp105.c
index 0ade4eb..10d94c9 100644
--- a/hw/tmp105.c
+++ b/hw/tmp105.c
@@ -153,11 +153,14 @@ static int tmp105_tx(I2CSlave *i2c, uint8_t data)
{
TMP105State *s = (TMP105State *) i2c;
- if (!s->len ++)
+ if (s->len == 0) {
s->pointer = data;
- else {
- if (s->len <= 2)
+ s->len++;
+ } else {
+ if (s->len <= 2) {
s->buf[s->len - 1] = data;
+ }
+ s->len++;
tmp105_write(s);
}
--
1.7.10.4
- [Qemu-devel] [PATCH for-1.4 v4 0/6] I2C libqos and tmp105 qtest support, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH for-1.4 v4 2/6] tmp105: Split out I2C message constants from header, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH for-1.4 v4 5/6] tmp105: QOM'ify, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH for-1.4 v4 3/6] tmp105: Fix I2C protocol bug,
Andreas Färber <=
- [Qemu-devel] [PATCH for-1.4 v4 1/6] libqtest: Prepare I2C libqos, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH for-1.4 v4 6/6] tmp105: Add temperature QOM property, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH for-1.4 v4 4/6] tests: Add tmp105 qtest test case, Andreas Färber, 2013/01/15
- Re: [Qemu-devel] [PATCH for-1.4 v4 0/6] I2C libqos and tmp105 qtest support, Anthony Liguori, 2013/01/21