From patchwork Thu Jun 20 11:50:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13705290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 303AAC27C79 for ; Thu, 20 Jun 2024 11:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RwiFhKj6DSEa7VQUlcxMDilTp/jRlc2Dqj2vwVcpqj0=; b=anPeSh3IMECV61k9oBzlMmqByw Abu9zUfhofqF1P+Qa61rQZjtrf36kFoIaMXt1B03/brDv2RVzQM2Zn8ZlZXVsoHRLuCJhgMo4Gw/S OZS1af9i1s0mFzXZuB+FRTzg17id/oHyF+NJi5eb+q05eNTtTqAK4J9NNNtZ0++o0jmK4+J7qr4jr iDrHA89qRVccD8Up3fQ33WwZbSQ7G6ZNAuhpontWvHTxvyaR5fOaPSoE9m9D4mAzPFH6Y5DXSe8E4 jpe6gdaowqsxswm1GjRCM0RSYPpFv9UbQU1IEm4ocIpA287O8NonZJ0neXF2lFTurMPYWWY89jd8j Y5kGYAJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKGJM-00000004qyP-2KJ4; Thu, 20 Jun 2024 11:50:40 +0000 Received: from zeus03.de ([194.117.254.33] helo=mail.zeus03.de) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKGJD-00000004qvT-1C0I for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 11:50:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=RwiFhKj6DSEa7VQUlcxMDilTp/jRlc2Dqj2vwVcpqj0=; b=Vlt3Tn 2Do8jfLoK1eRL4FgWZISar4kfzMU8gde27BdiSj8lgTTxmhI3UJFq11TCRUvR6tZ Pbsq6E/E3CZBgfdazgX8Q1vjsi/qXow7oDmaf0Qd6dOambnNHXMmMasDxNAA3Ipn VT8megWPDDrnHORl3mVY7k4WpUImipilMeymCFdIi3WVy9kwFfJmUCTMtIIg/JkM 5X+0MDgoErhr2Rppndy/u5YsghEhi70zSvfzGERH+aQqP2yE1SHxR2UA1uPF3Maj f4gTadjm+Nm6WVGltCVco4BB3Q0EI9HBlxm2xXT8zYR8OEqENAwRG98C38FB3Y1U 4MYuFRmbtK6gkLAg== Received: (qmail 1002835 invoked from network); 20 Jun 2024 13:50:25 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Jun 2024 13:50:25 +0200 X-UD-Smtp-Session: l3s3148p1@pg+p61Ab3JMgAwDPXzjQABqqX1QYyOSW From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Michal Simek , Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , linux-fpga@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/2] fpga: zynq-fpga: use 'time_left' variable with wait_for_completion_timeout() Date: Thu, 20 Jun 2024 13:50:22 +0200 Message-ID: <20240620115022.24409-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240620115022.24409-1-wsa+renesas@sang-engineering.com> References: <20240620115022.24409-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_045031_618707_72ABACA9 X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Signed-off-by: Wolfram Sang Acked-by: Michal Simek --- Change since v1: added ack (Thanks Michal) drivers/fpga/zynq-fpga.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c index 0ac93183d201..4db3d80e10b0 100644 --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c @@ -387,7 +387,7 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt) const char *why; int err; u32 intr_status; - unsigned long timeout; + unsigned long time_left; unsigned long flags; struct scatterlist *sg; int i; @@ -427,8 +427,8 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt) zynq_step_dma(priv); spin_unlock_irqrestore(&priv->dma_lock, flags); - timeout = wait_for_completion_timeout(&priv->dma_done, - msecs_to_jiffies(DMA_TIMEOUT_MS)); + time_left = wait_for_completion_timeout(&priv->dma_done, + msecs_to_jiffies(DMA_TIMEOUT_MS)); spin_lock_irqsave(&priv->dma_lock, flags); zynq_fpga_set_irq(priv, 0); @@ -452,7 +452,7 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt) if (priv->cur_sg || !((intr_status & IXR_D_P_DONE_MASK) == IXR_D_P_DONE_MASK)) { - if (timeout == 0) + if (time_left == 0) why = "DMA timed out"; else why = "DMA did not complete";