From patchwork Thu Feb 28 18:16:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 1049682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="biQRL1ou"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449LZj24ytz9s2R for ; Fri, 1 Mar 2019 05:25:33 +1100 (AEDT) Received: from localhost ([127.0.0.1]:44580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQN9-0005eM-5a for incoming@patchwork.ozlabs.org; Thu, 28 Feb 2019 13:25:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFi-0000XR-8w for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFY-0002Jr-D4 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:50 -0500 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:42340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFY-00029S-6X for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:40 -0500 Received: by mail-oi1-x243.google.com with SMTP id s16so17258412oih.9 for ; Thu, 28 Feb 2019 10:17: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=biQRL1ouBMgkMhP1pF06EvuEp23+bmz1L6gdHU3f9Fw5tWlUrh2tYiLFYGbvqOx8lt 3UpSdLNOUQmvsoGoX3A2R2YGlcJrdTkRNf0R/h+erGg/NMIYUhjfZJSlKzqGNnM/HY6t yp7wr4Ahs3XiNNWON+BnI6WkhExTOuto8S4dQTraRlTayS82oGJZK6u9ZUxLua93mCes X5KZUxl4WDNnMx/vAjZBF8o2+22t8TErK4rggq3YFcjCQ3BfFcWdTVROBOQopPDWXMRb Bi48RHjKFVlh1U+79DivdbdM8S9nFI14VhxyKvOrG45WFfwnXz1OS0yRJhrQ9cUzKgo6 ovMA== 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=X27yTgbV7NQjQBc9jOuRNI7tda0fIeFGCPKOgasXjAhcUjelZ+RMowLZQTkdd6Xf0l cMyT4R9TXzmF0h1Bth7I/D7YuJmWC4msooQ9oB/SkVsh+G+3kG5rMNMlugsESRfqnfCq BCo7d9eOQnfbsiXWFMCM2chzSX/6Rt3UxIZ5dr2aP5B8cs4JnSNJHDXgq1x6t+BDrBMk zCdd0P6iMGRQKZWWiM6UIcLBBwVtv/HD6u6L5ce31R6vlzfSIfcjjXW8TKWKDdC7ldum 6Kpb+cviz/gAmfCP24eFaXUkfGjvr0SlKuMCtVwQ1PvY1aLCmKRo8Zofv/SIETro2QFw 9v+w== X-Gm-Message-State: AHQUAubJuIG2ckvPUGrOCvL0fCoQoEyCRbyEomGb/ruhWzY+g1usjVjb aEANg7sj/+dI/hHvJpSxsQ== X-Google-Smtp-Source: AHgI3IYFfm3PSUHPUC2fs774U0Rgnh2OR/B0KgaozdT+rO/vvLPHJDnK58vmVhXp3sBs+KZTPaHb1g== X-Received: by 2002:aca:c1c6:: with SMTP id r189mr672668oif.179.1551377836060; Thu, 28 Feb 2019 10:17:16 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id n187sm8061145oia.34.2019.02.28.10.17.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:14 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id B01661808ED; Thu, 28 Feb 2019 18:17:13 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 6DAA9302AF6; Thu, 28 Feb 2019 12:17:13 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:16:55 -0600 Message-Id: <20190228181710.2477-5-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-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::243 Subject: [Qemu-devel] [PULL 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: Corey Minyard , QEMU Developers , minyard@acm.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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(-) 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;