From patchwork Wed Feb 20 13:59:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 158821 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5063333jaa; Wed, 20 Feb 2019 07:37:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJ3SWxzHgfE6aJkVA+zZxrx7qVAtRWSmNhUKjQTALZCI3YnwIDrho6MLmh9jK6ojnQWbBS X-Received: by 2002:a81:4e82:: with SMTP id c124mr29022290ywb.277.1550677020507; Wed, 20 Feb 2019 07:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550677020; cv=none; d=google.com; s=arc-20160816; b=u8NkZrioYbEgjydcwV8LAtjbeQEfM0ZRvEcuAXmK+bUsKsPklQ2NVxeET78iu8kkoW BF9kseA/7K6ScdKoNgmzIgOaCUtC4LGl0WoXiNF57NVGPuB5+7jveQSGec/Hnni19rNM +oug2vG/5M0JzgAd6+Gevx0hJP9OU69Ta8koxjWkaAovwSbDRRWLKahtuyd1GX9d2CNy jaNjLDVWwObeq2AGucIKDh54S08BahBbjrz8v+hR7OsygR26Ed94pWuIp6Og+3DOhZTR BfLDsdZKTFnbxVfVE4cWlMjznB4X3wO58iZ0FLqDf63MeCtrFSfvrf4xaWCnlk7S5djd ezYQ== 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=goF/+B6PVxcycg82kXeNDMO9X5wcycyJ+ZFAarZEKhJsw+9O0jl7J17BnpZRUiDgbz l6ydLbZB61z99Ajs2X3KgtjUxas3ShKcPbty8Fhs/L1WIGELNSaR3TZzUdmve6ykkwFU Sd3d84Id+TcnCaJOwsE5QoumNSy1czYeKPktjsIU+BVqMmc61jILQDcjBmcdT/A22PLq tbMjRGrzrofFg8m5J+4amHQDX9yPIkaxiv8cD5/lAPhAhX+FX2pzu+jyQQUSJk0A0bfC 2XwivCbntpMYfcMm5ViR3d/KevwRCXJx0Hl8VxWxcC4OcNc5nO6pKAYMB/AZ4lBp9l6x nliA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QzSy7FpT; 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 y11si11584739ybm.40.2019.02.20.07.37.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:37:00 -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=QzSy7FpT; 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]:41003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTvf-0001VI-Up for patch@linaro.org; Wed, 20 Feb 2019 10:37:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTkF-0000As-RE for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTkB-0007kR-8o for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:10 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:35291) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTk9-000781-4r for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:25:05 -0500 Received: by mail-ot1-x341.google.com with SMTP id z19so40799313otm.2 for ; Wed, 20 Feb 2019 07:23:29 -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=QzSy7FpTT2GmJk5slseBTgiprHjwUOKccL5cagCLcu4SFnRqNpj32MV1nYY/facvlm 2SqBtuMXgg4zmlYelD9SF95b4wMv/m9h2fzXtdJ5G8DmBn9BTcPqkBqJdPsw8WV/PHY1 KWmC1niVTtov11+23kuwmIpLGzNJwqwydABa9L6JKipD7EVQWDVK2F9domAlPV/BwBwR iX2aaG0V5HgUAGKs9/WdSRS2ZupBowT9zmrwjEWK7qo9swVoPiGq1JZTQsI5AbKw6Sh4 WgmcSibNv10ArWPoXgKpFPjxMwnVxUXp9D4e24CvUtHK/pb9I/Unao1o1XHmO+5L2R/e uAPA== 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=l35gXx03xPJFJZ92SLPwLJHlzZSFhjHWZmPp8mqTyuo5M7D0EQhluLq6+dc0fJ3DbM aR63mmh7rliTvgnxKGHFw6JtagFbdLTGn97RG8tXp6SE3vjoGZShc8ShDw2BYlJHjJjQ KNNyRVF41hRA4w2sdOmdEVvcT9VZtlaHRW1b5+VWMOJMMfFzfVljsG5Gf3Mm5OqGZ+1q NwldXad78fC47bdxFsnltxQy5owjZlkdrZeg+yut44cszYBnWX/vA8lEPSm5+W9rKxzD P9LlYPkHpIDlt0430lThLL7ebwqyUDXa70yba1+lBce7IVrSXYwa23z7sWnt4My/Oa61 yCCA== X-Gm-Message-State: AHQUAuZLEBS244H+3UG8YZ0WRN2Qw2jkd0tGD7sZugGQdZaQv+13TYvM o0McTQ+dkaD00wVECYdgADE4bNHgJg== X-Received: by 2002:aca:ed06:: with SMTP id l6mr6001608oih.7.1550671213411; Wed, 20 Feb 2019 06:00:13 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id k100sm4694695otk.5.2019.02.20.06.00.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:12 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 361D11808F4; Wed, 20 Feb 2019 14:00:09 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 12FB4302A62; Wed, 20 Feb 2019 08:00:07 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 07:59:41 -0600 Message-Id: <20190220135956.22589-5-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220135956.22589-1-minyard@acm.org> References: <20190220135956.22589-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::341 Subject: [Qemu-devel] [PATCH 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 , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , Paolo Bonzini 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;