aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wimax/i2400m/sdio.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c
index 9d6046f58cae..7c1b843b63e9 100644
--- a/drivers/net/wimax/i2400m/sdio.c
+++ b/drivers/net/wimax/i2400m/sdio.c
@@ -95,17 +95,23 @@ static const struct i2400m_poke_table i2400ms_pokes[] = {
95 * when we ask it to explicitly doing). Tries until a timeout is 95 * when we ask it to explicitly doing). Tries until a timeout is
96 * reached. 96 * reached.
97 * 97 *
98 * The @maxtries argument indicates how many times (at most) it should
99 * be tried to enable the function. 0 means forever. This acts along
100 * with the timeout (ie: it'll stop trying as soon as the maximum
101 * number of tries is reached _or_ as soon as the timeout is reached).
102 *
98 * The reverse of this is...sdio_disable_function() 103 * The reverse of this is...sdio_disable_function()
99 * 104 *
100 * Returns: 0 if the SDIO function was enabled, < 0 errno code on 105 * Returns: 0 if the SDIO function was enabled, < 0 errno code on
101 * error (-ENODEV when it was unable to enable the function). 106 * error (-ENODEV when it was unable to enable the function).
102 */ 107 */
103static 108static
104int i2400ms_enable_function(struct sdio_func *func) 109int i2400ms_enable_function(struct sdio_func *func, unsigned maxtries)
105{ 110{
106 u64 timeout; 111 u64 timeout;
107 int err; 112 int err;
108 struct device *dev = &func->dev; 113 struct device *dev = &func->dev;
114 unsigned tries = 0;
109 115
110 d_fnstart(3, dev, "(func %p)\n", func); 116 d_fnstart(3, dev, "(func %p)\n", func);
111 /* Setup timeout (FIXME: This needs to read the CIS table to 117 /* Setup timeout (FIXME: This needs to read the CIS table to
@@ -131,6 +137,10 @@ int i2400ms_enable_function(struct sdio_func *func)
131 } 137 }
132 d_printf(2, dev, "SDIO function failed to enable: %d\n", err); 138 d_printf(2, dev, "SDIO function failed to enable: %d\n", err);
133 sdio_release_host(func); 139 sdio_release_host(func);
140 if (maxtries > 0 && ++tries >= maxtries) {
141 err = -ETIME;
142 break;
143 }
134 msleep(I2400MS_INIT_SLEEP_INTERVAL); 144 msleep(I2400MS_INIT_SLEEP_INTERVAL);
135 } 145 }
136 /* If timed out, device is not there yet -- get -ENODEV so 146 /* If timed out, device is not there yet -- get -ENODEV so
@@ -305,7 +315,7 @@ do_bus_reset:
305 /* Wait for the device to settle */ 315 /* Wait for the device to settle */
306 msleep(40); 316 msleep(40);
307 317
308 result = i2400ms_enable_function(i2400ms->func); 318 result = i2400ms_enable_function(i2400ms->func, 0);
309 if (result >= 0) 319 if (result >= 0)
310 i2400ms_rx_setup(i2400ms); 320 i2400ms_rx_setup(i2400ms);
311 } else 321 } else
@@ -452,7 +462,7 @@ int i2400ms_probe(struct sdio_func *func,
452 goto error_set_blk_size; 462 goto error_set_blk_size;
453 } 463 }
454 464
455 result = i2400ms_enable_function(i2400ms->func); 465 result = i2400ms_enable_function(i2400ms->func, 1);
456 if (result < 0) { 466 if (result < 0) {
457 dev_err(dev, "Cannot enable SDIO function: %d\n", result); 467 dev_err(dev, "Cannot enable SDIO function: %d\n", result);
458 goto error_func_enable; 468 goto error_func_enable;