Merge upstream into ieee80211.
[deliverable/linux.git] / drivers / usb / net / zd1201.c
index c81cd0a619bfcf1841b611f79b946956fbc82591..fc013978837e21fd756a594d53b6d52326b2646f 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/string.h>
 #include <linux/if_arp.h>
 #include <linux/firmware.h>
-#include <ieee802_11.h>
+#include <net/ieee80211.h>
 #include "zd1201.h"
 
 static struct usb_device_id zd1201_table[] = {
@@ -29,6 +29,7 @@ static struct usb_device_id zd1201_table[] = {
        {USB_DEVICE(0x0ace, 0x1201)}, /* ZyDAS ZD1201 Wireless USB Adapter */
        {USB_DEVICE(0x050d, 0x6051)}, /* Belkin F5D6051 usb  adapter */
        {USB_DEVICE(0x0db0, 0x6823)}, /* MSI UB11B usb  adapter */
+       {USB_DEVICE(0x1044, 0x8005)}, /* GIGABYTE GN-WLBZ201 usb adapter */
        {}
 };
 
@@ -45,7 +46,7 @@ MODULE_PARM_DESC(ap, "If non-zero Access Point firmware will be loaded");
 MODULE_DEVICE_TABLE(usb, zd1201_table);
 
 
-int zd1201_fw_upload(struct usb_device *dev, int apfw)
+static int zd1201_fw_upload(struct usb_device *dev, int apfw)
 {
        const struct firmware *fw_entry;
        char* data;
@@ -111,7 +112,7 @@ exit:
        return err;
 }
 
-void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
+static void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
 {
        struct zd1201 *zd = urb->context;
 
@@ -142,7 +143,8 @@ void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
 
        total: 4 + 2 + 2 + 2 + 2 + 4 = 16
 */
-int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2)
+static int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0,
+                       int parm1, int parm2)
 {
        unsigned char *command;
        int ret;
@@ -175,15 +177,15 @@ int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2)
 }
 
 /* Callback after sending out a packet */
-void zd1201_usbtx(struct urb *urb, struct pt_regs *regs)
+static void zd1201_usbtx(struct urb *urb, struct pt_regs *regs)
 {
        struct zd1201 *zd = urb->context;
        netif_wake_queue(zd->dev);
        return;
 }
 
-/* Incomming data */
-void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
+/* Incoming data */
+static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
 {
        struct zd1201 *zd = urb->context;
        int free = 0;
@@ -336,25 +338,24 @@ void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                        goto resubmit;
                }
                        
-               if ((seq & IEEE802_11_SCTL_FRAG) ||
-                   (fc & IEEE802_11_FCTL_MOREFRAGS)) {
+               if ((seq & IEEE80211_SCTL_FRAG) ||
+                   (fc & IEEE80211_FCTL_MOREFRAGS)) {
                        struct zd1201_frag *frag = NULL;
                        char *ptr;
 
                        if (datalen<14)
                                goto resubmit;
-                       if ((seq & IEEE802_11_SCTL_FRAG) == 0) {
-                               frag = kmalloc(sizeof(struct zd1201_frag*),
-                                   GFP_ATOMIC);
+                       if ((seq & IEEE80211_SCTL_FRAG) == 0) {
+                               frag = kmalloc(sizeof(*frag), GFP_ATOMIC);
                                if (!frag)
                                        goto resubmit;
-                               skb = dev_alloc_skb(IEEE802_11_DATA_LEN +14+2);
+                               skb = dev_alloc_skb(IEEE80211_DATA_LEN +14+2);
                                if (!skb) {
                                        kfree(frag);
                                        goto resubmit;
                                }
                                frag->skb = skb;
-                               frag->seq = seq & IEEE802_11_SCTL_SEQ;
+                               frag->seq = seq & IEEE80211_SCTL_SEQ;
                                skb_reserve(skb, 2);
                                memcpy(skb_put(skb, 12), &data[datalen-14], 12);
                                memcpy(skb_put(skb, 2), &data[6], 2);
@@ -363,7 +364,7 @@ void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                                goto resubmit;
                        }
                        hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
-                               if(frag->seq == (seq&IEEE802_11_SCTL_SEQ))
+                               if(frag->seq == (seq&IEEE80211_SCTL_SEQ))
                                        break;
                        if (!frag)
                                goto resubmit;
@@ -371,7 +372,7 @@ void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
                        ptr = skb_put(skb, len);
                        if (ptr)
                                memcpy(ptr, data+8, len);
-                       if (fc & IEEE802_11_FCTL_MOREFRAGS)
+                       if (fc & IEEE80211_FCTL_MOREFRAGS)
                                goto resubmit;
                        hlist_del_init(&frag->fnode);
                        kfree(frag);
@@ -613,7 +614,7 @@ static inline int zd1201_setconfig16(struct zd1201 *zd, int rid, short val)
        return (zd1201_setconfig(zd, rid, &zdval, sizeof(__le16), 1));
 }
 
-int zd1201_drvr_start(struct zd1201 *zd)
+static int zd1201_drvr_start(struct zd1201 *zd)
 {
        int err, i;
        short max;
@@ -771,7 +772,7 @@ static int zd1201_net_stop(struct net_device *dev)
 /*
        RFC 1042 encapsulates Ethernet frames in 802.11 frames
        by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0
-       (0x00, 0x00, 0x00). Zd requires an additionnal padding, copy
+       (0x00, 0x00, 0x00). Zd requires an additional padding, copy
        of ethernet addresses, length of the standard RFC 1042 packet
        and a command byte (which is nul for tx).
        
@@ -1097,7 +1098,7 @@ static int zd1201_get_range(struct net_device *dev,
 
 /*     Little bit of magic here: we only get the quality if we poll
  *     for it, and we never get an actual request to trigger such
- *     a poll. Therefore we 'asume' that the user will soon ask for
+ *     a poll. Therefore we 'assume' that the user will soon ask for
  *     the stats after asking the bssid.
  */
 static int zd1201_get_wap(struct net_device *dev,
@@ -1107,7 +1108,7 @@ static int zd1201_get_wap(struct net_device *dev,
        unsigned char buffer[6];
 
        if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
-               /* Unfortunatly the quality and noise reported is useless.
+               /* Unfortunately the quality and noise reported is useless.
                   they seem to be accumulators that increase until you
                   read them, unless we poll on a fixed interval we can't
                   use them
@@ -1739,7 +1740,8 @@ static const struct iw_handler_def zd1201_iw_handlers = {
        .private_args           = (struct iw_priv_args *) zd1201_private_args,
 };
 
-int zd1201_probe(struct usb_interface *interface, const struct usb_device_id *id)
+static int zd1201_probe(struct usb_interface *interface,
+                       const struct usb_device_id *id)
 {
        struct zd1201 *zd;
        struct usb_device *usb;
@@ -1851,7 +1853,7 @@ err_zd:
        return err;
 }
 
-void zd1201_disconnect(struct usb_interface *interface)
+static void zd1201_disconnect(struct usb_interface *interface)
 {
        struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface);
        struct hlist_node *node, *node2;
@@ -1882,12 +1884,53 @@ void zd1201_disconnect(struct usb_interface *interface)
        kfree(zd);
 }
 
-struct usb_driver zd1201_usb = {
+#ifdef CONFIG_PM
+
+static int zd1201_suspend(struct usb_interface *interface,
+                          pm_message_t message)
+{
+       struct zd1201 *zd = usb_get_intfdata(interface);
+
+       netif_device_detach(zd->dev);
+
+       zd->was_enabled = zd->mac_enabled;
+
+       if (zd->was_enabled)
+               return zd1201_disable(zd);
+       else
+               return 0;
+}
+
+static int zd1201_resume(struct usb_interface *interface)
+{
+       struct zd1201 *zd = usb_get_intfdata(interface);
+
+       if (!zd || !zd->dev)
+               return -ENODEV;
+
+       netif_device_attach(zd->dev);
+
+       if (zd->was_enabled)
+               return zd1201_enable(zd);
+       else
+               return 0;
+}
+
+#else
+
+#define zd1201_suspend NULL
+#define zd1201_resume  NULL
+
+#endif
+
+static struct usb_driver zd1201_usb = {
        .owner = THIS_MODULE,
        .name = "zd1201",
        .probe = zd1201_probe,
        .disconnect = zd1201_disconnect,
        .id_table = zd1201_table,
+       .suspend = zd1201_suspend,
+       .resume = zd1201_resume,
 };
 
 static int __init zd1201_init(void)
This page took 0.029435 seconds and 5 git commands to generate.