summaryrefslogtreecommitdiffstats
path: root/hw/i2c/pm_smbus.c
diff options
context:
space:
mode:
authorCorey Minyard2018-08-20 22:26:02 +0200
committerPaolo Bonzini2018-08-23 18:46:25 +0200
commit4b615be540d8566f4b981245b4d5401163c57ced (patch)
tree1e8c10900bbfb2d31909ad62c86909006abf1e5b /hw/i2c/pm_smbus.c
parenti2c: pm_smbus: Clean up some style issues (diff)
downloadqemu-4b615be540d8566f4b981245b4d5401163c57ced.tar.gz
qemu-4b615be540d8566f4b981245b4d5401163c57ced.tar.xz
qemu-4b615be540d8566f4b981245b4d5401163c57ced.zip
i2c: pm_smbus: Fix the semantics of block I2C transfers
The I2C block transfer commands was not implemented correctly, it read a length byte and such like it was an smbus transfer. So fix the smbus_read_block() and smbus_write_block() functions so they can properly handle I2C transfers, and normal SMBus transfers (for upcoming changes). Pass in a transfer size and a bool to know whether to use the size byte (like SMBus) or use the length given (like I2C). Signed-off-by: Corey Minyard <cminyard@mvista.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1534796770-10295-3-git-send-email-minyard@acm.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i2c/pm_smbus.c')
-rw-r--r--hw/i2c/pm_smbus.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 83c2377bb4..f1fe889043 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -117,10 +117,16 @@ static void smb_transaction(PMSMBus *s)
break;
case PROT_I2C_BLOCK_DATA:
if (read) {
- ret = smbus_read_block(bus, addr, cmd, s->smb_data);
+ int xfersize = s->smb_data0;
+ if (xfersize > sizeof(s->smb_data)) {
+ xfersize = sizeof(s->smb_data);
+ }
+ ret = smbus_read_block(bus, addr, s->smb_data1, s->smb_data,
+ xfersize, false, true);
goto data8;
} else {
- ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0);
+ ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0,
+ false);
goto done;
}
break;