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: 10699117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0038C14E2 for ; Mon, 26 Nov 2018 20:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A312A06B for ; Mon, 26 Nov 2018 20:19:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4EF72A12E; Mon, 26 Nov 2018 20:19:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52F232A06B for ; Mon, 26 Nov 2018 20:19:12 +0000 (UTC) Received: from localhost ([::1]:38625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRNLb-000616-C5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 26 Nov 2018 15:19:11 -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-Google-Smtp-Source: AFSGD/XD6PZQqnJPEOprgC1H2zO3SQfJfBomW0HElJyX4FUO5ZEwc+Umg6nWrAxoQ9KaJElazHGVNA== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;