From 19b2f97e468b74a8aedb4e5918bccaa5702e0742 Mon Sep 17 00:00:00 2001 From: Barry Grussling Date: Tue, 8 Jan 2013 16:05:54 +0000 Subject: DSA: Convert repeated msleep calls to timeouts Convert DSA msleep calls to timeout/usleep_range calls as reported by checkpatch.pl. Signed-off-by: Barry Grussling Signed-off-by: David S. Miller --- drivers/net/dsa/mv88e6123_61_65.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers/net/dsa/mv88e6123_61_65.c') diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c index a644fc9fe093..41ee5b6ae917 100644 --- a/drivers/net/dsa/mv88e6123_61_65.c +++ b/drivers/net/dsa/mv88e6123_61_65.c @@ -8,6 +8,8 @@ * (at your option) any later version. */ +#include +#include #include #include #include @@ -50,6 +52,7 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) { int i; int ret; + unsigned long timeout; /* Set all ports to the disabled state. */ for (i = 0; i < 8; i++) { @@ -58,20 +61,21 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) } /* Wait for transmit queues to drain. */ - msleep(2); + usleep_range(2000, 4000); /* Reset the switch. */ REG_WRITE(REG_GLOBAL, 0x04, 0xc400); /* Wait up to one second for reset to complete. */ - for (i = 0; i < 1000; i++) { + timeout = jiffies + 1 * HZ; + while (time_before(jiffies, timeout)) { ret = REG_READ(REG_GLOBAL, 0x00); if ((ret & 0xc800) == 0xc800) break; - msleep(1); + usleep_range(1000, 2000); } - if (i == 1000) + if (time_after(jiffies, timeout)) return -ETIMEDOUT; return 0; -- cgit v1.2.3