ASoC: Remove duplicate ADC/DAC widgets from wm_hubs.c
[linux/fpc-iii.git] / drivers / staging / otus / zdusb.c
blob2a6d937ba5e875fc0d3f1878122d68c992063d96
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 /* */
17 /* Module Name : zdusb.c */
18 /* */
19 /* Abstract */
20 /* This module contains plug and play handling for USB device driver*/
21 /* */
22 /* NOTES */
23 /* Platform dependent. */
24 /* */
25 /************************************************************************/
27 #ifdef MODVERSIONS
28 #include <linux/modversions.h>
29 #endif
31 #include <linux/module.h>
32 #include <linux/usb.h>
34 #include "usbdrv.h"
35 #include "zdusb.h"
37 int zfLnxAllocAllUrbs(struct usbdrv_private *macp);
38 void zfLnxFreeAllUrbs(struct usbdrv_private *macp);
39 void zfLnxUnlinkAllUrbs(struct usbdrv_private *macp);
41 MODULE_AUTHOR("Atheros Communications");
42 MODULE_DESCRIPTION("Atheros 802.11n Wireless LAN adapter");
43 MODULE_LICENSE("Dual BSD/GPL");
45 static const char driver_name[] = "Otus";
47 /* table of devices that work with this driver */
48 static struct usb_device_id zd1221_ids [] = {
49 { USB_DEVICE(VENDOR_ATHR, PRODUCT_AR9170) },
50 { USB_DEVICE(VENDOR_DLINK, PRODUCT_DWA160A) },
51 { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WNDA3100) },
52 { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WN111v2) },
53 { } /* Terminating entry */
56 MODULE_DEVICE_TABLE(usb, zd1221_ids);
58 extern u8_t zfLnxInitSetup(struct net_device *dev, struct usbdrv_private *macp);
59 extern int usbdrv_close(struct net_device *dev);
60 extern u8_t zfLnxClearStructs(struct net_device *dev);
61 extern int zfWdsClose(struct net_device *dev);
62 extern int zfUnregisterWdsDev(struct net_device* parentDev, u16_t wdsId);
63 extern int zfLnxVapClose(struct net_device *dev);
64 extern int zfLnxUnregisterVapDev(struct net_device* parentDev, u16_t vapId);
66 /* WDS */
67 extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
69 /* VAP */
70 extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
72 static int zfLnxProbe(struct usb_interface *interface,
73 const struct usb_device_id *id)
75 struct usb_device *dev = interface_to_usbdev(interface);
77 struct net_device *net = NULL;
78 struct usbdrv_private *macp = NULL;
79 int vendor_id, product_id;
80 int result = 0;
82 usb_get_dev(dev);
84 vendor_id = dev->descriptor.idVendor;
85 product_id = dev->descriptor.idProduct;
87 #ifdef HMAC_DEBUG
88 printk(KERN_NOTICE "vendor_id = %04x\n", vendor_id);
89 printk(KERN_NOTICE "product_id = %04x\n", product_id);
91 if (dev->speed == USB_SPEED_HIGH)
92 printk(KERN_NOTICE "USB 2.0 Host\n");
93 else
94 printk(KERN_NOTICE "USB 1.1 Host\n");
95 #endif
97 if (!(macp = kmalloc(sizeof(struct usbdrv_private), GFP_KERNEL)))
99 printk(KERN_ERR "out of memory allocating device structure\n");
100 result = -ENOMEM;
101 goto fail;
104 /* Zero the memory */
105 memset(macp, 0, sizeof(struct usbdrv_private));
107 net = alloc_etherdev(0);
109 if (net == NULL)
111 printk(KERN_ERR "zfLnxProbe: Not able to alloc etherdev struct\n");
112 result = -ENOMEM;
113 goto fail1;
116 strcpy(net->name, "ath%d");
118 net->ml_priv = macp; //kernel 2.6
119 macp->udev = dev;
120 macp->device = net;
122 /* set up the endpoint information */
123 /* check out the endpoints */
124 macp->interface = interface;
126 //init_waitqueue_head(&macp->regSet_wait);
127 //init_waitqueue_head(&macp->iorwRsp_wait);
128 //init_waitqueue_head(&macp->term_wait);
130 if (!zfLnxAllocAllUrbs(macp))
132 result = -ENOMEM;
133 goto fail2;
136 if (!zfLnxInitSetup(net, macp))
138 result = -EIO;
139 goto fail3;
141 else
143 usb_set_intfdata(interface, macp);
144 SET_NETDEV_DEV(net, &interface->dev);
146 if (register_netdev(net) != 0)
148 usb_set_intfdata(interface, NULL);
149 goto fail3;
153 netif_carrier_off(net);
154 goto done;
156 fail3:
157 zfLnxFreeAllUrbs(macp);
158 fail2:
159 free_netdev(net); //kernel 2.6
160 fail1:
161 kfree(macp);
163 fail:
164 usb_put_dev(dev);
165 macp = NULL;
167 done:
168 return result;
171 static void zfLnxDisconnect(struct usb_interface *interface)
173 struct usbdrv_private *macp = (struct usbdrv_private *) usb_get_intfdata(interface);
175 printk(KERN_DEBUG "zfLnxDisconnect\n");
177 if (!macp)
179 printk(KERN_ERR "unregistering non-existant device\n");
180 return;
183 if (macp->driver_isolated)
185 if (macp->device->flags & IFF_UP)
186 usbdrv_close(macp->device);
189 #if 0
190 /* Close WDS */
191 //zfWdsClose(wds[0].dev);
192 /* Unregister WDS */
193 //zfUnregisterWdsDev(macp->device, 0);
195 /* Close VAP */
196 zfLnxVapClose(vap[0].dev);
197 /* Unregister VAP */
198 zfLnxUnregisterVapDev(macp->device, 0);
199 #endif
201 zfLnxClearStructs(macp->device);
203 unregister_netdev(macp->device);
205 usb_put_dev(interface_to_usbdev(interface));
207 //printk(KERN_ERR "3. zfLnxUnlinkAllUrbs\n");
208 //zfLnxUnlinkAllUrbs(macp);
210 /* Free network interface */
211 free_netdev(macp->device);
213 zfLnxFreeAllUrbs(macp);
214 //zfLnxClearStructs(macp->device);
215 kfree(macp);
216 macp = NULL;
218 usb_set_intfdata(interface, NULL);
221 static struct usb_driver zd1221_driver = {
222 .name = driver_name,
223 .probe = zfLnxProbe,
224 .disconnect = zfLnxDisconnect,
225 .id_table = zd1221_ids,
228 int __init zfLnxIinit(void)
230 printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID);
231 return usb_register(&zd1221_driver);
234 void __exit zfLnxExit(void)
236 usb_deregister(&zd1221_driver);
239 module_init(zfLnxIinit);
240 module_exit(zfLnxExit);