From: "Andreas Färber" <andreas.faerber@web.de>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Blue Swirl" <blauwirbel@gmail.com>,
"Alex Horn" <alex.horn@cs.ox.ac.uk>,
"Andreas Färber" <andreas.faerber@web.de>,
"Anthony Liguori" <anthony@codemonkey.ws>
Subject: [Qemu-devel] [PATCH v2 5/7] tmp105: Fix I2C protocol bug
Date: Fri, 14 Dec 2012 12:34:30 +0100 [thread overview]
Message-ID: <1355484872-11283-6-git-send-email-andreas.faerber@web.de> (raw)
In-Reply-To: <1355484872-11283-1-git-send-email-andreas.faerber@web.de>
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 <alex.horn@cs.ox.ac.uk>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
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 9c67e64..ff9f28b 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
next prev parent reply other threads:[~2012-12-14 11:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 11:34 [Qemu-devel] [PATCH v2 0/7] I2C libqos and tmp105 qtest support Andreas Färber
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 1/7] tmp105: Create API for TMP105 temperature sensor Andreas Färber
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 2/7] libqtest: Prepare I2C libqos Andreas Färber
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 3/7] tmp105: Split out I2C message constants from header Andreas Färber
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 4/7] tests: Add tmp105 qtest test case Andreas Färber
2012-12-14 11:34 ` Andreas Färber [this message]
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 6/7] tmp105: QOM'ify Andreas Färber
2012-12-14 11:34 ` [Qemu-devel] [PATCH v2 7/7] tmp105: Add temperature QOM property Andreas Färber
2012-12-15 16:52 ` Alex Horn
2012-12-15 18:30 ` Andreas Färber
2013-01-06 21:07 ` [Qemu-devel] [PATCH v2 0/7] I2C libqos and tmp105 qtest support Andreas Färber
2013-01-07 19:36 ` Anthony Liguori
2013-01-07 19:37 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355484872-11283-6-git-send-email-andreas.faerber@web.de \
--to=andreas.faerber@web.de \
--cc=alex.horn@cs.ox.ac.uk \
--cc=anthony@codemonkey.ws \
--cc=blauwirbel@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).