Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1958443lqa; Tue, 30 Apr 2024 04:43:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU07PJvwgwvh/IHjAKGAD7FHbL1Js7ZSkKZ31RkY+p1OdEtUwRDuGnBRi3BIe1Mbd8ti5JvZN1dGAlIxiyfEfL62On4kwLKNxcHri75dw== X-Google-Smtp-Source: AGHT+IHCRvO0N81SuXA/7bh2WRRDSM8zReodabznlPM8WkPWLAgf++9OOWd10wUXe4bA+CdPGZ9R X-Received: by 2002:a17:903:904:b0:1eb:5a92:cabf with SMTP id ll4-20020a170903090400b001eb5a92cabfmr9359386plb.41.1714477387495; Tue, 30 Apr 2024 04:43:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714477387; cv=pass; d=google.com; s=arc-20160816; b=dvRq8t3YkQ6GPaxkhGTYAvggVBs8D40udS5MBz/6dhRPsWHdTsDa1LW7hTugyKhGpR TQhI2PzzDqHlpLrHwvPetnVLh6k92zl59JJNCmEuRBVNRkT/j52vCp/TdHyXZgLuW4cb +V+hI5LAJzloFX+2hfmLdqHUMwlUr34jy1n5cook1cwHTZceC0I25ALQ4FVVypM1qT9c r3AZtTiiI/dkh+1G39uUEAfcSxpoHI5XuJHthUN/YkBETPwvGu8jou8xalGLvltPOtAP 4A4u3u8xfGfJICj1VTocjUcRp5ZimMxG0t/o/cs5m+Ap7EWWuraL1+xW7kVcwrFtXNUE phTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MhMUebPiMw4sibwlDImjI5Sk4b/9gqMN+xcox9R2PTQ=; fh=bFfRAjZ0XRzxnjf/NwYhlGwlC2deI6csyFatQZDRpyo=; b=TcjOnPTSqREFLLMo2mvxvCYD+gSnq/plh/H5whtMpDmY+uvzhBK5Qh3iot82xkh1mK X7dpvljYIWhfb0qWJ5BTTN12FoKspYZWs7hNFssMFYsvPsdwXYTKv/z4dyoI0HXvp500 xwwZ+Q6A18W/02FRbh8DmXaOrPFDIws3x94gbcAG2PkkLwiTD41ML1pS1cUcDiA0+A/z yK1OmnUjG/oXXLE0dZlzep94Z/hRCLkCQd54KP5KQNfUy++P3vuIyUNZhWRdwyvz2/vM s1GwBzbBE5C1A6Jits1b3+tqGjyAgLthbCFxBQGcxNJsSypoe78vCpMCzTOOTqfgpw/I 0o4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=DPhBWnSw; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-163858-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163858-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m4-20020a170902768400b001e412f0d7c8si21074939pll.466.2024.04.30.04.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 04:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163858-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=DPhBWnSw; arc=pass (i=1 spf=pass spfdomain=sang-engineering.com dkim=pass dkdomain=sang-engineering.com); spf=pass (google.com: domain of linux-kernel+bounces-163858-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163858-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A8242B20C09 for ; Tue, 30 Apr 2024 11:42:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D49E1428E8; Tue, 30 Apr 2024 11:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="DPhBWnSw" Received: from mail.zeus03.de (www.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 6D73613CFA0 for ; Tue, 30 Apr 2024 11:41:55 +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=1714477317; cv=none; b=S8b8mJlfS50hShIow3RNrDdZKuUtFbEnekm+NruKVQqjg2YuqoxREf8Qwcq0qeMq/BJtZ4kO04G7RZbW1S8iMEyFMPBb1tUtJxBJsA2g5vcppToQfMKNUKz+Vh1F6MzOfBUwhEIbZpvd/poCQNovM9p8NbROwq1fREBg6q/C/dY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714477317; c=relaxed/simple; bh=7N8oVXnRrJHaRlB87ucIG3bZfFi1TLwuECAHCFutGqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ESAza2k8fc6tOxzgDt/mGgptoDJH1QQXbWrcfXEjn63DPukmaeGhul2PXhWwwCchhxe4wvxW0iwk157MdTAqXPHq2ff/hrlijNL1t0XRH99MTq81juRrq+4r9OUR8gux7mZ220SJ5sfvwQ0UOnXkmYGKknUGKGGdE8/N0w9Oay8= 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=DPhBWnSw; 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 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=MhMUebPiMw4sibwlDImjI5Sk4b/9gqMN+xcox9R2PTQ=; b=DPhBWn SwP4ElT8aAcfmD8i/O46HdFj/1oqxGLvQA3vghpf17kG0g3VCZiduJC5Et31yzW2 CwKUMTxgj/+Ul1QIrBqfxqP+VuHFpMp1Y73Tl0/mcmqtFt86yuoDXF4/YsnrjdPw tUbYJkeEQQmeQSFScO9t3hue/B+1Qplo0jB+mms8xKGcdXxM3qIO+j9mFs4Hkmbg uzhaYSFy8BfDPXvdyKaGZT4KSaS+g/IggfimF8jeF3GSR4u1CHpOu/fArghxCv5Y 3kqNxOhoCIVZxJ/G7YhFY4AfAnsFB73S6iBdEKzMmf97LCW1vF88kCE2uMxgYQaF Jn+xuU6cqozEok9A== Received: (qmail 2617838 invoked from network); 30 Apr 2024 13:41:46 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 30 Apr 2024 13:41:46 +0200 X-UD-Smtp-Session: l3s3148p1@gR7O2k4XwOhehhrb From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Peng Fan , Mark Brown , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/8] spi: imx: use 'time_left' variable with wait_for_completion_timeout() Date: Tue, 30 Apr 2024 13:41:35 +0200 Message-ID: <20240430114142.28551-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240430114142.28551-1-wsa+renesas@sang-engineering.com> References: <20240430114142.28551-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Peng Fan --- drivers/spi/spi-imx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index c3e5cee18bea..f4006c82f867 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1405,7 +1405,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx, { struct dma_async_tx_descriptor *desc_tx, *desc_rx; unsigned long transfer_timeout; - unsigned long timeout; + unsigned long time_left; struct spi_controller *controller = spi_imx->controller; struct sg_table *tx = &transfer->tx_sg, *rx = &transfer->rx_sg; struct scatterlist *last_sg = sg_last(rx->sgl, rx->nents); @@ -1471,18 +1471,18 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx, transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); /* Wait SDMA to finish the data transfer.*/ - timeout = wait_for_completion_timeout(&spi_imx->dma_tx_completion, + time_left = wait_for_completion_timeout(&spi_imx->dma_tx_completion, transfer_timeout); - if (!timeout) { + if (!time_left) { dev_err(spi_imx->dev, "I/O Error in DMA TX\n"); dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_rx); return -ETIMEDOUT; } - timeout = wait_for_completion_timeout(&spi_imx->dma_rx_completion, - transfer_timeout); - if (!timeout) { + time_left = wait_for_completion_timeout(&spi_imx->dma_rx_completion, + transfer_timeout); + if (!time_left) { dev_err(&controller->dev, "I/O Error in DMA RX\n"); spi_imx->devtype_data->reset(spi_imx); dmaengine_terminate_all(controller->dma_rx); @@ -1501,7 +1501,7 @@ static int spi_imx_pio_transfer(struct spi_device *spi, { struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller); unsigned long transfer_timeout; - unsigned long timeout; + unsigned long time_left; spi_imx->tx_buf = transfer->tx_buf; spi_imx->rx_buf = transfer->rx_buf; @@ -1517,9 +1517,9 @@ static int spi_imx_pio_transfer(struct spi_device *spi, transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); - timeout = wait_for_completion_timeout(&spi_imx->xfer_done, - transfer_timeout); - if (!timeout) { + time_left = wait_for_completion_timeout(&spi_imx->xfer_done, + transfer_timeout); + if (!time_left) { dev_err(&spi->dev, "I/O Error in PIO\n"); spi_imx->devtype_data->reset(spi_imx); return -ETIMEDOUT; -- 2.43.0