From: "Marc Marí" <marc.mari.barcelo@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] smbus: fix writes
Date: Mon, 9 Jun 2014 10:55:31 +0200 [thread overview]
Message-ID: <1402304133-29620-2-git-send-email-marc.mari.barcelo@gmail.com> (raw)
In-Reply-To: <1402304133-29620-1-git-send-email-marc.mari.barcelo@gmail.com>
From: Paolo Bonzini <pbonzini@redhat.com>
SMBus protocol sends offset and length before the actual data that
is transferred. So we need to skip two bytes rather than one.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i2c/smbus.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 6e27ae8..173a533 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -59,9 +59,12 @@ static void smbus_do_write(SMBusDevice *dev)
} else {
dev->command = dev->data_buf[0];
DPRINTF("Command %d len %d\n", dev->command, dev->data_len - 1);
+ if (dev->data_buf[1] > dev->data_len - 2) {
+ fprintf(stderr, "SMBus data transfer overrun!\n");
+ }
if (sc->write_data) {
- sc->write_data(dev, dev->command, dev->data_buf + 1,
- dev->data_len - 1);
+ sc->write_data(dev, dev->command, dev->data_buf + 2,
+ MIN(dev->data_buf[1], dev->data_len - 2));
}
}
}
--
1.7.10.4
next prev parent reply other threads:[~2014-06-09 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-09 8:55 [Qemu-devel] [PATCH 0/3] Add PIIX4 SMBus to qtest and related changes Marc Marí
2014-06-09 8:55 ` Marc Marí [this message]
2014-06-09 8:55 ` [Qemu-devel] [PATCH 2/3] x86 piix4: Correct SMBus base address Marc Marí
2014-06-09 8:55 ` [Qemu-devel] [PATCH 3/3] qtest: Add PIIX4 SMBus support for libqos Marc Marí
2014-06-09 10:33 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2012-02-04 8:03 [Qemu-devel] [PATCH 0/3] Remove PROP_PTR, part 2/4 Paolo Bonzini
2012-02-04 8:03 ` [Qemu-devel] [PATCH 1/3] smbus: fix writes Paolo Bonzini
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=1402304133-29620-2-git-send-email-marc.mari.barcelo@gmail.com \
--to=marc.mari.barcelo@gmail.com \
--cc=afaerber@suse.de \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).