diff options
author | Amitkumar Karwar <akarwar@marvell.com> | 2011-06-08 11:09:20 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-06-10 14:57:52 -0400 |
commit | 287546df342daaa146c840ce26b3ed012a055de5 (patch) | |
tree | fc00b21c7d28ab5928cee9138c07bb413c073c7e /drivers/net/wireless/mwifiex/main.c | |
parent | 7f1f974251493d3929ebd422796e6f9f2bcd6956 (diff) |
mwifiex: get rid of global adapter pointer
1) Avoid global adapter pointer usage
a) in sdio.c by moving some code from mwifiex_cleanup_module() to
mwifiex_sdio_remove().
b) in main.c by passing an extra parameter to few functions.
2) Add new variable "user_rmmod" to identify if mwifiex_sdio_remove()
callback function is called in card removal or rmmod context. These
code changes are adapted from Libertas driver.
3) Remove unnecessary NULL pointer check for "func" pointer in
mwifiex_sdio_remove().
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/main.c')
-rw-r--r-- | drivers/net/wireless/mwifiex/main.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 4f43443036f4..054a5c348a24 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c | |||
@@ -26,9 +26,6 @@ | |||
26 | 26 | ||
27 | const char driver_version[] = "mwifiex " VERSION " (%s) "; | 27 | const char driver_version[] = "mwifiex " VERSION " (%s) "; |
28 | 28 | ||
29 | struct mwifiex_adapter *g_adapter; | ||
30 | EXPORT_SYMBOL_GPL(g_adapter); | ||
31 | |||
32 | static struct mwifiex_bss_attr mwifiex_bss_sta[] = { | 29 | static struct mwifiex_bss_attr mwifiex_bss_sta[] = { |
33 | {MWIFIEX_BSS_TYPE_STA, MWIFIEX_DATA_FRAME_TYPE_ETH_II, true, 0, 0}, | 30 | {MWIFIEX_BSS_TYPE_STA, MWIFIEX_DATA_FRAME_TYPE_ETH_II, true, 0, 0}, |
34 | }; | 31 | }; |
@@ -60,7 +57,8 @@ static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = { | |||
60 | * proper cleanup before exiting. | 57 | * proper cleanup before exiting. |
61 | */ | 58 | */ |
62 | static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, | 59 | static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, |
63 | struct mwifiex_drv_mode *drv_mode_ptr) | 60 | struct mwifiex_drv_mode *drv_mode_ptr, |
61 | void **padapter) | ||
64 | { | 62 | { |
65 | struct mwifiex_adapter *adapter; | 63 | struct mwifiex_adapter *adapter; |
66 | int i; | 64 | int i; |
@@ -69,7 +67,7 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, | |||
69 | if (!adapter) | 67 | if (!adapter) |
70 | return -ENOMEM; | 68 | return -ENOMEM; |
71 | 69 | ||
72 | g_adapter = adapter; | 70 | *padapter = adapter; |
73 | adapter->card = card; | 71 | adapter->card = card; |
74 | 72 | ||
75 | /* Save interface specific operations in adapter */ | 73 | /* Save interface specific operations in adapter */ |
@@ -324,7 +322,7 @@ exit_main_proc: | |||
324 | * and initializing the private structures. | 322 | * and initializing the private structures. |
325 | */ | 323 | */ |
326 | static int | 324 | static int |
327 | mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops) | 325 | mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops, void **padapter) |
328 | { | 326 | { |
329 | int i; | 327 | int i; |
330 | struct mwifiex_drv_mode *drv_mode_ptr; | 328 | struct mwifiex_drv_mode *drv_mode_ptr; |
@@ -343,7 +341,7 @@ mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops) | |||
343 | return -1; | 341 | return -1; |
344 | } | 342 | } |
345 | 343 | ||
346 | if (mwifiex_register(card, if_ops, drv_mode_ptr)) | 344 | if (mwifiex_register(card, if_ops, drv_mode_ptr, padapter)) |
347 | return -1; | 345 | return -1; |
348 | 346 | ||
349 | return 0; | 347 | return 0; |
@@ -855,13 +853,11 @@ mwifiex_add_card(void *card, struct semaphore *sem, | |||
855 | if (down_interruptible(sem)) | 853 | if (down_interruptible(sem)) |
856 | goto exit_sem_err; | 854 | goto exit_sem_err; |
857 | 855 | ||
858 | if (mwifiex_init_sw(card, if_ops)) { | 856 | if (mwifiex_init_sw(card, if_ops, (void **)&adapter)) { |
859 | pr_err("%s: software init failed\n", __func__); | 857 | pr_err("%s: software init failed\n", __func__); |
860 | goto err_init_sw; | 858 | goto err_init_sw; |
861 | } | 859 | } |
862 | 860 | ||
863 | adapter = g_adapter; | ||
864 | |||
865 | adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; | 861 | adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; |
866 | adapter->surprise_removed = false; | 862 | adapter->surprise_removed = false; |
867 | init_waitqueue_head(&adapter->init_wait_q); | 863 | init_waitqueue_head(&adapter->init_wait_q); |