From patchwork Mon Nov 26 20:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 152065 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp320776ljp; Mon, 26 Nov 2018 12:18:02 -0800 (PST) X-Google-Smtp-Source: AJdET5do7sBda77ZoT3ISYvnvmsZqej4204xJ4dNiYMxyPAa/89P0RvACnsOJ0z29cZ71N1CQWD+ X-Received: by 2002:a81:2b89:: with SMTP id r131-v6mr30595747ywr.286.1543263481883; Mon, 26 Nov 2018 12:18:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543263481; cv=none; d=google.com; s=arc-20160816; b=wcPYcujwAOW6nPgA7CBkSaxC+FgOvH5jGSPVXyCjlBVBNHgaxvW/5OEU9kKidBv1Yy c4KqwQbEz284oAWS13GMs7msk01wlxGNjxXcDHMogKsuht7BEHwu/TWlaJeT/OuBOxPX wtXxUr6xERQPpOvmnEQRDLVZNni7E1v3xzkBwtbBR8URBSI6ymgZ+Ph8U8WBs3j9EAue tWcLLGRXNQFsczU3UHCzEo4nZjuZCflkBUqCSBvd1T75GHprpjPsr+FlgwiyMFqcL79d E0YjMKtaGTYaBDjg80cp8FkhWtSg3QNJBhOioFynTf9xGGwmaREgzj3ntETP+RCqunGb /iGw== 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=5scURFf7MQR79d3Vhp21We8AvBn0IVcgqCVyOuH/t3M=; b=Gsea0GLuVh0YdwoF00jtjjGPaRVoQjilsI8E5Li87TrWG2/vzeGlcK8xuI1tmmGfyg 49sQaayvQ+B8kASMMjDOvoTUzIM9zETXKxhpTmky4Ccr1MD9eLWhJLUGsKsDZEkefphX luwiTCSGXEQZRYmHVTDujEkMlUAJeXqy4SEFr6e3VszPG2hpI14Vn4xKFC9KDivP0oGr 95LHH07TTe1uoBLcX2hlS2V3jm4YvJqj3LrYlDXlNESuKYlfVvcrbvvq+75EObNTWbmK WPzSL+HW3eatoFKscg5xRoMcX5MA2xXNQ/Tq2YsEK6tWAd47bIQwN9a1fAYf5UuDxc6z Xgqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aDiAiQ6B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m25-v6si918897ybj.422.2018.11.26.12.18.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 26 Nov 2018 12:18:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=aDiAiQ6B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNKT-0004kR-8F for patch@linaro.org; Mon, 26 Nov 2018 15:18:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRN81-0001lB-B0 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRN7y-0001LK-P2 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:09 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:39931) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRN7y-0001GT-C7 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 15:05:06 -0500 Received: by mail-ot1-x343.google.com with SMTP id g27so17863159oth.6 for ; Mon, 26 Nov 2018 12:04:51 -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=5scURFf7MQR79d3Vhp21We8AvBn0IVcgqCVyOuH/t3M=; b=aDiAiQ6BE0BaYn3vF4wIaAYS5Ly1X2IywE1x+LFG/jilhbwGD5ozs2hiy3OTD0tra/ z5MEbrHEbLlIa1zfze5hKS6CV6NOTwfiAm3gQwiYzB6t4g/KxO6lAsvzDcJVt5pXxYay xqF1ZUxTOllCzZpHBQ9x+67IU4jTEf4f+r3tcJKo/bwGbHN62NUGY4hE+5YQ3IxQ3iIk xIYZJNkvsY3qG+lYo9BwA1JNGbIZqoMRwJpaCpP+btvYgwtHISPx3DVvc8LhOp+uB+6X z/Uibuf6dfYVGUQUUz3IN5NHvgVSgwDftOvO6r/q++/FdxcIL/3X6rm9r8C3EUinGNiY x31A== 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=5scURFf7MQR79d3Vhp21We8AvBn0IVcgqCVyOuH/t3M=; b=gFsVHkHalYxfj+TSQ6LWOxrldVB9N2qMz1juwDm8SNfZxSFwDBaupGbioMaiv5CvLO +411owu3wFxdjrASqz3+1nCn5Rc5KygF6V62Fnu5A5RsPbz0q2PQhbqle81VH9bI5tyk 4YbKLNo05Yp1KbHBB0hUZfV4q38rx8UbPXBG7vTj73HuvX0NeMqnjjtlUL66mipSu+fj ujI9Oel5Yq8RCaKTTxjZ1QJUjd9kLR1dHsDuWnC0n2G5CAN3AJyoeR6wm7OpLcro27qF ru5DPHT7SK1tPRUz5NxM8xPOHg8TRq6P7/k6jxDxS+wj/z2hcSxaT0fH5NVACCpzgRG0 1PxQ== X-Gm-Message-State: AA+aEWbmbISavwIm2HN78/oItLct7E0sEwnEyVMmFeYf1Nm7VLyhqC5h l3brsaHQnbijHELHhETnxQ== X-Received: by 2002:a9d:a78:: with SMTP id 111mr11793472otg.229.1543262690906; Mon, 26 Nov 2018 12:04:50 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id w4sm388529otm.46.2018.11.26.12.04.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 12:04:49 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id CB851ECD; Mon, 26 Nov 2018 14:04:47 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 2509E301464; Mon, 26 Nov 2018 14:04:46 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Date: Mon, 26 Nov 2018 14:04:23 -0600 Message-Id: <20181126200435.23408-5-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181126200435.23408-1-minyard@acm.org> References: <20181126200435.23408-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::343 Subject: [Qemu-devel] [PATCH v3 04/16] 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: Paolo Bonzini , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" 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 | 4 ++-- hw/i2c/imx_i2c.c | 12 ++---------- 3 files changed, 6 insertions(+), 19 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..43f284eab7 100644 --- a/hw/i2c/exynos4210_i2c.c +++ b/hw/i2c/exynos4210_i2c.c @@ -106,12 +106,12 @@ static inline void exynos4210_i2c_raise_interrupt(Exynos4210I2CState *s) static void exynos4210_i2c_data_receive(void *opaque) { Exynos4210I2CState *s = (Exynos4210I2CState *)opaque; - int ret; + uint8_t ret; s->i2cstat &= ~I2CSTAT_LAST_BIT; s->scl_free = false; ret = i2c_recv(s->bus); - if (ret < 0 && (s->i2ccon & I2CCON_ACK_GEN)) { + if (s->i2ccon & I2CCON_ACK_GEN) { s->i2cstat |= I2CSTAT_LAST_BIT; /* Data is not acknowledged */ } else { s->i2cds = ret; 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;