aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/sdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/sdio.c')
-rw-r--r--drivers/net/wireless/wl12xx/sdio.c71
1 files changed, 28 insertions, 43 deletions
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 536e5065454b..4dc4573b6861 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -23,7 +23,6 @@
23 23
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/crc7.h>
27#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
28#include <linux/mmc/sdio_func.h> 27#include <linux/mmc/sdio_func.h>
29#include <linux/mmc/sdio_ids.h> 28#include <linux/mmc/sdio_ids.h>
@@ -45,7 +44,7 @@
45#define SDIO_DEVICE_ID_TI_WL1271 0x4076 44#define SDIO_DEVICE_ID_TI_WL1271 0x4076
46#endif 45#endif
47 46
48static const struct sdio_device_id wl1271_devices[] = { 47static const struct sdio_device_id wl1271_devices[] __devinitconst = {
49 { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, 48 { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) },
50 {} 49 {}
51}; 50};
@@ -107,14 +106,6 @@ static void wl1271_sdio_enable_interrupts(struct wl1271 *wl)
107 enable_irq(wl->irq); 106 enable_irq(wl->irq);
108} 107}
109 108
110static void wl1271_sdio_reset(struct wl1271 *wl)
111{
112}
113
114static void wl1271_sdio_init(struct wl1271 *wl)
115{
116}
117
118static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, 109static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
119 size_t len, bool fixed) 110 size_t len, bool fixed)
120{ 111{
@@ -170,10 +161,12 @@ static int wl1271_sdio_power_on(struct wl1271 *wl)
170 struct sdio_func *func = wl_to_func(wl); 161 struct sdio_func *func = wl_to_func(wl);
171 int ret; 162 int ret;
172 163
173 /* Make sure the card will not be powered off by runtime PM */ 164 /* If enabled, tell runtime PM not to power off the card */
174 ret = pm_runtime_get_sync(&func->dev); 165 if (pm_runtime_enabled(&func->dev)) {
175 if (ret < 0) 166 ret = pm_runtime_get_sync(&func->dev);
176 goto out; 167 if (ret)
168 goto out;
169 }
177 170
178 /* Runtime PM might be disabled, so power up the card manually */ 171 /* Runtime PM might be disabled, so power up the card manually */
179 ret = mmc_power_restore_host(func->card->host); 172 ret = mmc_power_restore_host(func->card->host);
@@ -200,8 +193,11 @@ static int wl1271_sdio_power_off(struct wl1271 *wl)
200 if (ret < 0) 193 if (ret < 0)
201 return ret; 194 return ret;
202 195
203 /* Let runtime PM know the card is powered off */ 196 /* If enabled, let runtime PM know the card is powered off */
204 return pm_runtime_put_sync(&func->dev); 197 if (pm_runtime_enabled(&func->dev))
198 ret = pm_runtime_put_sync(&func->dev);
199
200 return ret;
205} 201}
206 202
207static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) 203static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
@@ -215,8 +211,6 @@ static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
215static struct wl1271_if_operations sdio_ops = { 211static struct wl1271_if_operations sdio_ops = {
216 .read = wl1271_sdio_raw_read, 212 .read = wl1271_sdio_raw_read,
217 .write = wl1271_sdio_raw_write, 213 .write = wl1271_sdio_raw_write,
218 .reset = wl1271_sdio_reset,
219 .init = wl1271_sdio_init,
220 .power = wl1271_sdio_set_power, 214 .power = wl1271_sdio_set_power,
221 .dev = wl1271_sdio_wl_to_dev, 215 .dev = wl1271_sdio_wl_to_dev,
222 .enable_irq = wl1271_sdio_enable_interrupts, 216 .enable_irq = wl1271_sdio_enable_interrupts,
@@ -278,17 +272,19 @@ static int __devinit wl1271_probe(struct sdio_func *func,
278 goto out_free; 272 goto out_free;
279 } 273 }
280 274
281 enable_irq_wake(wl->irq); 275 ret = enable_irq_wake(wl->irq);
282 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1); 276 if (!ret) {
283 277 wl->irq_wake_enabled = true;
284 disable_irq(wl->irq); 278 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1);
285 279
286 /* if sdio can keep power while host is suspended, enable wow */ 280 /* if sdio can keep power while host is suspended, enable wow */
287 mmcflags = sdio_get_host_pm_caps(func); 281 mmcflags = sdio_get_host_pm_caps(func);
288 wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); 282 wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags);
289 283
290 if (mmcflags & MMC_PM_KEEP_POWER) 284 if (mmcflags & MMC_PM_KEEP_POWER)
291 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; 285 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
286 }
287 disable_irq(wl->irq);
292 288
293 ret = wl1271_init_ieee80211(wl); 289 ret = wl1271_init_ieee80211(wl);
294 if (ret) 290 if (ret)
@@ -303,8 +299,6 @@ static int __devinit wl1271_probe(struct sdio_func *func,
303 /* Tell PM core that we don't need the card to be powered now */ 299 /* Tell PM core that we don't need the card to be powered now */
304 pm_runtime_put_noidle(&func->dev); 300 pm_runtime_put_noidle(&func->dev);
305 301
306 wl1271_notice("initialized");
307
308 return 0; 302 return 0;
309 303
310 out_irq: 304 out_irq:
@@ -324,8 +318,10 @@ static void __devexit wl1271_remove(struct sdio_func *func)
324 pm_runtime_get_noresume(&func->dev); 318 pm_runtime_get_noresume(&func->dev);
325 319
326 wl1271_unregister_hw(wl); 320 wl1271_unregister_hw(wl);
327 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0); 321 if (wl->irq_wake_enabled) {
328 disable_irq_wake(wl->irq); 322 device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0);
323 disable_irq_wake(wl->irq);
324 }
329 free_irq(wl->irq, wl); 325 free_irq(wl->irq, wl);
330 wl1271_free_hw(wl); 326 wl1271_free_hw(wl);
331} 327}
@@ -402,23 +398,12 @@ static struct sdio_driver wl1271_sdio_driver = {
402 398
403static int __init wl1271_init(void) 399static int __init wl1271_init(void)
404{ 400{
405 int ret; 401 return sdio_register_driver(&wl1271_sdio_driver);
406
407 ret = sdio_register_driver(&wl1271_sdio_driver);
408 if (ret < 0) {
409 wl1271_error("failed to register sdio driver: %d", ret);
410 goto out;
411 }
412
413out:
414 return ret;
415} 402}
416 403
417static void __exit wl1271_exit(void) 404static void __exit wl1271_exit(void)
418{ 405{
419 sdio_unregister_driver(&wl1271_sdio_driver); 406 sdio_unregister_driver(&wl1271_sdio_driver);
420
421 wl1271_notice("unloaded");
422} 407}
423 408
424module_init(wl1271_init); 409module_init(wl1271_init);