Some operations (such as reading several megabytes of data from a flash) can take several seconds or more. Users may want to cancel such operations. Allow them to do so now that we have a way to recover. Signed-off-by: Sean Anderson <sean.anderson@xxxxxxxxx> --- drivers/spi/spi-zynqmp-gqspi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index cf47466ec982..fa4bff73324e 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -1062,14 +1062,24 @@ static int zynqmp_qspi_wait(struct zynqmp_qspi *xqspi, unsigned long timeout) { int ret; - ret = wait_for_completion_timeout(&xqspi->data_completion, timeout); - if (ret) + /* Only allow interrupting if we can reset the device */ + if (xqspi->reset) + ret = wait_for_completion_interruptible_timeout(&xqspi->data_completion, + timeout); + else + ret = wait_for_completion_timeout(&xqspi->data_completion, + timeout); + if (ret > 0) return 0; - dev_err(xqspi->dev, "Operation timed out\n"); + + if (!ret) { + dev_err(xqspi->dev, "Operation timed out\n"); + ret = -ETIMEDOUT; + } /* Attempt to recover as best we can */ zynqmp_qspi_init_hw(xqspi); - return -ETIMEDOUT; + return ret; } /** -- 2.35.1.1320.gc452695387.dirty