]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - drivers/net/wireless/zd1201.c
clocks: tegra12: Use static CPU-EMC co-relation
[linux-3.10.git] / drivers / net / wireless / zd1201.c
index 6226ac2357f82a308c6efa7d42daab08d4122a91..b8ba1f925e75521a2886b42a8a3d95dac69c0aa9 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
@@ -29,6 +30,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, 0x8004)}, /* Gigabyte GN-WLBZ101 */
        {USB_DEVICE(0x1044, 0x8005)}, /* GIGABYTE GN-WLBZ201 usb adapter */
        {}
 };
@@ -96,10 +98,12 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
                goto exit;
 
        err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4,
-           USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT);
+           USB_DIR_IN | 0x40, 0, 0, buf, sizeof(ret), ZD1201_FW_TIMEOUT);
        if (err < 0)
                goto exit;
 
+       memcpy(&ret, buf, sizeof(ret));
+
        if (ret & 0x80) {
                err = -EIO;
                goto exit;
@@ -112,6 +116,9 @@ exit:
        return err;
 }
 
+MODULE_FIRMWARE("zd1201-ap.fw");
+MODULE_FIRMWARE("zd1201.fw");
+
 static void zd1201_usbfree(struct urb *urb)
 {
        struct zd1201 *zd = urb->context;
@@ -130,7 +137,6 @@ static void zd1201_usbfree(struct urb *urb)
 
        kfree(urb->transfer_buffer);
        usb_free_urb(urb);
-       return;
 }
 
 /* cmdreq message: 
@@ -181,7 +187,6 @@ static void zd1201_usbtx(struct urb *urb)
 {
        struct zd1201 *zd = urb->context;
        netif_wake_queue(zd->dev);
-       return;
 }
 
 /* Incoming data */
@@ -306,7 +311,6 @@ static void zd1201_usbrx(struct urb *urb)
        if (data[urb->actual_length-1] == ZD1201_PACKET_RXDATA) {
                int datalen = urb->actual_length-1;
                unsigned short len, fc, seq;
-               struct hlist_node *node;
 
                len = ntohs(*(__be16 *)&data[datalen-2]);
                if (len>datalen)
@@ -328,8 +332,8 @@ static void zd1201_usbrx(struct urb *urb)
                        memcpy(skb_put(skb, 2), &data[datalen-24], 2);
                        memcpy(skb_put(skb, len), data, len);
                        skb->protocol = eth_type_trans(skb, zd->dev);
-                       zd->stats.rx_packets++;
-                       zd->stats.rx_bytes += skb->len;
+                       zd->dev->stats.rx_packets++;
+                       zd->dev->stats.rx_bytes += skb->len;
                        netif_rx(skb);
                        goto resubmit;
                }
@@ -359,7 +363,7 @@ static void zd1201_usbrx(struct urb *urb)
                                hlist_add_head(&frag->fnode, &zd->fraglist);
                                goto resubmit;
                        }
-                       hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
+                       hlist_for_each_entry(frag, &zd->fraglist, fnode)
                                if (frag->seq == (seq&IEEE80211_SCTL_SEQ))
                                        break;
                        if (!frag)
@@ -384,8 +388,8 @@ static void zd1201_usbrx(struct urb *urb)
                        memcpy(skb_put(skb, len), data+8, len);
                }
                skb->protocol = eth_type_trans(skb, zd->dev);
-               zd->stats.rx_packets++;
-               zd->stats.rx_bytes += skb->len;
+               zd->dev->stats.rx_packets++;
+               zd->dev->stats.rx_bytes += skb->len;
                netif_rx(skb);
        }
 resubmit:
@@ -403,7 +407,6 @@ exit:
                wake_up(&zd->rxdataq);
                kfree(urb->transfer_buffer);
        }
-       return;
 }
 
 static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
@@ -779,7 +782,8 @@ static int zd1201_net_stop(struct net_device *dev)
                                (llc+snap+type+payload)
                zd              1 null byte, zd1201 packet type
  */
-static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t zd1201_hard_start_xmit(struct sk_buff *skb,
+                                               struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
        unsigned char *txbuf = zd->txdata;
@@ -787,9 +791,9 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct urb *urb = zd->tx_urb;
 
        if (!zd->mac_enabled || zd->monitor) {
-               zd->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
                kfree_skb(skb);
-               return 0;
+               return NETDEV_TX_OK;
        }
        netif_stop_queue(dev);
 
@@ -817,16 +821,15 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        err = usb_submit_urb(zd->tx_urb, GFP_ATOMIC);
        if (err) {
-               zd->stats.tx_errors++;
+               dev->stats.tx_errors++;
                netif_start_queue(dev);
-               return err;
+       } else {
+               dev->stats.tx_packets++;
+               dev->stats.tx_bytes += skb->len;
        }
-       zd->stats.tx_packets++;
-       zd->stats.tx_bytes += skb->len;
-       dev->trans_start = jiffies;
        kfree_skb(skb);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void zd1201_tx_timeout(struct net_device *dev)
@@ -838,9 +841,9 @@ static void zd1201_tx_timeout(struct net_device *dev)
        dev_warn(&zd->usb->dev, "%s: TX timeout, shooting down urb\n",
            dev->name);
        usb_unlink_urb(zd->tx_urb);
-       zd->stats.tx_errors++;
+       dev->stats.tx_errors++;
        /* Restart the timeout to quiet the watchdog: */
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
 }
 
 static int zd1201_set_mac_address(struct net_device *dev, void *p)
@@ -861,13 +864,6 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p)
        return zd1201_mac_reset(zd);
 }
 
-static struct net_device_stats *zd1201_get_stats(struct net_device *dev)
-{
-       struct zd1201 *zd = netdev_priv(dev);
-
-       return &zd->stats;
-}
-
 static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
@@ -878,20 +874,18 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
 static void zd1201_set_multicast(struct net_device *dev)
 {
        struct zd1201 *zd = netdev_priv(dev);
-       struct dev_mc_list *mc = dev->mc_list;
+       struct netdev_hw_addr *ha;
        unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
        int i;
 
-       if (dev->mc_count > ZD1201_MAXMULTI)
+       if (netdev_mc_count(dev) > ZD1201_MAXMULTI)
                return;
 
-       for (i=0; i<dev->mc_count; i++) {
-               memcpy(reqbuf+i*ETH_ALEN, mc->dmi_addr, ETH_ALEN);
-               mc = mc->next;
-       }
+       i = 0;
+       netdev_for_each_mc_addr(ha, dev)
+               memcpy(reqbuf + i++ * ETH_ALEN, ha->addr, ETH_ALEN);
        zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf,
-           dev->mc_count*ETH_ALEN, 0);
-       
+                        netdev_mc_count(dev) * ETH_ALEN, 0);
 }
 
 static int zd1201_config_commit(struct net_device *dev, 
@@ -1724,6 +1718,17 @@ static const struct iw_handler_def zd1201_iw_handlers = {
        .get_wireless_stats     = zd1201_get_wireless_stats,
 };
 
+static const struct net_device_ops zd1201_netdev_ops = {
+       .ndo_open               = zd1201_net_open,
+       .ndo_stop               = zd1201_net_stop,
+       .ndo_start_xmit         = zd1201_hard_start_xmit,
+       .ndo_tx_timeout         = zd1201_tx_timeout,
+       .ndo_set_rx_mode        = zd1201_set_multicast,
+       .ndo_set_mac_address    = zd1201_set_mac_address,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static int zd1201_probe(struct usb_interface *interface,
                        const struct usb_device_id *id)
 {
@@ -1776,16 +1781,9 @@ static int zd1201_probe(struct usb_interface *interface,
        if (err)
                goto err_start;
 
-       dev->open = zd1201_net_open;
-       dev->stop = zd1201_net_stop;
-       dev->get_stats = zd1201_get_stats;
-       dev->wireless_handlers =
-           (struct iw_handler_def *)&zd1201_iw_handlers;
-       dev->hard_start_xmit = zd1201_hard_start_xmit;
+       dev->netdev_ops = &zd1201_netdev_ops;
+       dev->wireless_handlers = &zd1201_iw_handlers;
        dev->watchdog_timeo = ZD1201_TX_TIMEOUT;
-       dev->tx_timeout = zd1201_tx_timeout;
-       dev->set_multicast_list = zd1201_set_multicast;
-       dev->set_mac_address = zd1201_set_mac_address;
        strcpy(dev->name, "wlan%d");
 
        err = zd1201_getconfig(zd, ZD1201_RID_CNFOWNMACADDR, 
@@ -1833,15 +1831,15 @@ err_zd:
 
 static void zd1201_disconnect(struct usb_interface *interface)
 {
-       struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface);
-       struct hlist_node *node, *node2;
+       struct zd1201 *zd = usb_get_intfdata(interface);
+       struct hlist_node *node2;
        struct zd1201_frag *frag;
 
        if (!zd)
                return;
        usb_set_intfdata(interface, NULL);
 
-       hlist_for_each_entry_safe(frag, node, node2, &zd->fraglist, fnode) {
+       hlist_for_each_entry_safe(frag, node2, &zd->fraglist, fnode) {
                hlist_del_init(&frag->fnode);
                kfree_skb(frag->skb);
                kfree(frag);
@@ -1908,17 +1906,7 @@ static struct usb_driver zd1201_usb = {
        .id_table = zd1201_table,
        .suspend = zd1201_suspend,
        .resume = zd1201_resume,
+       .disable_hub_initiated_lpm = 1,
 };
 
-static int __init zd1201_init(void)
-{
-       return usb_register(&zd1201_usb);
-}
-
-static void __exit zd1201_cleanup(void)
-{
-       usb_deregister(&zd1201_usb);
-}
-
-module_init(zd1201_init);
-module_exit(zd1201_cleanup);
+module_usb_driver(zd1201_usb);