Commit 3938c0d4 authored by Nicholas Mc Guire's avatar Nicholas Mc Guire Committed by Boris Brezillon

mtd: spi-nor: cadence-quadspi: fix timeout handling

wait_for_completion_timeout returns an unsigned long not an int, so
let's check its return value directly instead of storing it in ret,
and avoid checking for negative values since this cannot happen.
Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
parent 261b354c
...@@ -525,15 +525,14 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf, ...@@ -525,15 +525,14 @@ static int cqspi_indirect_read_execute(struct spi_nor *nor, u8 *rxbuf,
reg_base + CQSPI_REG_INDIRECTRD); reg_base + CQSPI_REG_INDIRECTRD);
while (remaining > 0) { while (remaining > 0) {
ret = wait_for_completion_timeout(&cqspi->transfer_complete, if (!wait_for_completion_timeout(&cqspi->transfer_complete,
msecs_to_jiffies msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS)))
(CQSPI_READ_TIMEOUT_MS)); ret = -ETIMEDOUT;
bytes_to_read = cqspi_get_rd_sram_level(cqspi); bytes_to_read = cqspi_get_rd_sram_level(cqspi);
if (!ret && bytes_to_read == 0) { if (ret && bytes_to_read == 0) {
dev_err(nor->dev, "Indirect read timeout, no bytes\n"); dev_err(nor->dev, "Indirect read timeout, no bytes\n");
ret = -ETIMEDOUT;
goto failrd; goto failrd;
} }
...@@ -649,10 +648,8 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor, loff_t to_addr, ...@@ -649,10 +648,8 @@ static int cqspi_indirect_write_execute(struct spi_nor *nor, loff_t to_addr,
iowrite32_rep(cqspi->ahb_base, txbuf, iowrite32_rep(cqspi->ahb_base, txbuf,
DIV_ROUND_UP(write_bytes, 4)); DIV_ROUND_UP(write_bytes, 4));
ret = wait_for_completion_timeout(&cqspi->transfer_complete, if (!wait_for_completion_timeout(&cqspi->transfer_complete,
msecs_to_jiffies msecs_to_jiffies(CQSPI_TIMEOUT_MS))) {
(CQSPI_TIMEOUT_MS));
if (!ret) {
dev_err(nor->dev, "Indirect write timeout\n"); dev_err(nor->dev, "Indirect write timeout\n");
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
goto failwr; goto failwr;
...@@ -986,9 +983,8 @@ static int cqspi_direct_read_execute(struct spi_nor *nor, u_char *buf, ...@@ -986,9 +983,8 @@ static int cqspi_direct_read_execute(struct spi_nor *nor, u_char *buf,
} }
dma_async_issue_pending(cqspi->rx_chan); dma_async_issue_pending(cqspi->rx_chan);
ret = wait_for_completion_timeout(&cqspi->rx_dma_complete, if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
msecs_to_jiffies(len)); msecs_to_jiffies(len))) {
if (ret <= 0) {
dmaengine_terminate_sync(cqspi->rx_chan); dmaengine_terminate_sync(cqspi->rx_chan);
dev_err(nor->dev, "DMA wait_for_completion_timeout\n"); dev_err(nor->dev, "DMA wait_for_completion_timeout\n");
ret = -ETIMEDOUT; ret = -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