Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1 | #include "hfa384x_usb.c" |
| 2 | #include "prism2mgmt.c" |
| 3 | #include "prism2mib.c" |
| 4 | #include "prism2sta.c" |
| 5 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 6 | #define PRISM_USB_DEVICE(vid, pid, name) \ |
| 7 | USB_DEVICE(vid, pid), \ |
| 8 | .driver_info = (unsigned long) name |
| 9 | |
| 10 | static struct usb_device_id usb_prism_tbl[] = { |
| 11 | {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")}, |
| 12 | {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")}, |
| 13 | {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")}, |
| 14 | {PRISM_USB_DEVICE(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, |
| 15 | {PRISM_USB_DEVICE(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, |
| 16 | {PRISM_USB_DEVICE(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")}, |
| 17 | {PRISM_USB_DEVICE(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")}, |
| 18 | {PRISM_USB_DEVICE(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")}, |
| 19 | {PRISM_USB_DEVICE(0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")}, |
| 20 | {PRISM_USB_DEVICE(0x049f, 0x0033, "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")}, |
| 21 | {PRISM_USB_DEVICE(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")}, |
| 22 | {PRISM_USB_DEVICE(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, |
| 23 | {PRISM_USB_DEVICE(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")}, |
| 24 | {PRISM_USB_DEVICE(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, |
| 25 | {PRISM_USB_DEVICE(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")}, |
| 26 | {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")}, |
| 27 | {PRISM_USB_DEVICE(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")}, |
| 28 | {PRISM_USB_DEVICE(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")}, |
| 29 | {PRISM_USB_DEVICE(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")}, |
| 30 | {PRISM_USB_DEVICE(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")}, |
| 31 | {PRISM_USB_DEVICE(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")}, |
| 32 | {PRISM_USB_DEVICE(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")}, |
| 33 | {PRISM_USB_DEVICE(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")}, |
| 34 | {PRISM_USB_DEVICE(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")}, |
| 35 | {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")}, |
| 36 | {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")}, |
| 37 | // {PRISM_USB_DEVICE(0x0ace, 0x1201, "ZyDAS ZD1201 Wireless USB Adapter")}, |
| 38 | {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")}, |
| 39 | {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")}, |
| 40 | {PRISM_USB_DEVICE(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")}, |
| 41 | {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")}, |
| 42 | {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")}, |
| 43 | {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")}, |
| 44 | {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")}, |
| 45 | {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")}, |
| 46 | {PRISM_USB_DEVICE(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")}, |
| 47 | {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")}, |
| 48 | {PRISM_USB_DEVICE(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")}, |
| 49 | {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")}, |
| 50 | {PRISM_USB_DEVICE(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")}, |
| 51 | {PRISM_USB_DEVICE(0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")}, |
| 52 | { /* terminator */ } |
| 53 | }; |
| 54 | |
| 55 | MODULE_DEVICE_TABLE(usb, usb_prism_tbl); |
| 56 | |
| 57 | /*---------------------------------------------------------------- |
| 58 | * prism2sta_probe_usb |
| 59 | * |
| 60 | * Probe routine called by the USB subsystem. |
| 61 | * |
| 62 | * Arguments: |
| 63 | * dev ptr to the usb_device struct |
| 64 | * ifnum interface number being offered |
| 65 | * |
| 66 | * Returns: |
| 67 | * NULL - we're not claiming the device+interface |
| 68 | * non-NULL - we are claiming the device+interface and |
| 69 | * this is a ptr to the data we want back |
| 70 | * when disconnect is called. |
| 71 | * |
| 72 | * Side effects: |
| 73 | * |
| 74 | * Call context: |
| 75 | * I'm not sure, assume it's interrupt. |
| 76 | * |
| 77 | ----------------------------------------------------------------*/ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 78 | static int prism2sta_probe_usb( |
| 79 | struct usb_interface *interface, |
| 80 | const struct usb_device_id *id) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 81 | { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 82 | struct usb_device *dev; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 83 | |
| 84 | wlandevice_t *wlandev = NULL; |
| 85 | hfa384x_t *hw = NULL; |
| 86 | int result = 0; |
| 87 | |
| 88 | DBFENTER; |
| 89 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 90 | dev = interface_to_usbdev(interface); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 91 | |
| 92 | if ((wlandev = create_wlan()) == NULL) { |
| 93 | WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info); |
| 94 | result = -EIO; |
| 95 | goto failed; |
| 96 | } |
| 97 | hw = wlandev->priv; |
| 98 | |
| 99 | if ( wlan_setup(wlandev) != 0 ) { |
| 100 | WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info); |
| 101 | result = -EIO; |
| 102 | goto failed; |
| 103 | } |
| 104 | |
| 105 | /* Initialize the hw data */ |
| 106 | hfa384x_create(hw, dev); |
| 107 | hw->wlandev = wlandev; |
| 108 | |
| 109 | /* Register the wlandev, this gets us a name and registers the |
| 110 | * linux netdevice. |
| 111 | */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 112 | SET_NETDEV_DEV(wlandev->netdev, &(interface->dev)); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 113 | |
| 114 | /* Do a chip-level reset on the MAC */ |
| 115 | if (prism2_doreset) { |
| 116 | result = hfa384x_corereset(hw, |
| 117 | prism2_reset_holdtime, |
| 118 | prism2_reset_settletime, 0); |
| 119 | if (result != 0) { |
| 120 | unregister_wlandev(wlandev); |
| 121 | hfa384x_destroy(hw); |
| 122 | result = -EIO; |
| 123 | WLAN_LOG_ERROR( |
| 124 | "%s: hfa384x_corereset() failed.\n", |
| 125 | dev_info); |
| 126 | goto failed; |
| 127 | } |
| 128 | } |
| 129 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 130 | usb_get_dev(dev); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 131 | |
| 132 | wlandev->msdstate = WLAN_MSD_HWPRESENT; |
| 133 | |
Richard Kennedy | 1d1b698 | 2008-11-03 11:13:48 +0000 | [diff] [blame] | 134 | if ( register_wlandev(wlandev) != 0 ) { |
| 135 | WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info); |
| 136 | result = -EIO; |
| 137 | goto failed; |
| 138 | } |
| 139 | |
| 140 | /* enable the card */ |
| 141 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); |
| 142 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 143 | goto done; |
| 144 | |
| 145 | failed: |
| 146 | if (wlandev) kfree(wlandev); |
| 147 | if (hw) kfree(hw); |
| 148 | wlandev = NULL; |
| 149 | |
| 150 | done: |
| 151 | DBFEXIT; |
| 152 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 153 | usb_set_intfdata(interface, wlandev); |
| 154 | return result; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | |
| 158 | /*---------------------------------------------------------------- |
| 159 | * prism2sta_disconnect_usb |
| 160 | * |
| 161 | * Called when a device previously claimed by probe is removed |
| 162 | * from the USB. |
| 163 | * |
| 164 | * Arguments: |
| 165 | * dev ptr to the usb_device struct |
| 166 | * ptr ptr returned by probe() when the device |
| 167 | * was claimed. |
| 168 | * |
| 169 | * Returns: |
| 170 | * Nothing |
| 171 | * |
| 172 | * Side effects: |
| 173 | * |
| 174 | * Call context: |
| 175 | * process |
| 176 | ----------------------------------------------------------------*/ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 177 | static void |
| 178 | prism2sta_disconnect_usb(struct usb_interface *interface) |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 179 | { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 180 | wlandevice_t *wlandev; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 181 | |
| 182 | DBFENTER; |
| 183 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 184 | wlandev = (wlandevice_t *) usb_get_intfdata(interface); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 185 | |
| 186 | if ( wlandev != NULL ) { |
| 187 | LIST_HEAD(cleanlist); |
| 188 | struct list_head *entry; |
| 189 | struct list_head *temp; |
| 190 | unsigned long flags; |
| 191 | |
| 192 | hfa384x_t *hw = wlandev->priv; |
| 193 | |
| 194 | if (!hw) |
| 195 | goto exit; |
| 196 | |
| 197 | spin_lock_irqsave(&hw->ctlxq.lock, flags); |
| 198 | |
| 199 | p80211netdev_hwremoved(wlandev); |
| 200 | list_splice_init(&hw->ctlxq.reapable, &cleanlist); |
| 201 | list_splice_init(&hw->ctlxq.completing, &cleanlist); |
| 202 | list_splice_init(&hw->ctlxq.pending, &cleanlist); |
| 203 | list_splice_init(&hw->ctlxq.active, &cleanlist); |
| 204 | |
| 205 | spin_unlock_irqrestore(&hw->ctlxq.lock, flags); |
| 206 | |
| 207 | /* There's no hardware to shutdown, but the driver |
| 208 | * might have some tasks or tasklets that must be |
| 209 | * stopped before we can tear everything down. |
| 210 | */ |
| 211 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); |
| 212 | |
| 213 | del_singleshot_timer_sync(&hw->throttle); |
| 214 | del_singleshot_timer_sync(&hw->reqtimer); |
| 215 | del_singleshot_timer_sync(&hw->resptimer); |
| 216 | |
| 217 | /* Unlink all the URBs. This "removes the wheels" |
| 218 | * from the entire CTLX handling mechanism. |
| 219 | */ |
| 220 | usb_kill_urb(&hw->rx_urb); |
| 221 | usb_kill_urb(&hw->tx_urb); |
| 222 | usb_kill_urb(&hw->ctlx_urb); |
| 223 | |
| 224 | tasklet_kill(&hw->completion_bh); |
| 225 | tasklet_kill(&hw->reaper_bh); |
| 226 | |
| 227 | flush_scheduled_work(); |
| 228 | |
| 229 | /* Now we complete any outstanding commands |
| 230 | * and tell everyone who is waiting for their |
| 231 | * responses that we have shut down. |
| 232 | */ |
| 233 | list_for_each(entry, &cleanlist) { |
| 234 | hfa384x_usbctlx_t *ctlx; |
| 235 | |
| 236 | ctlx = list_entry(entry, hfa384x_usbctlx_t, list); |
| 237 | complete(&ctlx->done); |
| 238 | } |
| 239 | |
| 240 | /* Give any outstanding synchronous commands |
| 241 | * a chance to complete. All they need to do |
| 242 | * is "wake up", so that's easy. |
| 243 | * (I'd like a better way to do this, really.) |
| 244 | */ |
| 245 | msleep(100); |
| 246 | |
| 247 | /* Now delete the CTLXs, because no-one else can now. */ |
| 248 | list_for_each_safe(entry, temp, &cleanlist) { |
| 249 | hfa384x_usbctlx_t *ctlx; |
| 250 | |
| 251 | ctlx = list_entry(entry, hfa384x_usbctlx_t, list); |
| 252 | kfree(ctlx); |
| 253 | } |
| 254 | |
| 255 | /* Unhook the wlandev */ |
| 256 | unregister_wlandev(wlandev); |
| 257 | wlan_unsetup(wlandev); |
| 258 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 259 | usb_put_dev(hw->usb); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 260 | |
| 261 | hfa384x_destroy(hw); |
| 262 | kfree(hw); |
| 263 | |
| 264 | kfree(wlandev); |
| 265 | } |
| 266 | |
| 267 | exit: |
| 268 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 269 | usb_set_intfdata(interface, NULL); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 270 | DBFEXIT; |
| 271 | } |
| 272 | |
| 273 | |
| 274 | static struct usb_driver prism2_usb_driver = { |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 275 | .name = "prism2_usb", |
| 276 | .probe = prism2sta_probe_usb, |
| 277 | .disconnect = prism2sta_disconnect_usb, |
| 278 | .id_table = usb_prism_tbl, |
| 279 | /* fops, minor? */ |
| 280 | }; |
| 281 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 282 | static int __init prism2usb_init(void) |
| 283 | { |
| 284 | DBFENTER; |
| 285 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 286 | /* This call will result in calls to prism2sta_probe_usb. */ |
| 287 | return usb_register(&prism2_usb_driver); |
| 288 | |
| 289 | DBFEXIT; |
| 290 | }; |
| 291 | |
| 292 | static void __exit prism2usb_cleanup(void) |
| 293 | { |
| 294 | DBFENTER; |
| 295 | |
| 296 | usb_deregister(&prism2_usb_driver); |
| 297 | |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 298 | DBFEXIT; |
| 299 | }; |
| 300 | |
| 301 | module_init(prism2usb_init); |
| 302 | module_exit(prism2usb_cleanup); |