Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1295026lqa; Mon, 29 Apr 2024 04:41:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBlm1fzkFEp3N5TwpHdxrdufrC+aDB+gC7tq2JuWiRIE1v0o5ZZxRhCW3wVbPmfMs4ZjFqMA311iFT94zeIMspj4Cs4S6py4DF9Bs7QQ== X-Google-Smtp-Source: AGHT+IFk/PSL+2h/PurLirNDzJvoIctXFoSiihDTqo1VdNMclSxMj6cSIEwgfsmqqieHDE1KhppZ X-Received: by 2002:a05:6870:9614:b0:23c:97e6:1499 with SMTP id d20-20020a056870961400b0023c97e61499mr3469259oaq.28.1714390866479; Mon, 29 Apr 2024 04:41:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714390866; cv=pass; d=google.com; s=arc-20160816; b=mbxYvPursIeo5fEkSnLQzC6Fs+l+YRuYyo8NyO3qr0Z19OEB7l3poto9R6HjuVoxgP cKG8ohW7zBHtWkBdIw2XTsypikMl/CZ0MG80kv1pKJoMWRrLnZ+mcIBKyyAPfcKXJ+lQ wrd6P19shmmzVJUUhzf9ys0HUhIUJ+kANWNLq1AclUq9H0R+MfDWkXLfW79B3m/lKEX+ iNYgsp9lFKqjJnWWkHhLD1r5DtfM4RNmoxer57fcZl62OysVBdM3Q3BnSoSFOkAq3Tbt S0jGULt/iGQbC0aGmR2NHBNjM0o4/HCHNvorRH+YQ37E2AbAZQJ9vWpyh3vOE1s+swH3 UUXg== 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=7uNA3296SSZr7aZkz7ZdUhN4Qf0isSkwCYvTIcIHIv8=; fh=rgmf3tvIcM2Z3UnKqX4jn0rsitSIiBNIA0bB8TfPivw=; b=0UDVmDEyCPQrWo09U8QRvoQk8v/YAsGQopkll5MbjkH0nFyuwFVN2WSCRS+AnM2EQu UEzfDyKS7raZ3N1MX/d6C/399xQXbxoUzX4seOWvOdLA1cOGKnf6Z+R7uBALNqO02e2n KWC/9jUVKO0jV4dcvi1/c6bgRfzgI/Rwew+v0BwzIgIwYcorC5ZrgxocSf4v3Ff151/W VnGL/3NqjiZZyKO24XE4XIrBnIWE6VTc5rNE4I+cocaVyEsTU0HSxrPFEO6v4qo1mbXE eR8zRF5wWZKwee8HiROTMsmIN7uuoiNhQJzucuAmqnD8o0pePf0+I4vD5zJogBm6+qlL UqiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sang-engineering.com header.s=k1 header.b=CC8HVkPf; 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-162142-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162142-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 g184-20020a636bc1000000b005dc90546100si19365580pgc.295.2024.04.29.04.41.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 04:41:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162142-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=CC8HVkPf; 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-162142-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162142-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 94478B253FD for ; Mon, 29 Apr 2024 11:29:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EF024D583; Mon, 29 Apr 2024 11:28:57 +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="CC8HVkPf" 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 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: 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 --- 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