diff options
author | Barry Grussling <barry@grussling.com> | 2013-01-08 11:05:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-10 03:04:34 -0500 |
commit | 19b2f97e468b74a8aedb4e5918bccaa5702e0742 (patch) | |
tree | 2e804fa37858f9b8c0472791f5b8337c07ca636d | |
parent | 3675c8d7144e91d9a2a1f6f12e576cb92e06f352 (diff) |
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 <barry@grussling.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/mv88e6060.c | 12 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6123_61_65.c | 12 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6131.c | 12 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 16 |
4 files changed, 34 insertions, 18 deletions
diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c index 637373cebf78..8548f8d9f75e 100644 --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/jiffies.h> | ||
11 | #include <linux/list.h> | 13 | #include <linux/list.h> |
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
@@ -66,6 +68,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) | |||
66 | { | 68 | { |
67 | int i; | 69 | int i; |
68 | int ret; | 70 | int ret; |
71 | unsigned long timeout; | ||
69 | 72 | ||
70 | /* Set all ports to the disabled state. */ | 73 | /* Set all ports to the disabled state. */ |
71 | for (i = 0; i < 6; i++) { | 74 | for (i = 0; i < 6; i++) { |
@@ -74,20 +77,21 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds) | |||
74 | } | 77 | } |
75 | 78 | ||
76 | /* Wait for transmit queues to drain. */ | 79 | /* Wait for transmit queues to drain. */ |
77 | msleep(2); | 80 | usleep_range(2000, 4000); |
78 | 81 | ||
79 | /* Reset the switch. */ | 82 | /* Reset the switch. */ |
80 | REG_WRITE(REG_GLOBAL, 0x0a, 0xa130); | 83 | REG_WRITE(REG_GLOBAL, 0x0a, 0xa130); |
81 | 84 | ||
82 | /* Wait up to one second for reset to complete. */ | 85 | /* Wait up to one second for reset to complete. */ |
83 | for (i = 0; i < 1000; i++) { | 86 | timeout = jiffies + 1 * HZ; |
87 | while (time_before(jiffies, timeout)) { | ||
84 | ret = REG_READ(REG_GLOBAL, 0x00); | 88 | ret = REG_READ(REG_GLOBAL, 0x00); |
85 | if ((ret & 0x8000) == 0x0000) | 89 | if ((ret & 0x8000) == 0x0000) |
86 | break; | 90 | break; |
87 | 91 | ||
88 | msleep(1); | 92 | usleep_range(1000, 2000); |
89 | } | 93 | } |
90 | if (i == 1000) | 94 | if (time_after(jiffies, timeout)) |
91 | return -ETIMEDOUT; | 95 | return -ETIMEDOUT; |
92 | 96 | ||
93 | return 0; | 97 | return 0; |
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 @@ | |||
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/jiffies.h> | ||
11 | #include <linux/list.h> | 13 | #include <linux/list.h> |
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
@@ -50,6 +52,7 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) | |||
50 | { | 52 | { |
51 | int i; | 53 | int i; |
52 | int ret; | 54 | int ret; |
55 | unsigned long timeout; | ||
53 | 56 | ||
54 | /* Set all ports to the disabled state. */ | 57 | /* Set all ports to the disabled state. */ |
55 | for (i = 0; i < 8; i++) { | 58 | for (i = 0; i < 8; i++) { |
@@ -58,20 +61,21 @@ static int mv88e6123_61_65_switch_reset(struct dsa_switch *ds) | |||
58 | } | 61 | } |
59 | 62 | ||
60 | /* Wait for transmit queues to drain. */ | 63 | /* Wait for transmit queues to drain. */ |
61 | msleep(2); | 64 | usleep_range(2000, 4000); |
62 | 65 | ||
63 | /* Reset the switch. */ | 66 | /* Reset the switch. */ |
64 | REG_WRITE(REG_GLOBAL, 0x04, 0xc400); | 67 | REG_WRITE(REG_GLOBAL, 0x04, 0xc400); |
65 | 68 | ||
66 | /* Wait up to one second for reset to complete. */ | 69 | /* Wait up to one second for reset to complete. */ |
67 | for (i = 0; i < 1000; i++) { | 70 | timeout = jiffies + 1 * HZ; |
71 | while (time_before(jiffies, timeout)) { | ||
68 | ret = REG_READ(REG_GLOBAL, 0x00); | 72 | ret = REG_READ(REG_GLOBAL, 0x00); |
69 | if ((ret & 0xc800) == 0xc800) | 73 | if ((ret & 0xc800) == 0xc800) |
70 | break; | 74 | break; |
71 | 75 | ||
72 | msleep(1); | 76 | usleep_range(1000, 2000); |
73 | } | 77 | } |
74 | if (i == 1000) | 78 | if (time_after(jiffies, timeout)) |
75 | return -ETIMEDOUT; | 79 | return -ETIMEDOUT; |
76 | 80 | ||
77 | return 0; | 81 | return 0; |
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index b61381887587..dadfafba64e9 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/jiffies.h> | ||
11 | #include <linux/list.h> | 13 | #include <linux/list.h> |
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
@@ -42,6 +44,7 @@ static int mv88e6131_switch_reset(struct dsa_switch *ds) | |||
42 | { | 44 | { |
43 | int i; | 45 | int i; |
44 | int ret; | 46 | int ret; |
47 | unsigned long timeout; | ||
45 | 48 | ||
46 | /* Set all ports to the disabled state. */ | 49 | /* Set all ports to the disabled state. */ |
47 | for (i = 0; i < 11; i++) { | 50 | for (i = 0; i < 11; i++) { |
@@ -50,20 +53,21 @@ static int mv88e6131_switch_reset(struct dsa_switch *ds) | |||
50 | } | 53 | } |
51 | 54 | ||
52 | /* Wait for transmit queues to drain. */ | 55 | /* Wait for transmit queues to drain. */ |
53 | msleep(2); | 56 | usleep_range(2000, 4000); |
54 | 57 | ||
55 | /* Reset the switch. */ | 58 | /* Reset the switch. */ |
56 | REG_WRITE(REG_GLOBAL, 0x04, 0xc400); | 59 | REG_WRITE(REG_GLOBAL, 0x04, 0xc400); |
57 | 60 | ||
58 | /* Wait up to one second for reset to complete. */ | 61 | /* Wait up to one second for reset to complete. */ |
59 | for (i = 0; i < 1000; i++) { | 62 | timeout = jiffies + 1 * HZ; |
63 | while (time_before(jiffies, timeout)) { | ||
60 | ret = REG_READ(REG_GLOBAL, 0x00); | 64 | ret = REG_READ(REG_GLOBAL, 0x00); |
61 | if ((ret & 0xc800) == 0xc800) | 65 | if ((ret & 0xc800) == 0xc800) |
62 | break; | 66 | break; |
63 | 67 | ||
64 | msleep(1); | 68 | usleep_range(1000, 2000); |
65 | } | 69 | } |
66 | if (i == 1000) | 70 | if (time_after(jiffies, timeout)) |
67 | return -ETIMEDOUT; | 71 | return -ETIMEDOUT; |
68 | 72 | ||
69 | return 0; | 73 | return 0; |
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index d436668cb515..afe7d80001e2 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/jiffies.h> | ||
11 | #include <linux/list.h> | 13 | #include <linux/list.h> |
12 | #include <linux/module.h> | 14 | #include <linux/module.h> |
13 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
@@ -196,14 +198,15 @@ int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val) | |||
196 | static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) | 198 | static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) |
197 | { | 199 | { |
198 | int ret; | 200 | int ret; |
199 | int i; | 201 | unsigned long timeout; |
200 | 202 | ||
201 | ret = REG_READ(REG_GLOBAL, 0x04); | 203 | ret = REG_READ(REG_GLOBAL, 0x04); |
202 | REG_WRITE(REG_GLOBAL, 0x04, ret & ~0x4000); | 204 | REG_WRITE(REG_GLOBAL, 0x04, ret & ~0x4000); |
203 | 205 | ||
204 | for (i = 0; i < 1000; i++) { | 206 | timeout = jiffies + 1 * HZ; |
207 | while (time_before(jiffies, timeout)) { | ||
205 | ret = REG_READ(REG_GLOBAL, 0x00); | 208 | ret = REG_READ(REG_GLOBAL, 0x00); |
206 | msleep(1); | 209 | usleep_range(1000, 2000); |
207 | if ((ret & 0xc000) != 0xc000) | 210 | if ((ret & 0xc000) != 0xc000) |
208 | return 0; | 211 | return 0; |
209 | } | 212 | } |
@@ -214,14 +217,15 @@ static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) | |||
214 | static int mv88e6xxx_ppu_enable(struct dsa_switch *ds) | 217 | static int mv88e6xxx_ppu_enable(struct dsa_switch *ds) |
215 | { | 218 | { |
216 | int ret; | 219 | int ret; |
217 | int i; | 220 | unsigned long timeout; |
218 | 221 | ||
219 | ret = REG_READ(REG_GLOBAL, 0x04); | 222 | ret = REG_READ(REG_GLOBAL, 0x04); |
220 | REG_WRITE(REG_GLOBAL, 0x04, ret | 0x4000); | 223 | REG_WRITE(REG_GLOBAL, 0x04, ret | 0x4000); |
221 | 224 | ||
222 | for (i = 0; i < 1000; i++) { | 225 | timeout = jiffies + 1 * HZ; |
226 | while (time_before(jiffies, timeout)) { | ||
223 | ret = REG_READ(REG_GLOBAL, 0x00); | 227 | ret = REG_READ(REG_GLOBAL, 0x00); |
224 | msleep(1); | 228 | usleep_range(1000, 2000); |
225 | if ((ret & 0xc000) == 0xc000) | 229 | if ((ret & 0xc000) == 0xc000) |
226 | return 0; | 230 | return 0; |
227 | } | 231 | } |