diff mbox

spi: bcm53xx: use msecs_to_jiffies for conversion

Message ID 1423408265-23116-1-git-send-email-hofrat@osadl.org (mailing list archive)
State Accepted
Commit b3e7766bc459af941c311a3cb03f2082b2fe60ba
Headers show

Commit Message

Nicholas Mc Guire Feb. 8, 2015, 3:11 p.m. UTC
Converting milliseconds to jiffies by "val * HZ / 1000" is technically
ok but msecs_to_jiffies(val) is the cleaner solution and handles all
corner cases correctly. 

This is only an API consolidation and should make things more readable

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Patch was compile-tested only with

Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)

 drivers/spi/spi-bcm53xx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mark Brown Feb. 11, 2015, 2:14 a.m. UTC | #1
On Sun, Feb 08, 2015 at 10:11:05AM -0500, Nicholas Mc Guire wrote:
> Converting milliseconds to jiffies by "val * HZ / 1000" is technically
> ok but msecs_to_jiffies(val) is the cleaner solution and handles all
> corner cases correctly. 

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-bcm53xx.c b/drivers/spi/spi-bcm53xx.c
index 17b34cb..1933ef3 100644
--- a/drivers/spi/spi-bcm53xx.c
+++ b/drivers/spi/spi-bcm53xx.c
@@ -44,7 +44,7 @@  static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms)
 	u32 tmp;
 
 	/* SPE bit has to be 0 before we read MSPI STATUS */
-	deadline = jiffies + BCM53XXSPI_SPE_TIMEOUT_MS * HZ / 1000;
+	deadline = jiffies + msecs_to_jiffies(BCM53XXSPI_SPE_TIMEOUT_MS);
 	do {
 		tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_SPCR2);
 		if (!(tmp & B53SPI_MSPI_SPCR2_SPE))
@@ -56,7 +56,7 @@  static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms)
 		goto spi_timeout;
 
 	/* Check status */
-	deadline = jiffies + timeout_ms * HZ / 1000;
+	deadline = jiffies + msecs_to_jiffies(timeout_ms);
 	do {
 		tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_MSPI_STATUS);
 		if (tmp & B53SPI_MSPI_MSPI_STATUS_SPIF) {