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: 10784319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54B6B17E9 for ; Mon, 28 Jan 2019 18:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 432732B777 for ; Mon, 28 Jan 2019 18:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36D9E2B8E0; Mon, 28 Jan 2019 18:18:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3C8D2B777 for ; Mon, 28 Jan 2019 18:18:24 +0000 (UTC) Received: from localhost ([127.0.0.1]:36446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBUG-0000Wy-1L for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Jan 2019 13:18:24 -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-Google-Smtp-Source: ALg8bN4+EY/0L9keRW7yOXCoD4wlv2aAq5UZaCbjeQ8N4pFQbywCqvnq3T9G9FVetq4oHnND15Ta+g== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;