Commit eaeac043 authored by Wolfram Sang's avatar Wolfram Sang Committed by Mark Brown

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarPeng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20240430114142.28551-4-wsa+renesas@sang-engineering.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent eef51e99
...@@ -1405,7 +1405,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx, ...@@ -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; struct dma_async_tx_descriptor *desc_tx, *desc_rx;
unsigned long transfer_timeout; unsigned long transfer_timeout;
unsigned long timeout; unsigned long time_left;
struct spi_controller *controller = spi_imx->controller; struct spi_controller *controller = spi_imx->controller;
struct sg_table *tx = &transfer->tx_sg, *rx = &transfer->rx_sg; struct sg_table *tx = &transfer->tx_sg, *rx = &transfer->rx_sg;
struct scatterlist *last_sg = sg_last(rx->sgl, rx->nents); 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, ...@@ -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); transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len);
/* Wait SDMA to finish the data transfer.*/ /* 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); transfer_timeout);
if (!timeout) { if (!time_left) {
dev_err(spi_imx->dev, "I/O Error in DMA TX\n"); dev_err(spi_imx->dev, "I/O Error in DMA TX\n");
dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_tx);
dmaengine_terminate_all(controller->dma_rx); dmaengine_terminate_all(controller->dma_rx);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
timeout = wait_for_completion_timeout(&spi_imx->dma_rx_completion, time_left = wait_for_completion_timeout(&spi_imx->dma_rx_completion,
transfer_timeout); transfer_timeout);
if (!timeout) { if (!time_left) {
dev_err(&controller->dev, "I/O Error in DMA RX\n"); dev_err(&controller->dev, "I/O Error in DMA RX\n");
spi_imx->devtype_data->reset(spi_imx); spi_imx->devtype_data->reset(spi_imx);
dmaengine_terminate_all(controller->dma_rx); dmaengine_terminate_all(controller->dma_rx);
...@@ -1501,7 +1501,7 @@ static int spi_imx_pio_transfer(struct spi_device *spi, ...@@ -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); struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller);
unsigned long transfer_timeout; unsigned long transfer_timeout;
unsigned long timeout; unsigned long time_left;
spi_imx->tx_buf = transfer->tx_buf; spi_imx->tx_buf = transfer->tx_buf;
spi_imx->rx_buf = transfer->rx_buf; spi_imx->rx_buf = transfer->rx_buf;
...@@ -1517,9 +1517,9 @@ static int spi_imx_pio_transfer(struct spi_device *spi, ...@@ -1517,9 +1517,9 @@ static int spi_imx_pio_transfer(struct spi_device *spi,
transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len);
timeout = wait_for_completion_timeout(&spi_imx->xfer_done, time_left = wait_for_completion_timeout(&spi_imx->xfer_done,
transfer_timeout); transfer_timeout);
if (!timeout) { if (!time_left) {
dev_err(&spi->dev, "I/O Error in PIO\n"); dev_err(&spi->dev, "I/O Error in PIO\n");
spi_imx->devtype_data->reset(spi_imx); spi_imx->devtype_data->reset(spi_imx);
return -ETIMEDOUT; return -ETIMEDOUT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment