diff options
author | Holger Schurig <hs4233@mail.mn-solutions.de> | 2007-05-25 12:01:42 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2007-06-11 14:28:38 -0400 |
commit | 3874d0fefd965eedfc7f8e0a5459ddf914eb4306 (patch) | |
tree | ece3d62a0667d9650db6496457286a528b539861 /drivers/net/wireless/libertas/if_usb.c | |
parent | fb3dddf22c63d7e0622d4819a87dbb8563f0e968 (diff) |
[PATCH] libertas: move reset_device() code main.c to if_usb.c
The reset_device() logic is only needed for USB devices, not for CF
devices.
Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/if_usb.c')
-rw-r--r-- | drivers/net/wireless/libertas/if_usb.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index bf7ef6582c59..99f4ba35d6ef 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -17,6 +17,10 @@ | |||
17 | 17 | ||
18 | static const char usbdriver_name[] = "usb8xxx"; | 18 | static const char usbdriver_name[] = "usb8xxx"; |
19 | 19 | ||
20 | #define MAX_DEVS 5 | ||
21 | static struct net_device *libertas_devs[MAX_DEVS]; | ||
22 | static int libertas_found = 0; | ||
23 | |||
20 | static struct usb_device_id if_usb_table[] = { | 24 | static struct usb_device_id if_usb_table[] = { |
21 | /* Enter the device signature inside */ | 25 | /* Enter the device signature inside */ |
22 | { USB_DEVICE(0x1286, 0x2001) }, | 26 | { USB_DEVICE(0x1286, 0x2001) }, |
@@ -28,6 +32,7 @@ MODULE_DEVICE_TABLE(usb, if_usb_table); | |||
28 | 32 | ||
29 | static void if_usb_receive(struct urb *urb); | 33 | static void if_usb_receive(struct urb *urb); |
30 | static void if_usb_receive_fwload(struct urb *urb); | 34 | static void if_usb_receive_fwload(struct urb *urb); |
35 | static int reset_device(wlan_private *priv); | ||
31 | 36 | ||
32 | /** | 37 | /** |
33 | * @brief call back function to handle the status of the URB | 38 | * @brief call back function to handle the status of the URB |
@@ -189,6 +194,12 @@ static int if_usb_probe(struct usb_interface *intf, | |||
189 | */ | 194 | */ |
190 | if (!(priv = wlan_add_card(usb_cardp))) | 195 | if (!(priv = wlan_add_card(usb_cardp))) |
191 | goto dealloc; | 196 | goto dealloc; |
197 | |||
198 | if (libertas_found < MAX_DEVS) { | ||
199 | libertas_devs[libertas_found] = priv->wlan_dev.netdev; | ||
200 | libertas_found++; | ||
201 | } | ||
202 | |||
192 | if (wlan_add_mesh(priv)) | 203 | if (wlan_add_mesh(priv)) |
193 | goto dealloc; | 204 | goto dealloc; |
194 | 205 | ||
@@ -220,6 +231,7 @@ static void if_usb_disconnect(struct usb_interface *intf) | |||
220 | struct usb_card_rec *cardp = usb_get_intfdata(intf); | 231 | struct usb_card_rec *cardp = usb_get_intfdata(intf); |
221 | wlan_private *priv = (wlan_private *) cardp->priv; | 232 | wlan_private *priv = (wlan_private *) cardp->priv; |
222 | wlan_adapter *adapter = NULL; | 233 | wlan_adapter *adapter = NULL; |
234 | int i; | ||
223 | 235 | ||
224 | adapter = priv->adapter; | 236 | adapter = priv->adapter; |
225 | 237 | ||
@@ -228,6 +240,14 @@ static void if_usb_disconnect(struct usb_interface *intf) | |||
228 | */ | 240 | */ |
229 | adapter->surpriseremoved = 1; | 241 | adapter->surpriseremoved = 1; |
230 | 242 | ||
243 | for (i = 0; i<libertas_found; i++) { | ||
244 | if (libertas_devs[i]==priv->wlan_dev.netdev) { | ||
245 | libertas_devs[i] = libertas_devs[--libertas_found]; | ||
246 | libertas_devs[libertas_found] = NULL ; | ||
247 | break; | ||
248 | } | ||
249 | } | ||
250 | |||
231 | /* card is removed and we can call wlan_remove_card */ | 251 | /* card is removed and we can call wlan_remove_card */ |
232 | lbs_deb_usbd(&cardp->udev->dev, "call remove card\n"); | 252 | lbs_deb_usbd(&cardp->udev->dev, "call remove card\n"); |
233 | wlan_remove_mesh(priv); | 253 | wlan_remove_mesh(priv); |
@@ -330,12 +350,17 @@ static int libertas_do_reset(wlan_private *priv) | |||
330 | int ret; | 350 | int ret; |
331 | struct usb_card_rec *cardp = priv->wlan_dev.card; | 351 | struct usb_card_rec *cardp = priv->wlan_dev.card; |
332 | 352 | ||
353 | lbs_deb_enter(LBS_DEB_USB); | ||
354 | |||
333 | ret = usb_reset_device(cardp->udev); | 355 | ret = usb_reset_device(cardp->udev); |
334 | if (!ret) { | 356 | if (!ret) { |
335 | msleep(10); | 357 | msleep(10); |
336 | reset_device(priv); | 358 | reset_device(priv); |
337 | msleep(10); | 359 | msleep(10); |
338 | } | 360 | } |
361 | |||
362 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); | ||
363 | |||
339 | return ret; | 364 | return ret; |
340 | } | 365 | } |
341 | 366 | ||
@@ -718,14 +743,16 @@ int libertas_sbi_read_event_cause(wlan_private * priv) | |||
718 | return 0; | 743 | return 0; |
719 | } | 744 | } |
720 | 745 | ||
721 | int reset_device(wlan_private *priv) | 746 | static int reset_device(wlan_private *priv) |
722 | { | 747 | { |
723 | int ret; | 748 | int ret; |
724 | 749 | ||
750 | lbs_deb_enter(LBS_DEB_USB); | ||
725 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset, | 751 | ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset, |
726 | cmd_act_halt, 0, 0, NULL); | 752 | cmd_act_halt, 0, 0, NULL); |
727 | msleep_interruptible(10); | 753 | msleep_interruptible(10); |
728 | 754 | ||
755 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); | ||
729 | return ret; | 756 | return ret; |
730 | } | 757 | } |
731 | 758 | ||
@@ -935,7 +962,13 @@ int libertas_sbi_register(void) | |||
935 | */ | 962 | */ |
936 | void libertas_sbi_unregister(void) | 963 | void libertas_sbi_unregister(void) |
937 | { | 964 | { |
965 | int i; | ||
966 | |||
967 | for (i = 0; i<libertas_found; i++) { | ||
968 | wlan_private *priv = libertas_devs[i]->priv; | ||
969 | reset_device(priv); | ||
970 | } | ||
971 | |||
938 | /* API unregisters the driver from USB subsystem */ | 972 | /* API unregisters the driver from USB subsystem */ |
939 | usb_deregister(&if_usb_driver); | 973 | usb_deregister(&if_usb_driver); |
940 | return; | ||
941 | } | 974 | } |