]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtd: dataflash: replace msleep with usleep_range
authorLuca Ellero <luca.ellero@brickedbrain.com>
Wed, 18 Apr 2018 09:26:26 +0000 (11:26 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Sun, 22 Apr 2018 18:02:17 +0000 (20:02 +0200)
Since msleep is based on jiffies, this 3 ms sleep becomes actually 20 ms.
Worst of all, since this sleep is used in a loop when writing, a single page
write (256 to 1024 bytes) causes 17 ms extra time.
When writing large files (for example u-boot is usually 512 KB) this delay
adds up to minutes.
See Documentation/timers/timers-howto.txt "Why not msleep for (1ms - 20ms)".

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/devices/mtd_dataflash.c

index aaaeaae01e1dfea48f57115d7519b27dfcc64fd6..3a6f450d1093c4c59d8b79bfafbc0d0c8c744722 100644 (file)
@@ -140,7 +140,7 @@ static int dataflash_waitready(struct spi_device *spi)
                if (status & (1 << 7))  /* RDY/nBSY */
                        return status;
 
-               msleep(3);
+               usleep_range(3000, 4000);
        }
 }