diff options
author | Zhu Yi <yi.zhu@intel.com> | 2009-06-15 15:36:14 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-19 11:50:16 -0400 |
commit | d7e057dca3f1b76ff44dd16fefcd493a52614aad (patch) | |
tree | edc3d4ff1a2ba516b3619a7d5fcdfd22820eb43d | |
parent | 8d96e7960b6b520eb52be6e1eb7c794da5db9555 (diff) |
iwmc3200wifi: add iwm_if_add and iwm_if_remove
We used to do alloc_netdev and register_netdev at the same time in
iwm_if_alloc. But some bus related structures will only be initialized
after iwm_priv is allocated. This caused a race condition that the
netdev might be registered earlier. The patch adds iwm_if_add and
iwm_if_remove so that the bus layer could register the device after
all initialization is done.
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/iwm.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/netdev.c | 32 | ||||
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/sdio.c | 9 |
3 files changed, 31 insertions, 12 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h index 2237448e0427..4aa0ad1932ff 100644 --- a/drivers/net/wireless/iwmc3200wifi/iwm.h +++ b/drivers/net/wireless/iwmc3200wifi/iwm.h | |||
@@ -315,6 +315,8 @@ extern const struct iw_handler_def iwm_iw_handler_def; | |||
315 | void *iwm_if_alloc(int sizeof_bus, struct device *dev, | 315 | void *iwm_if_alloc(int sizeof_bus, struct device *dev, |
316 | struct iwm_if_ops *if_ops); | 316 | struct iwm_if_ops *if_ops); |
317 | void iwm_if_free(struct iwm_priv *iwm); | 317 | void iwm_if_free(struct iwm_priv *iwm); |
318 | int iwm_if_add(struct iwm_priv *iwm); | ||
319 | void iwm_if_remove(struct iwm_priv *iwm); | ||
318 | int iwm_mode_to_nl80211_iftype(int mode); | 320 | int iwm_mode_to_nl80211_iftype(int mode); |
319 | int iwm_priv_init(struct iwm_priv *iwm); | 321 | int iwm_priv_init(struct iwm_priv *iwm); |
320 | void iwm_priv_deinit(struct iwm_priv *iwm); | 322 | void iwm_priv_deinit(struct iwm_priv *iwm); |
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c index 88dd82649b47..aaa20c6885c8 100644 --- a/drivers/net/wireless/iwmc3200wifi/netdev.c +++ b/drivers/net/wireless/iwmc3200wifi/netdev.c | |||
@@ -123,8 +123,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev, | |||
123 | 123 | ||
124 | wdev->iftype = iwm_mode_to_nl80211_iftype(iwm->conf.mode); | 124 | wdev->iftype = iwm_mode_to_nl80211_iftype(iwm->conf.mode); |
125 | 125 | ||
126 | ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, | 126 | ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, IWM_TX_QUEUES); |
127 | IWM_TX_QUEUES); | ||
128 | if (!ndev) { | 127 | if (!ndev) { |
129 | dev_err(dev, "no memory for network device instance\n"); | 128 | dev_err(dev, "no memory for network device instance\n"); |
130 | goto out_priv; | 129 | goto out_priv; |
@@ -134,19 +133,10 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev, | |||
134 | ndev->wireless_handlers = &iwm_iw_handler_def; | 133 | ndev->wireless_handlers = &iwm_iw_handler_def; |
135 | ndev->ieee80211_ptr = wdev; | 134 | ndev->ieee80211_ptr = wdev; |
136 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); | 135 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); |
137 | ret = register_netdev(ndev); | ||
138 | if (ret < 0) { | ||
139 | dev_err(dev, "Failed to register netdev: %d\n", ret); | ||
140 | goto out_ndev; | ||
141 | } | ||
142 | |||
143 | wdev->netdev = ndev; | 136 | wdev->netdev = ndev; |
144 | 137 | ||
145 | return iwm; | 138 | return iwm; |
146 | 139 | ||
147 | out_ndev: | ||
148 | free_netdev(ndev); | ||
149 | |||
150 | out_priv: | 140 | out_priv: |
151 | iwm_priv_deinit(iwm); | 141 | iwm_priv_deinit(iwm); |
152 | 142 | ||
@@ -160,8 +150,26 @@ void iwm_if_free(struct iwm_priv *iwm) | |||
160 | if (!iwm_to_ndev(iwm)) | 150 | if (!iwm_to_ndev(iwm)) |
161 | return; | 151 | return; |
162 | 152 | ||
163 | unregister_netdev(iwm_to_ndev(iwm)); | ||
164 | free_netdev(iwm_to_ndev(iwm)); | 153 | free_netdev(iwm_to_ndev(iwm)); |
165 | iwm_wdev_free(iwm); | 154 | iwm_wdev_free(iwm); |
166 | iwm_priv_deinit(iwm); | 155 | iwm_priv_deinit(iwm); |
167 | } | 156 | } |
157 | |||
158 | int iwm_if_add(struct iwm_priv *iwm) | ||
159 | { | ||
160 | struct net_device *ndev = iwm_to_ndev(iwm); | ||
161 | int ret; | ||
162 | |||
163 | ret = register_netdev(ndev); | ||
164 | if (ret < 0) { | ||
165 | dev_err(&ndev->dev, "Failed to register netdev: %d\n", ret); | ||
166 | return ret; | ||
167 | } | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | void iwm_if_remove(struct iwm_priv *iwm) | ||
173 | { | ||
174 | unregister_netdev(iwm_to_ndev(iwm)); | ||
175 | } | ||
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c index b54da677b371..c0405715647a 100644 --- a/drivers/net/wireless/iwmc3200wifi/sdio.c +++ b/drivers/net/wireless/iwmc3200wifi/sdio.c | |||
@@ -454,10 +454,18 @@ static int iwm_sdio_probe(struct sdio_func *func, | |||
454 | 454 | ||
455 | INIT_WORK(&hw->isr_worker, iwm_sdio_isr_worker); | 455 | INIT_WORK(&hw->isr_worker, iwm_sdio_isr_worker); |
456 | 456 | ||
457 | ret = iwm_if_add(iwm); | ||
458 | if (ret) { | ||
459 | dev_err(dev, "add SDIO interface failed\n"); | ||
460 | goto destroy_wq; | ||
461 | } | ||
462 | |||
457 | dev_info(dev, "IWM SDIO probe\n"); | 463 | dev_info(dev, "IWM SDIO probe\n"); |
458 | 464 | ||
459 | return 0; | 465 | return 0; |
460 | 466 | ||
467 | destroy_wq: | ||
468 | destroy_workqueue(hw->isr_wq); | ||
461 | debugfs_exit: | 469 | debugfs_exit: |
462 | iwm_debugfs_exit(iwm); | 470 | iwm_debugfs_exit(iwm); |
463 | if_free: | 471 | if_free: |
@@ -472,6 +480,7 @@ static void iwm_sdio_remove(struct sdio_func *func) | |||
472 | struct device *dev = &func->dev; | 480 | struct device *dev = &func->dev; |
473 | 481 | ||
474 | iwm_debugfs_exit(iwm); | 482 | iwm_debugfs_exit(iwm); |
483 | iwm_if_remove(iwm); | ||
475 | iwm_if_free(iwm); | 484 | iwm_if_free(iwm); |
476 | destroy_workqueue(hw->isr_wq); | 485 | destroy_workqueue(hw->isr_wq); |
477 | 486 | ||