[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 05/19] i2c:smbus: Correct the working of quick co
From: |
minyard |
Subject: |
[Qemu-devel] [PATCH v4 05/19] i2c:smbus: Correct the working of quick commands |
Date: |
Mon, 28 Jan 2019 11:54:44 -0600 |
From: Corey Minyard <address@hidden>
The logic of handling quick SMBus commands was wrong. If you get a
finish event with no data, that's a quick command.
Document the quick command while we are at it.
Signed-off-by: Corey Minyard <address@hidden>
---
hw/i2c/smbus_slave.c | 35 +++++++++++++++++++----------------
include/hw/i2c/smbus_slave.h | 5 +++++
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c
index 6e4d542f51..6a89a286e3 100644
--- a/hw/i2c/smbus_slave.c
+++ b/hw/i2c/smbus_slave.c
@@ -54,9 +54,7 @@ static void smbus_do_write(SMBusDevice *dev)
{
SMBusDeviceClass *sc = SMBUS_DEVICE_GET_CLASS(dev);
- if (dev->data_len == 0) {
- smbus_do_quick_cmd(dev, 0);
- } else if (dev->data_len == 1) {
+ if (dev->data_len == 1) {
DPRINTF("Send Byte\n");
if (sc->send_byte) {
sc->send_byte(dev, dev->data_buf[0]);
@@ -120,19 +118,24 @@ static int smbus_i2c_event(I2CSlave *s, enum i2c_event
event)
break;
case I2C_FINISH:
- switch (dev->mode) {
- case SMBUS_WRITE_DATA:
- smbus_do_write(dev);
- break;
- case SMBUS_RECV_BYTE:
- smbus_do_quick_cmd(dev, 1);
- break;
- case SMBUS_READ_DATA:
- BADF("Unexpected stop during receive\n");
- break;
- default:
- /* Nothing to do. */
- break;
+ if (dev->data_len == 0) {
+ if (dev->mode == SMBUS_WRITE_DATA || dev->mode == SMBUS_READ_DATA)
{
+ smbus_do_quick_cmd(dev, dev->mode == SMBUS_READ_DATA);
+ }
+ } else {
+ switch (dev->mode) {
+ case SMBUS_WRITE_DATA:
+ smbus_do_write(dev);
+ break;
+
+ case SMBUS_READ_DATA:
+ BADF("Unexpected stop during receive\n");
+ break;
+
+ default:
+ /* Nothing to do. */
+ break;
+ }
}
dev->mode = SMBUS_IDLE;
dev->data_len = 0;
diff --git a/include/hw/i2c/smbus_slave.h b/include/hw/i2c/smbus_slave.h
index 46b8948f0f..5ef1c72ad0 100644
--- a/include/hw/i2c/smbus_slave.h
+++ b/include/hw/i2c/smbus_slave.h
@@ -40,6 +40,11 @@ typedef struct SMBusDevice SMBusDevice;
typedef struct SMBusDeviceClass
{
I2CSlaveClass parent_class;
+
+ /*
+ * An operation with no data, special in SMBus.
+ * This may be NULL, quick commands are ignore in that case.
+ */
void (*quick_cmd)(SMBusDevice *dev, uint8_t read);
void (*send_byte)(SMBusDevice *dev, uint8_t val);
uint8_t (*receive_byte)(SMBusDevice *dev);
--
2.17.1
- [Qemu-devel] [PATCH v4 00/19] Fix/add vmstate handling in some I2C code, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 19/19] i2c: Verify that the count passed in to smbus_eeprom_init() is valid, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 16/19] i2c:smbus_eeprom: Add a size constant for the smbus_eeprom size, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 14/19] i2c:smbus_slave: Add an SMBus vmstate structure, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 15/19] i2c:smbus_eeprom: Add normal type name and cast to smbus_eeprom.c, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 10/19] boards.h: Ignore migration for SMBus devices on older machines, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 18/19] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 02/19] i2c: have I2C receive operation return uint8_t, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 05/19] i2c:smbus: Correct the working of quick commands,
minyard <=
- [Qemu-devel] [PATCH v4 11/19] i2c:pm_smbus: Fix pm_smbus handling of I2C block read, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 04/19] i2c: Don't check return value from i2c_recv(), minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 03/19] arm:i2c: Don't mask return from i2c_recv(), minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 17/19] i2c:smbus_eeprom: Add vmstate handling to the smbus eeprom, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 08/19] i2c:smbus_eeprom: Get rid of the quick command, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 13/19] i2c:pm_smbus: Fix state transfer, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 01/19] i2c: Split smbus into parts, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 09/19] i2c:smbus: Make white space in switch statements consistent, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 12/19] migration: Add a VMSTATE_BOOL_TEST() macro, minyard, 2019/01/28
- [Qemu-devel] [PATCH v4 06/19] i2c:smbus: Simplify write operation, minyard, 2019/01/28