diff options
Diffstat (limited to 'drivers/mtd/spi-nor/spi-nor.c')
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index eafaeeb2e580..2bda622d4621 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -202,19 +202,24 @@ static int spi_nor_ready(struct spi_nor *nor) static int spi_nor_wait_till_ready(struct spi_nor *nor) { unsigned long deadline; - int ret; + int timeout = 0, ret; deadline = jiffies + MAX_READY_WAIT_JIFFIES; - do { - cond_resched(); + while (!timeout) { + if (time_after_eq(jiffies, deadline)) + timeout = 1; ret = spi_nor_ready(nor); if (ret < 0) return ret; if (ret) return 0; - } while (!time_after_eq(jiffies, deadline)); + + cond_resched(); + } + + dev_err(nor->dev, "flash operation timed out\n"); return -ETIMEDOUT; } |