From patchwork Mon Jan 28 17:54:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156848 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3732317jaa; Mon, 28 Jan 2019 10:17:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN42eG8YMw3guapNKuN1U/uW6jsvMJyT2nwdq7rOR60ih7IGFwOnvZLSjuOcKpDz0q3oEyFd X-Received: by 2002:adf:fc09:: with SMTP id i9mr21912014wrr.299.1548699433764; Mon, 28 Jan 2019 10:17:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548699433; cv=none; d=google.com; s=arc-20160816; b=mSvBQjLGEemeBUzxwoKUZqUJTdFiQBYTRsHuIF+s7xfqTnQkBUFfy4HgNV9oXp3QDa J0xi9ysbqwpqjfvCycWDlLyBLTgC4YnoQWJWi0sEmemePpvgergvI3Gn3M9CHuFwVG+y uWJbAwBJzOVVo9AEec/MisGVw53OkQ+bRXKlvO2CtZmxg7irGqOXj4dOwA4L+or7JOs6 NjQfDeKl46AFNYI60aqbYCKFgRJdavKe7K7Gcc9WYvbAfTvkoilHGQM3XR+aY+maoJSU yaUjcf0kXm44B/wJulJtB1vKQOWNcoUS5pE+cR70XRbVV3tLoXCP7p2jv+YGIVqpcT9b a1vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Excm8HgHGnquQpA1JYPDe1clppMYhUvhbZU4Zai+sO0=; b=FNiQrRlEMmtgedliCfGvZiRfNP/9M+/UA9Sr0bLmgvKTpKX6EcVkbdjmRCwjYyEmg1 2TkVbJ4ozL/loQs8RPhQOkfR25spqKwA6XxTqY8+eWSqrpxD1+p/5v4yOX/Z5jKfc68G ie3AvW5UVtz9PVueCFEvIbpP9Tu1fB7FdKoulO3c+J7PJP4w+97toksuoeGBO2Oucflk enRaRuFvQaPnVLHOl4+dKAP1KZ/1ztCyW4I/X/v9oT0HBVq1gX4kXuXfbeOcVj6QrCx8 t+DpCT6oDopRMiefkEZTSvf/ARKzHxPZoonM2ty6zs52Ke3tiaW/FK3DQ09aU23ovnR/ uDtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z5BqRhln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i81si114948wma.22.2019.01.28.10.17.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:17:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z5BqRhln; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:36436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBT6-0007o8-E4 for patch@linaro.org; Mon, 28 Jan 2019 13:17:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBEH-0003b9-CN for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB7t-0005Xf-N9 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:30 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:40764) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB7t-0005Wz-GV for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:17 -0500 Received: by mail-pl1-x641.google.com with SMTP id u18so8063320plq.7 for ; Mon, 28 Jan 2019 09:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Excm8HgHGnquQpA1JYPDe1clppMYhUvhbZU4Zai+sO0=; b=Z5BqRhlnyh/TpdMF4nGoNNnqX90BWQtbmiuxU221nj2J6+iR/NsSw5tJVBlfpgoWlK 9Am/vYW3hA9P1zqtBQjKak7SIwYfigNtGmJZ2n7vvXIqmYXv4sW1gT7+vTNHkRy0N3Ps z8d5upHhvayEYvISJt1I9zTSIWBNK8mpuSTxiYZ5PP9+TF43wMjqA+31uFanmjWIKMHx EffYi+5IdybIc5yk7vivaK6P3Cfh1+D+tx9SaXYHng3VKpiNJQ9FyIjmELHAb8HZSG8O 7vlq905n7Al3ujqJcjfSiAGdE4El8FG97rjYlBmRERTvK4w6rLVxwPDb/zDjmpjPc8cA y7CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Excm8HgHGnquQpA1JYPDe1clppMYhUvhbZU4Zai+sO0=; b=Rn5/sYQg2sEtn0Qommz8jamrVslP3O2wA7Ne9uxXtReM6GZeMIz01fyTTlzsgQGQcC YhxB03F1i0SItbvqGVfgoT8b1xzbZOdDVCCM44l4jg9DBH0IPDt/Qc386gTBx3WdSQz+ 7EdtZL6S1rF4BWW7Dou1Zqj8R5xdJG/ICjAjuZKFhvQd0ya7y4PeGNont+VeUhcQb5pt vrRCxJnSh7hsFiAKf2TUu+KSQNOAAZkQ5TlNkA3yKPBMI2uv5CaFY493mAu0ucLSgw8L wIJLhX/T7ow/k4Q7ixpHFvCM8mQVqXF7qxyhHp9TuVoapLmEa4zFgdWthyllq+ZQERwb XoFA== X-Gm-Message-State: AJcUukffy1Yd867XuIHaSsVIthdKwbx5kXWW5Q5k4eIGEif/E1uK99LS 3lP9AkGrNv5hwb++nHVSsg== X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr23026441plo.50.1548698116056; Mon, 28 Jan 2019 09:55:16 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id 128sm56630272pfu.129.2019.01.28.09.55.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:13 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id 6CC86CA8; Mon, 28 Jan 2019 11:55:12 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id BCC3E30115A; Mon, 28 Jan 2019 11:55:07 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:43 -0600 Message-Id: <20190128175458.27255-5-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v4 04/19] i2c: Don't check return value from i2c_recv() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard 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 Suggested-by: Peter Maydell --- 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(-) -- 2.17.1 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;