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: 159414 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp980423oce; Thu, 28 Feb 2019 10:25:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwtXJFQuLrbU69bJMaaj8BSoOJnRnC+AsqKnIFwUEBOoAtVQzlPivB08SbXB5fQKANIMslT X-Received: by 2002:a25:9945:: with SMTP id n5mr681269ybo.453.1551378305185; Thu, 28 Feb 2019 10:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378305; cv=none; d=google.com; s=arc-20160816; b=U5zNB2jtVaXpy24oMY1HCnZuo0IHkYT1AktNYnPqULWHK0zwK9V4soV5QgJt8JaNGt 2vNOpgHwXBd5G3YiD0DP4aifXSM+icrg9dLsRuILEaDbnKpJK1jB862UPnuogn3J1edm gUV4ZDPoX9Awo7uQ+FnCr0GzARVmisgqhjG29Mdomqqzj1cYE77VIVHFTKstDN10COao 48PxsYK897z4lY4WSjyjItP+TRLYoNKDbzL1WdsOcLEwY0XXasX5pn4B5ZYBCfZnFnGe Afi6ovCC6UzwmeNXPvs3XM7bVPUSOh25aaIsD1z4tn4wQHxS/6tspbooUioBDalItcx6 eNwQ== 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=qPZTrux2FuZo244ksz5wHGl5ATzL7oAMZ8aoii306r4FecjPy2Q/t4JoG6+Ve7zec3 ee6U5hA2IpSw1/f9lSUxFRgmy2EWDWU8MfwMxqUKAh0yk69nwlal8+4b4dwNlOQ+Jl5o hTCnIkhr5CbTFZYz6UqcyR4pzAj/bzkLcyg0lLfSE0E0N6CL1Y/D18fCENFDe4p5C63P 6/5UYd4Y72atJ3XL7TKiwIAxELyBIKH8AlVKioU/XeNKB/RmgSVFGP6DVx1XceeTbrvm EqFym5NT/YpTI275ZGqjIUPtyRYoeUR6e3Mm0rduiP97b9TmOpjxX1w2/OPHr4G7yzil D9ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=biQRL1ou; 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 d15si11201772ywb.64.2019.02.28.10.25.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:25:05 -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=biQRL1ou; 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]:44580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQMi-0005eM-NT for patch@linaro.org; Thu, 28 Feb 2019 13:25:04 -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-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+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;