From patchwork Thu Jun 20 11:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13705279 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC0D41AAE2E for ; Thu, 20 Jun 2024 11:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718884230; cv=none; b=cjI40i4udC0GaDlgePD9HVi8YteifXrJF2VTTgQvueEM0OEbtVzEPn67TRupHi8gUpoTeZ9eR3zpjWLVLyAzg787iZM2WUwgHxcqUXfk31xRHh7+/W003u6iYbph23JLLPzVh+eemG/3BnVf5fLNsljwDnB/Bh/wgE0lS+QZsUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718884230; c=relaxed/simple; bh=iOzVDw446sjQ+BfSiKI2J7kMH91mM90U6cJySi28zac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h+o2G+NRURz1c7J7dLHQw6fW1Vy930utwxIZLmGirNno7aBULXkcZJl+p+CrW/qME8QGZxVJfPBborr0+8e/c7/BVX6eDOhlge16PRKknAaGDZ9giMHKvdIEf1m8eCxsNC3rzWZkLN8GWa53FIRNu8FPoOp5P2idknLHty/Sjps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=Gqa7xL3w; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="Gqa7xL3w" 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=hhjBD+ima6QVHIrHeWwX9nW5Tqwsw/JyzTU2SbaYaPA=; b=Gqa7xL 3wzoIEK1N1y4BRR/HTbfsx9hVIkHOj7ZNq8QOmeT10XtxyONiu3clghhsrqyW1p0 tR8/kbcQLkFW0AryJJzT4TvU+BI97J8cTHBl1MwVA5uTkYgxpwsyA9VFD0FkNp3Y ju5tdUp3RRtljL68wkXNVQKsGjm3oMwa6dn/9h7CmIMazCEoE9y2r49MDSK7/niw 7jbsEde/C1eg/7i7HQv6y0GsOu7Rw+xlYYPs9P1At/WFikBkZAMgvQczRcR38i8M 6If5LFFsJShsiLqzujggiKcqNKw+fKwuPpgTpym9Ox2FusxXSucrs0rYs/wquN2h W5z0VrvUAHrxk7/Q== Received: (qmail 1002798 invoked from network); 20 Jun 2024 13:50:24 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 20 Jun 2024 13:50:24 +0200 X-UD-Smtp-Session: l3s3148p1@C/+b61AbzpMgAwDPXzjQABqqX1QYyOSW From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , linux-fpga@vger.kernel.org Subject: [PATCH v2 1/2] fpga: socfpga: use 'time_left' variable with wait_for_completion*() Date: Thu, 20 Jun 2024 13:50:21 +0200 Message-ID: <20240620115022.24409-2-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> Precedence: bulk X-Mailing-List: linux-fpga@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_interruptible_timeout() causing patterns like: timeout = wait_for_completion_interruptible_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Fix to the proper variable type 'long' while here. Signed-off-by: Wolfram Sang --- Change since v1: * use reverse-xmas-tree for variable init * keep chars/line limits in commit message drivers/fpga/socfpga.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c index 723ea0ad3f09..f772b754aa76 100644 --- a/drivers/fpga/socfpga.c +++ b/drivers/fpga/socfpga.c @@ -301,16 +301,17 @@ static irqreturn_t socfpga_fpga_isr(int irq, void *dev_id) static int socfpga_fpga_wait_for_config_done(struct socfpga_fpga_priv *priv) { - int timeout, ret = 0; + long time_left; + int ret = 0; socfpga_fpga_disable_irqs(priv); init_completion(&priv->status_complete); socfpga_fpga_enable_irqs(priv, SOCFPGA_FPGMGR_MON_CONF_DONE); - timeout = wait_for_completion_interruptible_timeout( + time_left = wait_for_completion_interruptible_timeout( &priv->status_complete, msecs_to_jiffies(10)); - if (timeout == 0) + if (time_left == 0) ret = -ETIMEDOUT; socfpga_fpga_disable_irqs(priv); 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: 13705281 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B484B1ABCB1 for ; Thu, 20 Jun 2024 11:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718884231; cv=none; b=rn4h5hwsraO2T1zve9Fo6DcgQXH152R1QMIju9KqI+I6r812htxuvFAsyxmEFkHp3cdeHDQrp6Uz2bc6sDbGEbidv+iHLFUad+jPIz9pkRXOeb9gcnEZUr6eEphWruyt+mCGfifZfqDrvHYcLRqkSbnXWP3K3FKj4XtP5YHXtrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718884231; c=relaxed/simple; bh=/fsDy/J5swdf4EmXOs+1OkO3VMutkagftRVjj5QTHnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BCru5eOgFd76cxhJ+CreQvHBwZ0VtkoMSV5v1fX7eVRoob3E/QBupFJOuoK1udMLHqNGd5o267xHx27S8xhjfhBIrOdcwskWbrGNGZK1XNW0VrwDu4B4jQV0Xk70PZEsS28SHGNB9fBC0iEbkH70npdnmMpfRHie5be0Y/1Hyos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=Vlt3Tn2D; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="Vlt3Tn2D" 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> Precedence: bulk X-Mailing-List: linux-fpga@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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";