From: Peng Fan <peng.fan@nxp.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>
Cc: Mark Brown <broonie@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 3/8] spi: imx: use 'time_left' variable with wait_for_completion_timeout()
Date: Tue, 30 Apr 2024 01:35:57 +0000 [thread overview]
Message-ID: <DU0PR04MB9417662086BA0D4847CD1637881A2@DU0PR04MB9417.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20240429112843.67628-4-wsa+renesas@sang-engineering.com>
> Subject: [PATCH 3/8] spi: imx: use 'time_left' variable with
> wait_for_completion_timeout()
>
> 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 <wsa+renesas@sang-engineering.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
> ---
> 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
>
next prev parent reply other threads:[~2024-04-30 1:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 11:28 [PATCH 0/8] spi: use 'time_left' instead of 'timeout' with wait_for_*() functions Wolfram Sang
2024-04-29 11:28 ` [PATCH 3/8] spi: imx: use 'time_left' variable with wait_for_completion_timeout() Wolfram Sang
2024-04-30 1:35 ` Peng Fan [this message]
2024-05-02 3:57 ` [PATCH 0/8] spi: use 'time_left' instead of 'timeout' with wait_for_*() functions Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DU0PR04MB9417662086BA0D4847CD1637881A2@DU0PR04MB9417.eurprd04.prod.outlook.com \
--to=peng.fan@nxp.com \
--cc=broonie@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).