diff options
author | Corey Minyard <cminyard@mvista.com> | 2018-11-30 13:38:21 -0600 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2019-02-27 21:06:08 -0600 |
commit | 9cf27d74a829f651c0da5d80c014a6cef9d4cbd8 (patch) | |
tree | 74bb0f0aee54e6e81fccfeb58417bcecaab85366 /include/hw | |
parent | 905cec6d11088e585fcedb3fd606510959ee50ff (diff) | |
download | qemu-9cf27d74a829f651c0da5d80c014a6cef9d4cbd8.zip qemu-9cf27d74a829f651c0da5d80c014a6cef9d4cbd8.tar.gz qemu-9cf27d74a829f651c0da5d80c014a6cef9d4cbd8.tar.bz2 |
i2c:smbus: Simplify write operation
There were two different write functions and the SMBus code kept
track of the command.
Keeping track of the command wasn't useful, in fact it wasn't quite
correct for the eeprom_smbus code. And there is no need for two write
functions. Just have one write function and the first byte in the
buffer is the command.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'include/hw')
-rw-r--r-- | include/hw/i2c/smbus_slave.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/include/hw/i2c/smbus_slave.h b/include/hw/i2c/smbus_slave.h index 5ef1c72..fa92201 100644 --- a/include/hw/i2c/smbus_slave.h +++ b/include/hw/i2c/smbus_slave.h @@ -46,18 +46,24 @@ typedef struct SMBusDeviceClass * 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); - /* We can't distinguish between a word write and a block write with - length 1, so pass the whole data block including the length byte - (if present). The device is responsible figuring out what type of - command this is. */ - void (*write_data)(SMBusDevice *dev, uint8_t cmd, uint8_t *buf, int len); + + /* + * We can't distinguish between a word write and a block write with + * length 1, so pass the whole data block including the length byte + * (if present). The device is responsible figuring out what type of + * command this is. + * This may be NULL if no data is written to the device. Writes + * will be ignore in that case. + */ + int (*write_data)(SMBusDevice *dev, uint8_t *buf, uint8_t len); + /* Likewise we can't distinguish between different reads, or even know the length of the read until the read is complete, so read data a byte at a time. The device is responsible for adding the length byte on block reads. */ - uint8_t (*read_data)(SMBusDevice *dev, uint8_t cmd, int n); + uint8_t (*read_data)(SMBusDevice *dev, int n); } SMBusDeviceClass; struct SMBusDevice { @@ -68,7 +74,6 @@ struct SMBusDevice { int mode; int data_len; uint8_t data_buf[34]; /* command + len + 32 bytes of data. */ - uint8_t command; }; #endif |