From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/3] smbus: fix writes
Date: Sat, 4 Feb 2012 09:03:30 +0100 [thread overview]
Message-ID: <1328342612-25826-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1328342612-25826-1-git-send-email-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/smbus.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/smbus.c b/hw/smbus.c
index 77626f3..4ff2342 100644
--- a/hw/smbus.c
+++ b/hw/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.7.6
next prev parent reply other threads:[~2012-02-04 8:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-04 8:03 [Qemu-devel] [PATCH 0/3] Remove PROP_PTR, part 2/4 Paolo Bonzini
2012-02-04 8:03 ` Paolo Bonzini [this message]
2012-02-04 8:03 ` [Qemu-devel] [PATCH 2/3] smbus_eeprom: remove PTR property Paolo Bonzini
2012-02-04 8:03 ` [Qemu-devel] [PATCH 3/3] vmmouse: replace PROP_PTR property with gpio pin to i8042 Paolo Bonzini
2012-02-04 13:03 ` Gerhard Wiesinger
2012-02-04 13:15 ` Paolo Bonzini
2012-02-07 12:39 ` Juan Quintela
2012-02-07 12:54 ` Paolo Bonzini
2012-02-09 0:48 ` Paul Brook
-- strict thread matches above, loose matches on Subject: below --
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 ` [Qemu-devel] [PATCH 1/3] smbus: fix writes Marc Marí
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=1328342612-25826-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--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).