From nobody Fri Dec 19 02:50:40 2025 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 AF0533FE28 for ; Mon, 29 Apr 2024 11:28:52 +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=1714390134; cv=none; b=r8uRwnnRiceFtrQVnt35TnLhxFmJ0QWG1eS6VOIcvQrEzWfxMJdbLT/ynJxy0W/ThNoubIipbHC56XDoni0GI2K7ZPmhx10JUpqNU/LWoGpquoLjQEqMiekuFHvFQ8+oOGcxIjLWV2gw+44T10vaV7lLTeZjy8GuAtnC1nnjlTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390134; c=relaxed/simple; bh=/+yQD/1xxpt49MoQExQ1xzYhBFcnigvlM4u45hspn/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y84ClKGzpERPDihFi9g3sIZZzGxw9rwvu15FDSLf1Z7ta/5LxK3NEzfm7YrCXrhKXoNgGaSdQW1H93dYpVtnI0T1z83IAgcIvS6LBYfjw/eD182lxaRwD3mmYbg+Xn5yofo5B6v4EtlAfanHGfEvn+GBaZCsSRcXjlL3gGG5sZg= 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=QiqdOS15; 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="QiqdOS15" 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=Tc5X/Zoe6TzZ7ehoGlEwf656j+yN61PTSQN5v3elxi4=; b=QiqdOS 15/fKw2XKRiniG5gIdbcmDHbOpdjQWh7I8lyPv+YW4noWzynWoqS4K0+k/V7+Hbu xneolw1qFeu5yCzEFflcNHqp64h32A+twQhMzlEBDpmq8P/oO7XLq0H9ZYy124at iVCwNzV6cMjwXyUVLSINLpx6ay/79ouKo56lbcS4eB8DPEgIqX2EaQ+0rHdhhum1 2/NMEhn/exNkM7LTfAEI8Cx+fIwNLZ9YKLBlPOq64Wte+1DrSTeAcy4UQ9yHr7M0 uXiuT0dcPknJZxj0spnOiQyKs2LNOV+snuhUpEn/99ZthP+/K8OXxfsRSnaHLYe5 ylbECwhGfAQoa4nw== Received: (qmail 2279524 invoked from network); 29 Apr 2024 13:28:45 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:45 +0200 X-UD-Smtp-Session: l3s3148p1@3bxgjjoXflVtKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 1/8] spi: armada-3700: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:34 +0200 Message-ID: <20240429112843.67628-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Fix to the proper variable type 'unsigned long' while here. Signed-off-by: Wolfram Sang --- drivers/spi/spi-armada-3700.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index 3c9ed412932f..02c1e625742d 100644 --- a/drivers/spi/spi-armada-3700.c +++ b/drivers/spi/spi-armada-3700.c @@ -339,7 +339,7 @@ static irqreturn_t a3700_spi_interrupt(int irq, void *d= ev_id) static bool a3700_spi_wait_completion(struct spi_device *spi) { struct a3700_spi *a3700_spi; - unsigned int timeout; + unsigned long time_left; unsigned int ctrl_reg; unsigned long timeout_jiffies; =20 @@ -361,12 +361,12 @@ static bool a3700_spi_wait_completion(struct spi_devi= ce *spi) a3700_spi->wait_mask); =20 timeout_jiffies =3D msecs_to_jiffies(A3700_SPI_TIMEOUT); - timeout =3D wait_for_completion_timeout(&a3700_spi->done, - timeout_jiffies); + time_left =3D wait_for_completion_timeout(&a3700_spi->done, + timeout_jiffies); =20 a3700_spi->wait_mask =3D 0; =20 - if (timeout) + if (time_left) return true; =20 /* there might be the case that right after we checked the --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 763F44176B for ; Mon, 29 Apr 2024 11:28:53 +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=1714390135; cv=none; b=Mz0rkAm3XbX0yfbfSNM8d8wZpJHx/Ak6l8cjE3PXJ/8af0tvKrZhgoVw9x1yYmDzf2s5YwXJFPTA738enre7lTmy7b5vBQUMDnCsJxn6LlHJpYbqMJgt33DufUrt4ejwrOzdl7aLdt5h70KlEc5ALMuH01vg9xHr93Leg3QQ0No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390135; c=relaxed/simple; bh=Zmt3mvVxR8/6eumvAZBZCb07XHV0s9S1SjrKXTEDONg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nffv3xNOyDuub4VAuufrVZYjYBMwmO28aeziiLivqlXNkMudnLpO9ZkbEmX4XZ+2Xiz7NWqelv0HQ1coREen+Mj3t1sFISpqDd67o3jx6C6D/hNtUR6WytZss2uE+57UFQCxwJCsSeGq3b7nVR36izNL+YTnsi7XFfP/3nOOvZs= 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=WbKQJDFH; 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="WbKQJDFH" 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=MInQ7pWHBpWvz99BT9rM0W6PRLzDwOBqZlUusbB0xrA=; b=WbKQJD FHMrDGNaxa7kcjZJGqVu3ihuDXv9KISrpMvum40cOr470SRiySzb7UDHfBJm8Tj0 pr2TYBxLI4CVC/WkJgBljlUOn/GSnJT1W2f7SCVmdQc1X1TrbX5LczsOxBjs5H67 Q7MsY7QcTbEAul2tCZeWUebTHSQVrz8qYe49tRQN/u0upsjhX2Azuav2aiWLJ/0B Z1ShxOI9HNOf6T4cMXydCmTBBZf/wNvvaVmW/5gBuc3G/njYpFupGVsg8c9XD7Is TV8ECecwMrNlM61NCgjxGj+k0dD1FhLQbn+kLpnFa7v2vwoC12kb2+hoIcYsk+Lq npiM1+AUpgqLHaYw== Received: (qmail 2279552 invoked from network); 29 Apr 2024 13:28:46 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:46 +0200 X-UD-Smtp-Session: l3s3148p1@uCdzjjoXtG1tKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 2/8] spi: fsl-lpspi: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:35 +0200 Message-ID: <20240429112843.67628-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Signed-off-by: Wolfram Sang --- drivers/spi/spi-fsl-lpspi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 92a662d1b55c..aa5ed254be46 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -553,7 +553,7 @@ static int fsl_lpspi_dma_transfer(struct spi_controller= *controller, { struct dma_async_tx_descriptor *desc_tx, *desc_rx; unsigned long transfer_timeout; - unsigned long timeout; + unsigned long time_left; struct sg_table *tx =3D &transfer->tx_sg, *rx =3D &transfer->rx_sg; int ret; =20 @@ -594,9 +594,9 @@ static int fsl_lpspi_dma_transfer(struct spi_controller= *controller, transfer->len); =20 /* Wait eDMA to finish the data transfer.*/ - timeout =3D wait_for_completion_timeout(&fsl_lpspi->dma_tx_completion, - transfer_timeout); - if (!timeout) { + time_left =3D wait_for_completion_timeout(&fsl_lpspi->dma_tx_completion, + transfer_timeout); + if (!time_left) { dev_err(fsl_lpspi->dev, "I/O Error in DMA TX\n"); dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_rx); @@ -604,9 +604,9 @@ static int fsl_lpspi_dma_transfer(struct spi_controller= *controller, return -ETIMEDOUT; } =20 - timeout =3D wait_for_completion_timeout(&fsl_lpspi->dma_rx_completion, - transfer_timeout); - if (!timeout) { + time_left =3D wait_for_completion_timeout(&fsl_lpspi->dma_rx_completion, + transfer_timeout); + if (!time_left) { dev_err(fsl_lpspi->dev, "I/O Error in DMA RX\n"); dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_rx); --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 8B8EF44C6A for ; Mon, 29 Apr 2024 11:28:54 +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=1714390136; cv=none; b=DGYgC9Enrvy4NiVk1JDRzJV5OUuGze1FAlJpZqjcdIU+FwzpXpqXembOyhuufpyl5wa81WTa3WDp4VwNfODg1o4IePCYsgeWaEcTKPdBye9ihZW2DEKGPaBABwbgIl0GEMD3quxhty2IoSzSxyAUWoEHdG/1IOrhZqIKSQ/DogU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390136; c=relaxed/simple; bh=Xsyv5SDNkoLgH9URuS3zIADXYIorPsuiL3ykMXINUvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CpA67BmrMfVDRxNhrUzdbMQFPQRRrWsXoQ3k5+cPFhlpMdt9qhghX+OVXMPqVFvaE/206MxOy/I6ukTnU11ouzJXEtm13CH3eYt4Bt3z/WalmwwAB5OIj2RXEte1vT0sFtjHukH1vR+3GUsSobTyztawbvJvoABHEt7bjcEY3sY= 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=CC8HVkPf; 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="CC8HVkPf" 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=7uNA3296SSZr7aZkz7ZdUhN4Qf0isSkwCYvTIcIHIv8=; b=CC8HVk PfDiXBD6JGqzCl/GFyo9GTZfjDKVejx1LSIaI+5AsreC5+T+yH0CZ2wWt8j5eI3y 8P81reUjJ00HeO/33tGlMJBGcriHmvyUxGqVPFIeh3JjngRZ4zMyateJQELR4mmH yiOM+RJhdsmdg6OBeQnRHqKxdhcCEfoJ8QBk5J8av+FZLBm6ZFxyAFtILyLsA9Mb l2Wyki0pHaRl7Y0apLZGS5a0rlwks0LoBkMCEVjjrjcDgX+BQtLzZCgkYqxC+VV1 R4B4LpySmiMxpKH/RGP4QYaa4GsgEN2VX7604QsEt685XwuvHWlArROFXQkHNPSa qZOVNSrG47cXVNXQ== Received: (qmail 2279577 invoked from network); 29 Apr 2024 13:28:47 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:47 +0200 X-UD-Smtp-Session: l3s3148p1@aCKGjjoXGlBtKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , 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 3/8] spi: imx: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:36 +0200 Message-ID: <20240429112843.67628-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Signed-off-by: Wolfram Sang --- 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 =3D spi_imx->controller; struct sg_table *tx =3D &transfer->tx_sg, *rx =3D &transfer->rx_sg; struct scatterlist *last_sg =3D sg_last(rx->sgl, rx->nents); @@ -1471,18 +1471,18 @@ static int spi_imx_dma_transfer(struct spi_imx_data= *spi_imx, transfer_timeout =3D spi_imx_calculate_timeout(spi_imx, transfer->len); =20 /* Wait SDMA to finish the data transfer.*/ - timeout =3D wait_for_completion_timeout(&spi_imx->dma_tx_completion, + time_left =3D 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; } =20 - timeout =3D wait_for_completion_timeout(&spi_imx->dma_rx_completion, - transfer_timeout); - if (!timeout) { + time_left =3D 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 *sp= i, { struct spi_imx_data *spi_imx =3D spi_controller_get_devdata(spi->controll= er); unsigned long transfer_timeout; - unsigned long timeout; + unsigned long time_left; =20 spi_imx->tx_buf =3D transfer->tx_buf; spi_imx->rx_buf =3D transfer->rx_buf; @@ -1517,9 +1517,9 @@ static int spi_imx_pio_transfer(struct spi_device *sp= i, =20 transfer_timeout =3D spi_imx_calculate_timeout(spi_imx, transfer->len); =20 - timeout =3D wait_for_completion_timeout(&spi_imx->xfer_done, - transfer_timeout); - if (!timeout) { + time_left =3D 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; --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 D8ED040C09 for ; Mon, 29 Apr 2024 11:28:51 +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=1714390134; cv=none; b=BCnLwbD/tuJdScDnnsVTnfV1lPoyyLBhw+QvDIDFhk7NUcSypRA+b/EwteAlU94KYIAkGRfRqP4+0RyGU0Ir4/1IXV2xSvKTEODdzB83rr18jeTLm/dxsuayGdnODEuJj78lbCE2pP02Zp3MlORaGnCYo1pMBH41vezgcB8cqK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390134; c=relaxed/simple; bh=6lX6Ow8+WDkXB8QGR8oS5cwaB8Odx+W5VMP6TmmTnWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=giBA2hYTcCk+lkE2UET3gUaCjH2OsYlZZYC0INIFd+FOwer2QD4cKUq+Eb+NUhPSMIThH+HeUKxnyQxD0LP3IHAOqcgltpoiSxLthZwUdqlLXU9ouolMhfSWFXjJaySnnlkLDsCbEJnp4VEVSOUaYhn8qmSVcev40bcixjPjlDc= 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=VSWpY1uW; 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="VSWpY1uW" 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=yUtX8ec+dY41NIYbceVd82J6yRSNmS1VfJIrMLj50Sk=; b=VSWpY1 uW5yn24Q352EjNSnroFqqmtWFagaHZseeL4FE7mlmLJWqgarDimkWGdi/DG+41sD f67zb7fQm5FjRa2FAMVDC9859kiLObZ/F+F1a7BHiwbxs3KGSGRBlwjCzKP7DuBv OEPNe8YsRMV6l4pvCz4jZ1nvqifCNT1yScaGEtFsuaUm78WtlD3QcBGj5UAFtSAt 8RAKCy84gwtGEshdMwfIRSqNSF+3yIRcMRjt568enM8plDTpwvjzt4oiy7G9c+LI DtAlM1ymqlqz6iULtiTL7LP3jaFCirqdYlEwP40KH9iSjvNCmUvwhNvILItGBzMC fNRIkAPBMEn2QjQw== Received: (qmail 2279629 invoked from network); 29 Apr 2024 13:28:48 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:48 +0200 X-UD-Smtp-Session: l3s3148p1@IK2VjjoXK1dtKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4/8] spi: pic32-sqi: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:37 +0200 Message-ID: <20240429112843.67628-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Signed-off-by: Wolfram Sang --- drivers/spi/spi-pic32-sqi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-pic32-sqi.c b/drivers/spi/spi-pic32-sqi.c index 3f1e5b27776b..0031063a7e25 100644 --- a/drivers/spi/spi-pic32-sqi.c +++ b/drivers/spi/spi-pic32-sqi.c @@ -344,7 +344,7 @@ static int pic32_sqi_one_message(struct spi_controller = *host, struct spi_transfer *xfer; struct pic32_sqi *sqi; int ret =3D 0, mode; - unsigned long timeout; + unsigned long time_left; u32 val; =20 sqi =3D spi_controller_get_devdata(host); @@ -410,8 +410,8 @@ static int pic32_sqi_one_message(struct spi_controller = *host, writel(val, sqi->regs + PESQI_BD_CTRL_REG); =20 /* wait for xfer completion */ - timeout =3D wait_for_completion_timeout(&sqi->xfer_done, 5 * HZ); - if (timeout =3D=3D 0) { + time_left =3D wait_for_completion_timeout(&sqi->xfer_done, 5 * HZ); + if (time_left =3D=3D 0) { dev_err(&sqi->host->dev, "wait timedout/interrupted\n"); ret =3D -ETIMEDOUT; msg->status =3D ret; --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 571C04594A for ; Mon, 29 Apr 2024 11:28:54 +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=1714390137; cv=none; b=iobjNKtAekNwEAD5gx5apos4hoUjik5PiMFHauTmArVDnveT9lSz7MuLoxSMYYlBSv7tKWze79eYzTCUAfNua+7xV3pwdbC94VAjARF/yZUzYq9ACDJL5uDxV/KjzvV4lyntu5DfaRbgDcnd+X3BPuqhtMWYAYSqJnx+Fsn9WwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390137; c=relaxed/simple; bh=ZZCt1Knc3LTkd7ud87jJX+jMQvb71Ot0fnQdxWqqxKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sGPj187OYaTVTFdCE5vf4/QBb/O675fcggbFDW5JjERECOjaJaJCIEMels9Tsk1UarJcGMi6om7RoOGag2BJ8cjKwJ+5lp3jPJIdLLvAUTQic5o5Mf9ICuN1A21FszQWM1LOaJ20CtBCWwfqbxXZ+ilFq8SzfW6imBUWlLMs43A= 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=Cm8xoqhr; 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="Cm8xoqhr" 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=wiD2un7//igTyi+4riuvfy4dW9R7R9MwCjnV7qyUbeI=; b=Cm8xoq hriBqVte2y8G0rg6Ug/N85sy0zOjE4Pb94WiwqEMXBNXLY/QtC8ZBzikKXpsoguB ods8iB4Jh6r9tVbUj5YvjX8JMM0N67DeSsCEehhY4B1MxBGIyCboae8nTg2hF+Qi pMHp2ckB+R3ojPnLsRq9ZlgeG5GVqYWw1KMGBKV+4i1iob1sPvKGX59JCOUzJvG2 xJ/stN+qddmEn7uNVWSV8L7qd7Rvxso22iPMJHit69WC05A79L8GfXKRdBgb7T6E YFXFZqUfeVDqtl4HADwv/gl4UitT5BpdwuUdTUczqjGok/pKKxQzBNzVd97Ulj5U s6ejYtEXGAQX88yw== Received: (qmail 2279659 invoked from network); 29 Apr 2024 13:28:49 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:49 +0200 X-UD-Smtp-Session: l3s3148p1@pOukjjoXlx9tKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 5/8] spi: pic32: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:38 +0200 Message-ID: <20240429112843.67628-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Signed-off-by: Wolfram Sang --- drivers/spi/spi-pic32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c index 709edb70ad7d..b8bcc220e96d 100644 --- a/drivers/spi/spi-pic32.c +++ b/drivers/spi/spi-pic32.c @@ -498,7 +498,7 @@ static int pic32_spi_one_transfer(struct spi_controller= *host, { struct pic32_spi *pic32s; bool dma_issued =3D false; - unsigned long timeout; + unsigned long time_left; int ret; =20 pic32s =3D spi_controller_get_devdata(host); @@ -545,8 +545,8 @@ static int pic32_spi_one_transfer(struct spi_controller= *host, } =20 /* wait for completion */ - timeout =3D wait_for_completion_timeout(&pic32s->xfer_done, 2 * HZ); - if (timeout =3D=3D 0) { + time_left =3D wait_for_completion_timeout(&pic32s->xfer_done, 2 * HZ); + if (time_left =3D=3D 0) { dev_err(&spi->dev, "wait error/timedout\n"); if (dma_issued) { dmaengine_terminate_all(host->dma_rx); --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 EAF9940843 for ; Mon, 29 Apr 2024 11:28:56 +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=1714390139; cv=none; b=EsIJJvomWG0IBzY+UjTFk2EE62U1PLElRDjVO0MaQpTblOt/mnxsMkntbgHFsSJqO68A3zbfOWqymhBcKi8Vr6uSSvb0kRrVMrmz9uVyD7A12JoTyERAn8R1Aqh9b6RmEAyMTDIsrH5Gangzxzzod/pj5FPgdFMNdgKAncAIzp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390139; c=relaxed/simple; bh=HttXKCFGHIVX81OVIeLZCnbPUyLUoWDK6FOuG7LInck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dkk0zfNBQgQpV+l8vHfxcwAjYQcr56pXehlKomrpL+mHLZCb2kP/UHjFc/DKjnEjPG0nBNlfkus9ZIOldAGRaOpDmzCqldFde0HZ0Sf+y8vH4kKQJuK2VJZhKBczf7XtuBemLoAe5QdlbjxkRuhHCrgFQsoRM1Rsv4F913rTMJY= 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=FS32s8bm; 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="FS32s8bm" 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=tTCtWiINuS6VElP26/IngafNkTKRIxMsJbQoLAWEXag=; b=FS32s8 bmah6IRXRbty3oQurlZK/iOpTiXwlVlHuTDS98+48ztRUvUDA9o9TR6zM41+WC0p kDLol/mdm37N6kFzFCZa3UFR+FcDbe+z8y1m+FRT51PcJwc6j71B4GQkUrb3+kza 062OsVGXS9DCeoeLdvHrdqCqi/1eqida0U+Gs2/pBR5pHPxTFySQ+1JuduILJAnE 8WYfcAGVKbxFg+6s57JnmCuFRHh/PBwnFkhE1T1TBc+eLR3PQj9DbkTAwPSIkNHc yv19OmpdKpZZu9aQh2fyzJrJ4caRG+WMtsgtuHV+Zij1mZEHJvor8P+Dxx/MzFrX viCh6/TlqsnS8C/w== Received: (qmail 2279687 invoked from network); 29 Apr 2024 13:28:50 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:50 +0200 X-UD-Smtp-Session: l3s3148p1@3dazjjoXCnxtKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] spi: sun4i: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:39 +0200 Message-ID: <20240429112843.67628-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Fix to the proper variable type 'unsigned long' while here. Signed-off-by: Wolfram Sang Acked-by: Jernej Skrabec Reviewed-by: Andre Przywara --- drivers/spi/spi-sun4i.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index 11d8bd27b3e9..2ee6755b43f5 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -206,7 +206,8 @@ static int sun4i_spi_transfer_one(struct spi_controller= *host, struct spi_transfer *tfr) { struct sun4i_spi *sspi =3D spi_controller_get_devdata(host); - unsigned int mclk_rate, div, timeout; + unsigned int mclk_rate, div; + unsigned long time_left; unsigned int start, end, tx_time; unsigned int tx_len =3D 0; int ret =3D 0; @@ -327,10 +328,10 @@ static int sun4i_spi_transfer_one(struct spi_controll= er *host, =20 tx_time =3D max(tfr->len * 8 * 2 / (tfr->speed_hz / 1000), 100U); start =3D jiffies; - timeout =3D wait_for_completion_timeout(&sspi->done, - msecs_to_jiffies(tx_time)); + time_left =3D wait_for_completion_timeout(&sspi->done, + msecs_to_jiffies(tx_time)); end =3D jiffies; - if (!timeout) { + if (!time_left) { dev_warn(&host->dev, "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", dev_name(&spi->dev), tfr->len, tfr->speed_hz, --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 2B59751C2C for ; Mon, 29 Apr 2024 11:28:57 +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=1714390139; cv=none; b=qV02Aioq77e5COWZ/F9uvlmHIopfD4RKORJgSo2hI0RkuruvpipI4lCd03XWLI1E+GJaNlSL7orUmpXaRel9hu+uJC/oZoBb2kZ9RbRQVvmmuzV/z4bKW2buCcBrVzOrZJlrBDgcXD2U7wHMWu2LFu6oHxovMrDlMsFzm0wqLRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390139; c=relaxed/simple; bh=D7OPeJLbch41oDZDivUDejzOlkcUJd7HsRHODi0a1SQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AxT/h2BKYhBhJv1p39r+uVRKLZbRsZCKlPKIgR+2mVZhOpXQyZFrbicBiN9dMNl2GGaDlbhQ74To4OQz1OuCWZ5k22+ptlgvEqS0VuYrAvbpj+56U2J2kUGcegv4Z4NNnujKFBkVDC0JVm5TNNGBpoixDjrSbOLVL7MCn4QNv4c= 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=cYd8t3yS; 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="cYd8t3yS" 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=U1aYJ6z7/ImyPl7HdsAgHQCypuNdVejMIowCb/bL9pw=; b=cYd8t3 ySsRqddvAIvU2awFj5wQ4kr6hxnSUl7b6LwQIzVbrVQD7DxEeLiwn7fNNkSrjJhw sNEzTH4tMs/hUDlbXvxngx11O2LtX6Ls51Ln/Gi9Q5Q7+4IAjTPZiwPQf7hjPtr4 4ebeituvnd/X3Lq4W9md+orAk1NCeaDowiz0N4BVBpOVATdOlExq2W9hziqJOCC5 jrwLgtJIv+H77HZ9TSzNtlNZ8IhHicWa8KWreX2y8QeDa9xGIEJBmVX4ROMb+SS1 ixeG9nyYxDl9ubbFsUDy7E76Ubt59rEhhHlAK2idWFOkQ8XYPeqqozwJma5Wemok f8yoVpM+HrgSY0RQ== Received: (qmail 2279704 invoked from network); 29 Apr 2024 13:28:51 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:51 +0200 X-UD-Smtp-Session: l3s3148p1@wATEjjoX7VxtKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] spi: sun6i: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:40 +0200 Message-ID: <20240429112843.67628-8-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Fix to the proper variable type 'unsigned long' while here. Signed-off-by: Wolfram Sang Acked-by: Jernej Skrabec Reviewed-by: Andre Przywara --- drivers/spi/spi-sun6i.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index cd018ea1abf1..7bbe7ea0d66a 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -277,7 +277,8 @@ static int sun6i_spi_transfer_one(struct spi_controller= *host, struct spi_transfer *tfr) { struct sun6i_spi *sspi =3D spi_controller_get_devdata(host); - unsigned int div, div_cdr1, div_cdr2, timeout; + unsigned int div, div_cdr1, div_cdr2; + unsigned long time_left; unsigned int start, end, tx_time; unsigned int trig_level; unsigned int tx_len =3D 0, rx_len =3D 0, nbits =3D 0; @@ -488,26 +489,26 @@ static int sun6i_spi_transfer_one(struct spi_controll= er *host, =20 tx_time =3D spi_controller_xfer_timeout(host, tfr); start =3D jiffies; - timeout =3D wait_for_completion_timeout(&sspi->done, - msecs_to_jiffies(tx_time)); + time_left =3D wait_for_completion_timeout(&sspi->done, + msecs_to_jiffies(tx_time)); =20 if (!use_dma) { sun6i_spi_drain_fifo(sspi); } else { - if (timeout && rx_len) { + if (time_left && rx_len) { /* * Even though RX on the peripheral side has finished * RX DMA might still be in flight */ - timeout =3D wait_for_completion_timeout(&sspi->dma_rx_done, - timeout); - if (!timeout) + time_left =3D wait_for_completion_timeout(&sspi->dma_rx_done, + time_left); + if (!time_left) dev_warn(&host->dev, "RX DMA timeout\n"); } } =20 end =3D jiffies; - if (!timeout) { + if (!time_left) { dev_warn(&host->dev, "%s: timeout transferring %u bytes@%iHz for %i(%i)ms", dev_name(&spi->dev), tfr->len, tfr->speed_hz, --=20 2.43.0 From nobody Fri Dec 19 02:50:40 2025 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 392B152F65 for ; Mon, 29 Apr 2024 11:28:58 +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=1714390140; cv=none; b=Ldp4+nK3UquQPGQ4g6zvzhapPLxxUJhiiBXYMwxL3+DocEiBtmw2uNa0BHv4Qru3w1Y83iGETB+Tu0YHRcbmRjmdqW0he9kUQxnWe9xwiV8dwfam3ZxnWpjeXD0J3sghyqZknOG1Sae0x48GF8AvFxfFRF2pf4CgIPUe2xDONwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714390140; c=relaxed/simple; bh=MqlEzg2jbLKX7b5U4n7ik5lIo7ox8YuJe3H75yyVnR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BkW3FZ/tjbIBrMysSqiflRXXAu8qVHMhuSUTzfRM90dlz1VsTHf9GgKvE/y2j0x1uvdqvLyTMFV6FP8KHY0OsshkCcd1bThWncYXveimY19V8PujfMDjkismIP7DDk2u4wl64fazW/6amIxq9OmxSe4fwBXh6LBVsVyYPQ/ruZQ= 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=hooLQnfJ; 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="hooLQnfJ" 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=QSKeK0isKUrZRHFQeVEM2xYZKBtP1xN7MAYYmt11wmo=; b=hooLQn fJRnSCS6U+iqEyjxwB3be9yC4tnNF5mRSWuMgiqV/vUVpBvYmrwQZR071nWGpxQp 8L6X1uZyKlGSWVl+9qGR3oOhigzvL7CLF6z2raLAoXXDq0hcFL4vmAFxcnH4AEAG OP7z4p/lXUx0fGprfTc0d38JRtjwl7ZbORQuNFQ8qLi8yqwOVe+m5yv6QtVd0Mk3 W00dCbNaY2KoHYwGyJygvCOohqD1SluNO/IjT6dnALrstpYwaa4ynitJLj292/Vn vliaVYWjm6DCRqjfzk6nX0j5icMloOU2b2FtcFK9IKZBZP39+rPzykCaR2oshOrr dTlSx+ryrvra7qRg== Received: (qmail 2279720 invoked from network); 29 Apr 2024 13:28:52 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 29 Apr 2024 13:28:52 +0200 X-UD-Smtp-Session: l3s3148p1@6oHUjjoXnE9tKPB4 From: Wolfram Sang To: linux-spi@vger.kernel.org Cc: Wolfram Sang , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 8/8] spi: xlp: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 29 Apr 2024 13:28:41 +0200 Message-ID: <20240429112843.67628-9-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429112843.67628-1-wsa+renesas@sang-engineering.com> References: <20240429112843.67628-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the c= ode self explaining. Fix to the proper variable type 'unsigned long' while here. Signed-off-by: Wolfram Sang --- drivers/spi/spi-xlp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-xlp.c b/drivers/spi/spi-xlp.c index 49302364b7bd..2fec18b68449 100644 --- a/drivers/spi/spi-xlp.c +++ b/drivers/spi/spi-xlp.c @@ -270,7 +270,7 @@ static int xlp_spi_xfer_block(struct xlp_spi_priv *xs, const unsigned char *tx_buf, unsigned char *rx_buf, int xfer_len, int cmd_cont) { - int timeout; + unsigned long time_left; u32 intr_mask =3D 0; =20 xs->tx_buf =3D tx_buf; @@ -299,11 +299,11 @@ static int xlp_spi_xfer_block(struct xlp_spi_priv *x= s, intr_mask |=3D XLP_SPI_INTR_DONE; xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, intr_mask); =20 - timeout =3D wait_for_completion_timeout(&xs->done, - msecs_to_jiffies(1000)); + time_left =3D wait_for_completion_timeout(&xs->done, + msecs_to_jiffies(1000)); /* Disable interrupts */ xlp_spi_reg_write(xs, xs->cs, XLP_SPI_INTR_EN, 0x0); - if (!timeout) { + if (!time_left) { dev_err(&xs->dev, "xfer timedout!\n"); goto out; } --=20 2.43.0