From patchwork Mon Oct 8 13:56:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10630815 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 72BD913BB for ; Mon, 8 Oct 2018 13:56:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6369F29310 for ; Mon, 8 Oct 2018 13:56:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 578502931F; Mon, 8 Oct 2018 13:56:58 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 141CA29310 for ; Mon, 8 Oct 2018 13:56:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 083F56E137; Mon, 8 Oct 2018 13:56:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud9.xs4all.net (lb2-smtp-cloud9.xs4all.net [194.109.24.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id 689626E137 for ; Mon, 8 Oct 2018 13:56:54 +0000 (UTC) Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud9.xs4all.net with ESMTPA id 9W1hgNFcWSskC9W1kggqAo; Mon, 08 Oct 2018 15:56:53 +0200 To: Maling list - DRI developers , Tomi Valkeinen From: Hans Verkuil Subject: [PATCH] omapdrm/dss/hdmi4_cec.c: simplify clear_tx/rx_fifo functions Message-ID: <3bc5d91c-89ce-1885-7b56-7e6047c7ff8b@xs4all.nl> Date: Mon, 8 Oct 2018 15:56:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-US X-CMAE-Envelope: MS4wfG+0xyGomDLJ9Gi9WqHIPmTKhIO+ywMCGL72X7hcsFgROkx0z7OG9KZWtkWouBTPw2O/3kQjvCpzQWVGYo0kpqYRDoqEM+QYV5MOhGa/UVW+KvgOnGVi rM5PhB9TdYSSq5wsuuyJjFBVf8+Q+Iy7O6kXvmQvYaRPfb1RD17zvAv0xFix/3557heIT6Nden9DKZQqNQJ9K1E9V3kJCIBo1F2aDh6AB4YxfGsaEr++qjLq 6rEctEMAXApK5m7VZcxpQPu84hU/5uqJRoG31SntoZ8= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux Media Mailing List Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use REG_GET to avoid the temp variable. Add pr_err_once if hdmi_cec_clear_tx_fifo() fails in hdmi4_cec_irq(). Signed-off-by: Hans Verkuil --- Note: the FIFOs are cleared almost immediately (after just one try), so adding delays is overkill. --- diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c index 00407f1995a8..92b55780aafd 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c @@ -110,16 +110,12 @@ static bool hdmi_cec_clear_tx_fifo(struct cec_adapter *adap) { struct hdmi_core_data *core = cec_get_drvdata(adap); int retry = HDMI_CORE_CEC_RETRY; - int temp; REG_FLD_MOD(core->base, HDMI_CEC_DBG_3, 0x1, 7, 7); - while (retry) { - temp = hdmi_read_reg(core->base, HDMI_CEC_DBG_3); - if (FLD_GET(temp, 7, 7) == 0) - break; - retry--; - } - return retry != 0; + while (retry--) + if (!REG_GET(core->base, HDMI_CEC_DBG_3, 7, 7)) + return true; + return false; } void hdmi4_cec_irq(struct hdmi_core_data *core) @@ -136,7 +132,9 @@ void hdmi4_cec_irq(struct hdmi_core_data *core) } else if (stat1 & 0x02) { u32 dbg3 = hdmi_read_reg(core->base, HDMI_CEC_DBG_3); - hdmi_cec_clear_tx_fifo(core->adap); + if (!hdmi_cec_clear_tx_fifo(core->adap)) + pr_err_once("cec-%s: could not clear TX FIFO\n", + core->adap->name); cec_transmit_done(core->adap, CEC_TX_STATUS_NACK | CEC_TX_STATUS_MAX_RETRIES, @@ -150,17 +148,12 @@ static bool hdmi_cec_clear_rx_fifo(struct cec_adapter *adap) { struct hdmi_core_data *core = cec_get_drvdata(adap); int retry = HDMI_CORE_CEC_RETRY; - int temp; hdmi_write_reg(core->base, HDMI_CEC_RX_CONTROL, 0x3); - retry = HDMI_CORE_CEC_RETRY; - while (retry) { - temp = hdmi_read_reg(core->base, HDMI_CEC_RX_CONTROL); - if (FLD_GET(temp, 1, 0) == 0) - break; - retry--; - } - return retry != 0; + while (retry--) + if (!REG_GET(core->base, HDMI_CEC_RX_CONTROL, 1, 0)) + return true; + return false; } static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)