spi: uniphier: fix timeout error
authorKeiji Hayashibara <hayashibara.keiji@socionext.com>
Wed, 26 Jun 2019 00:41:47 +0000 (09:41 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 26 Jun 2019 11:30:37 +0000 (12:30 +0100)
Timeout error was silently ignored.
This commit adds timeout error handling and modifies return type of
wait_for_completion_timeout().

Signed-off-by: Keiji Hayashibara <hayashibara.keiji@socionext.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-uniphier.c

index 5a6137fe172df6eb5633ee38b7b3be2c01a84305..c3c35c041ef17ef4676c6b3dfaba35a1deec9220 100644 (file)
@@ -328,7 +328,8 @@ static int uniphier_spi_transfer_one(struct spi_master *master,
                                     struct spi_transfer *t)
 {
        struct uniphier_spi_priv *priv = spi_master_get_devdata(master);
-       int status;
+       struct device *dev = master->dev.parent;
+       unsigned long time_left;
 
        uniphier_spi_setup_transfer(spi, t);
 
@@ -338,13 +339,15 @@ static int uniphier_spi_transfer_one(struct spi_master *master,
 
        uniphier_spi_irq_enable(spi, SSI_IE_RCIE | SSI_IE_RORIE);
 
-       status = wait_for_completion_timeout(&priv->xfer_done,
-                                            msecs_to_jiffies(SSI_TIMEOUT_MS));
+       time_left = wait_for_completion_timeout(&priv->xfer_done,
+                                       msecs_to_jiffies(SSI_TIMEOUT_MS));
 
        uniphier_spi_irq_disable(spi, SSI_IE_RCIE | SSI_IE_RORIE);
 
-       if (status < 0)
-               return status;
+       if (!time_left) {
+               dev_err(dev, "transfer timeout.\n");
+               return -ETIMEDOUT;
+       }
 
        return priv->error;
 }