From nobody Mon Feb 9 03:13:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550677141237690.8761248747116; Wed, 20 Feb 2019 07:39:01 -0800 (PST) Received: from localhost ([127.0.0.1]:41030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTxY-0002mV-7Y for importer@patchew.org; Wed, 20 Feb 2019 10:38:56 -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) 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) 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-Google-Smtp-Source: AHgI3IbTp6h9ZKlRfWjWFk7+6bI5Z5XMTS876XLOtm2TqCskNjo2mrOokNN2XAtjoZznOeZmpe3goA== X-Received: by 2002:aca:ed06:: with SMTP id l6mr6001608oih.7.1550671213411; Wed, 20 Feb 2019 06:00:13 -0800 (PST) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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) =20 static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) { - int ret; + uint8_t ret; =20 aspeed_i2c_set_state(bus, I2CD_MRXD); ret =3D i2c_recv(bus->bus); - if (ret < 0) { - qemu_log_mask(LOG_GUEST_ERROR, "%s: read failed\n", __func__); - ret =3D 0xff; - } else { - bus->intr_status |=3D I2CD_INTR_RX_DONE; - } + bus->intr_status |=3D I2CD_INTR_RX_DONE; bus->buf =3D (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(Exy= nos4210I2CState *s) static void exynos4210_i2c_data_receive(void *opaque) { Exynos4210I2CState *s =3D (Exynos4210I2CState *)opaque; - int ret; =20 s->i2cstat &=3D ~I2CSTAT_LAST_BIT; s->scl_free =3D false; - ret =3D i2c_recv(s->bus); - if (ret < 0 && (s->i2ccon & I2CCON_ACK_GEN)) { - s->i2cstat |=3D I2CSTAT_LAST_BIT; /* Data is not acknowledged */ - } else { - s->i2cds =3D ret; - } + s->i2cds =3D i2c_recv(s->bus); exynos4210_i2c_raise_interrupt(s); } =20 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 offse= t, value =3D s->i2dr_read; =20 if (imx_i2c_is_master(s)) { - int ret =3D 0xff; + uint8_t ret =3D 0xff; =20 if (s->address =3D=3D ADDR_RESET) { /* something is wrong as the address is not set */ @@ -133,15 +133,7 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offs= et, } else { /* get the next byte */ ret =3D i2c_recv(s->bus); - - if (ret >=3D 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 =3D 0xff; - } + imx_i2c_raise_interrupt(s); } =20 s->i2dr_read =3D ret; --=20 2.17.1