[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/19] i2c: Don't check return value from i2c_recv()
From: |
minyard |
Subject: |
[Qemu-devel] [PATCH 04/19] i2c: Don't check return value from i2c_recv() |
Date: |
Wed, 20 Feb 2019 07:59:41 -0600 |
From: Corey Minyard <address@hidden>
i2c_recv() cannot fail, so there is no need to check the return
value. It also returns unt8_t, so comparing with < 0 is not
meaningful.
Fix up various I2C controllers to remove the unneeded code.
Signed-off-by: Corey Minyard <address@hidden>
Suggested-by: Peter Maydell <address@hidden>
---
hw/i2c/aspeed_i2c.c | 9 ++-------
hw/i2c/exynos4210_i2c.c | 8 +-------
hw/i2c/imx_i2c.c | 12 ++----------
3 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index a2dfa82760..a085510cfd 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -189,16 +189,11 @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus)
static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus)
{
- int ret;
+ uint8_t ret;
aspeed_i2c_set_state(bus, I2CD_MRXD);
ret = i2c_recv(bus->bus);
- if (ret < 0) {
- qemu_log_mask(LOG_GUEST_ERROR, "%s: read failed\n", __func__);
- ret = 0xff;
- } else {
- bus->intr_status |= I2CD_INTR_RX_DONE;
- }
+ bus->intr_status |= I2CD_INTR_RX_DONE;
bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT;
if (bus->cmd & I2CD_M_S_RX_CMD_LAST) {
i2c_nack(bus->bus);
diff --git a/hw/i2c/exynos4210_i2c.c b/hw/i2c/exynos4210_i2c.c
index c96fa7d7be..d154b05739 100644
--- a/hw/i2c/exynos4210_i2c.c
+++ b/hw/i2c/exynos4210_i2c.c
@@ -106,16 +106,10 @@ static inline void
exynos4210_i2c_raise_interrupt(Exynos4210I2CState *s)
static void exynos4210_i2c_data_receive(void *opaque)
{
Exynos4210I2CState *s = (Exynos4210I2CState *)opaque;
- int ret;
s->i2cstat &= ~I2CSTAT_LAST_BIT;
s->scl_free = false;
- ret = i2c_recv(s->bus);
- if (ret < 0 && (s->i2ccon & I2CCON_ACK_GEN)) {
- s->i2cstat |= I2CSTAT_LAST_BIT; /* Data is not acknowledged */
- } else {
- s->i2cds = ret;
- }
+ s->i2cds = i2c_recv(s->bus);
exynos4210_i2c_raise_interrupt(s);
}
diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c
index 6c81b98ebd..6da5224e2e 100644
--- a/hw/i2c/imx_i2c.c
+++ b/hw/i2c/imx_i2c.c
@@ -120,7 +120,7 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
value = s->i2dr_read;
if (imx_i2c_is_master(s)) {
- int ret = 0xff;
+ uint8_t ret = 0xff;
if (s->address == ADDR_RESET) {
/* something is wrong as the address is not set */
@@ -133,15 +133,7 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
} else {
/* get the next byte */
ret = i2c_recv(s->bus);
-
- if (ret >= 0) {
- imx_i2c_raise_interrupt(s);
- } else {
- qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: read failed "
- "for device 0x%02x\n", TYPE_IMX_I2C,
- __func__, s->address);
- ret = 0xff;
- }
+ imx_i2c_raise_interrupt(s);
}
s->i2dr_read = ret;
--
2.17.1
- [Qemu-devel] [PATCH v5 00/19] Fix/add vmstate handling in some I2C code, minyard, 2019/02/20
- [Qemu-devel] [PATCH 07/19] i2c:smbus: Simplify read handling, minyard, 2019/02/20
- [Qemu-devel] [PATCH 19/19] i2c: Verify that the count passed in to smbus_eeprom_init() is valid, minyard, 2019/02/20
- [Qemu-devel] [PATCH 15/19] i2c:smbus_eeprom: Add normal type name and cast to smbus_eeprom.c, minyard, 2019/02/20
- [Qemu-devel] [PATCH 04/19] i2c: Don't check return value from i2c_recv(),
minyard <=
- [Qemu-devel] [PATCH 10/19] boards.h: Ignore migration for SMBus devices on older machines, minyard, 2019/02/20
- [Qemu-devel] [PATCH 05/19] i2c:smbus: Correct the working of quick commands, minyard, 2019/02/20
- [Qemu-devel] [PATCH 17/19] i2c:smbus_eeprom: Add vmstate handling to the smbus eeprom, minyard, 2019/02/20
- [Qemu-devel] [PATCH 11/19] i2c:pm_smbus: Fix pm_smbus handling of I2C block read, minyard, 2019/02/20
- [Qemu-devel] [PATCH 03/19] arm:i2c: Don't mask return from i2c_recv(), minyard, 2019/02/20
- [Qemu-devel] [PATCH 09/19] i2c:smbus: Make white space in switch statements consistent, minyard, 2019/02/20
- [Qemu-devel] [PATCH 12/19] migration: Add a VMSTATE_BOOL_TEST() macro, minyard, 2019/02/20
- [Qemu-devel] [PATCH 16/19] i2c:smbus_eeprom: Add a size constant for the smbus_eeprom size, minyard, 2019/02/20
- [Qemu-devel] [PATCH 01/19] i2c: Split smbus into parts, minyard, 2019/02/20
- [Qemu-devel] [PATCH 02/19] i2c: have I2C receive operation return uint8_t, minyard, 2019/02/20