Staging: wlan-ng: Eliminate a boatload of tertiaryAP-only code.
[linux-2.6-microblaze.git] / drivers / staging / wlan-ng / p80211netdev.c
index 11f84a8..7b38883 100644 (file)
@@ -79,9 +79,7 @@
 #include <linux/ethtool.h>
 #endif
 
-#if WIRELESS_EXT > 12
 #include <net/iw_handler.h>
-#endif
 #include <net/net_namespace.h>
 
 /*================================================================*/
@@ -244,7 +242,7 @@ static int p80211knetdev_init( netdevice_t *netdev)
 static struct net_device_stats*
 p80211knetdev_get_stats(netdevice_t *netdev)
 {
-       wlandevice_t    *wlandev = (wlandevice_t*)netdev->priv;
+       wlandevice_t    *wlandev = netdev->ml_priv;
        DBFENTER;
 
        /* TODO: review the MIB stats for items that correspond to
@@ -272,7 +270,7 @@ p80211knetdev_get_stats(netdevice_t *netdev)
 static int p80211knetdev_open( netdevice_t *netdev )
 {
        int             result = 0; /* success */
-       wlandevice_t    *wlandev = (wlandevice_t*)(netdev->priv);
+       wlandevice_t    *wlandev = netdev->ml_priv;
 
        DBFENTER;
 
@@ -285,9 +283,6 @@ static int p80211knetdev_open( netdevice_t *netdev )
        if ( wlandev->open != NULL) {
                result = wlandev->open(wlandev);
                if ( result == 0 ) {
-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43) )
-                       netdev->interrupt = 0;
-#endif
                        p80211netdev_start_queue(wlandev);
                        wlandev->state = WLAN_DEVICE_OPEN;
                }
@@ -315,7 +310,7 @@ static int p80211knetdev_open( netdevice_t *netdev )
 static int p80211knetdev_stop( netdevice_t *netdev )
 {
        int             result = 0;
-       wlandevice_t    *wlandev = (wlandevice_t*)(netdev->priv);
+       wlandevice_t    *wlandev = netdev->ml_priv;
 
        DBFENTER;
 
@@ -460,7 +455,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
 {
        int             result = 0;
        int             txresult = -1;
-       wlandevice_t    *wlandev = (wlandevice_t*)netdev->priv;
+       wlandevice_t    *wlandev = netdev->ml_priv;
        p80211_hdr_t    p80211_hdr;
        p80211_metawep_t p80211_wep;
 
@@ -478,15 +473,6 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
        memset(&p80211_hdr, 0, sizeof(p80211_hdr_t));
        memset(&p80211_wep, 0, sizeof(p80211_metawep_t));
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
-       if ( test_and_set_bit(0, (void*)&(netdev->tbusy)) != 0 ) {
-               /* We've been called w/ tbusy set, has the tx */
-               /* path stalled?   */
-               WLAN_LOG_DEBUG(1, "called when tbusy set\n");
-               result = 1;
-               goto failed;
-       }
-#else
        if ( netif_queue_stopped(netdev) ) {
                WLAN_LOG_DEBUG(1, "called when queue stopped.\n");
                result = 1;
@@ -495,12 +481,6 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
 
        netif_stop_queue(netdev);
 
-       /* No timeout handling here, 2.3.38+ kernels call the
-        * timeout function directly.
-        * TODO: Add timeout handling.
-       */
-#endif
-
        /* Check to see that a valid mode is set */
        switch( wlandev->macmode ) {
        case WLAN_MACMODE_IBSS_STA:
@@ -603,7 +583,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
 ----------------------------------------------------------------*/
 static void p80211knetdev_set_multicast_list(netdevice_t *dev)
 {
-       wlandevice_t    *wlandev = (wlandevice_t*)dev->priv;
+       wlandevice_t    *wlandev = dev->ml_priv;
 
        DBFENTER;
 
@@ -696,22 +676,12 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
 {
        int                     result = 0;
        p80211ioctl_req_t       *req = (p80211ioctl_req_t*)ifr;
-       wlandevice_t            *wlandev = (wlandevice_t*)dev->priv;
+       wlandevice_t            *wlandev = dev->ml_priv;
        UINT8                   *msgbuf;
        DBFENTER;
 
        WLAN_LOG_DEBUG(2, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len);
 
-#if WIRELESS_EXT < 13
-       /* Is this a wireless extensions ioctl? */
-       if ((cmd >= SIOCIWFIRST) && (cmd <= SIOCIWLAST)) {
-               if ((result = p80211wext_support_ioctl(dev, ifr, cmd))
-                   != (-EOPNOTSUPP)) {
-                       goto bail;
-               }
-       }
-#endif
-
 #ifdef SIOCETHTOOL
        if (cmd == SIOCETHTOOL) {
                result = p80211netdev_ethtool(wlandev, (void __user *) ifr->ifr_data);
@@ -792,15 +762,9 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
 
        DBFENTER;
        /* If we're running, we don't allow MAC address changes */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
-       if ( dev->start) {
-               return -EBUSY;
-       }
-#else
        if (netif_running(dev)) {
                return -EBUSY;
        }
-#endif
 
        /* Set up some convenience pointers. */
        mibattr = &dot11req.mibattribute;
@@ -812,7 +776,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
        dot11req.msgcode = DIDmsg_dot11req_mibset;
        dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t);
        memcpy(dot11req.devname,
-               ((wlandevice_t*)(dev->priv))->name,
+               ((wlandevice_t *)dev->ml_priv)->name,
                WLAN_DEVNAMELEN_MAX - 1);
 
        /* Set up the mibattribute argument */
@@ -833,7 +797,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
        resultcode->data = 0;
 
        /* now fire the request */
-       result = p80211req_dorequest(dev->priv, (UINT8*)&dot11req);
+       result = p80211req_dorequest(dev->ml_priv, (UINT8 *)&dot11req);
 
        /* If the request wasn't successful, report an error and don't
         * change the netdev address
@@ -917,7 +881,7 @@ int wlan_setup(wlandevice_t *wlandev)
                memset( dev, 0, sizeof(netdevice_t));
                ether_setup(dev);
                wlandev->netdev = dev;
-               dev->priv = wlandev;
+               dev->ml_priv = wlandev;
                dev->hard_start_xmit =  p80211knetdev_hard_start_xmit;
                dev->get_stats =        p80211knetdev_get_stats;
 #ifdef HAVE_PRIVATE_IOCTL
@@ -931,20 +895,13 @@ int wlan_setup(wlandevice_t *wlandev)
                dev->stop =             p80211knetdev_stop;
 
 #ifdef CONFIG_NET_WIRELESS
-#if ((WIRELESS_EXT < 17) && (WIRELESS_EXT < 21))
+#if (WIRELESS_EXT < 21)
                dev->get_wireless_stats = p80211wext_get_wireless_stats;
 #endif
-#if WIRELESS_EXT > 12
                dev->wireless_handlers = &p80211wext_handler_def;
 #endif
-#endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
-               dev->tbusy = 1;
-               dev->start = 0;
-#else
                netif_stop_queue(dev);
-#endif
 #ifdef HAVE_CHANGE_MTU
                dev->change_mtu = wlan_change_mtu;
 #endif
@@ -1039,11 +996,7 @@ int register_wlandev(wlandevice_t *wlandev)
                return -EIO;
        }
 
-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) )
-       dev->name = wlandev->name;
-#else
        strcpy(wlandev->name, dev->name);
-#endif
 
 #ifdef CONFIG_PROC_FS
        if (proc_p80211) {
@@ -1062,10 +1015,6 @@ int register_wlandev(wlandevice_t *wlandev)
        }
 #endif
 
-#ifdef CONFIG_HOTPLUG
-       p80211_run_sbin_hotplug(wlandev, WLAN_HOTPLUG_REGISTER);
-#endif
-
        DBFEXIT;
        return 0;
 }
@@ -1094,10 +1043,6 @@ int unregister_wlandev(wlandevice_t *wlandev)
 
        DBFENTER;
 
-#ifdef CONFIG_HOTPLUG
-       p80211_run_sbin_hotplug(wlandev, WLAN_HOTPLUG_REMOVE);
-#endif
-
 #ifdef CONFIG_PROC_FS
        if ( wlandev->procwlandev ) {
                remove_proc_entry("wlandev", wlandev->procdir);
@@ -1416,61 +1361,11 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, UINT16 fc)
        return drop;
 }
 
-#ifdef CONFIG_HOTPLUG
-/* Notify userspace when a netdevice event occurs,
- * by running '/sbin/hotplug net' with certain
- * environment variables set.
- */
-int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action)
-{
-        char *argv[3], *envp[7], ifname[12 + IFNAMSIZ], action_str[32];
-       char nsdname[32], wlan_wext[32];
-        int i;
-
-       if (wlandev) {
-               sprintf(ifname, "INTERFACE=%s", wlandev->name);
-               sprintf(nsdname, "NSDNAME=%s", wlandev->nsdname);
-       } else {
-               sprintf(ifname, "INTERFACE=null");
-               sprintf(nsdname, "NSDNAME=null");
-       }
-
-       sprintf(wlan_wext, "WLAN_WEXT=%s", wlan_wext_write ? "y" : "");
-        sprintf(action_str, "ACTION=%s", action);
-
-        i = 0;
-        argv[i++] = hotplug_path;
-        argv[i++] = "wlan";
-        argv[i] = NULL;
-
-        i = 0;
-        /* minimal command environment */
-        envp [i++] = "HOME=/";
-        envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-        envp [i++] = ifname;
-        envp [i++] = action_str;
-        envp [i++] = nsdname;
-        envp [i++] = wlan_wext;
-        envp [i] = NULL;
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,62))
-        return call_usermodehelper(argv [0], argv, envp);
-#else
-        return call_usermodehelper(argv [0], argv, envp, 0);
-#endif
-}
-
-#endif
-
 
 void    p80211_suspend(wlandevice_t *wlandev)
 {
        DBFENTER;
 
-#ifdef CONFIG_HOTPLUG
-       p80211_run_sbin_hotplug(wlandev, WLAN_HOTPLUG_SUSPEND);
-#endif
-
        DBFEXIT;
 }
 
@@ -1478,16 +1373,12 @@ void    p80211_resume(wlandevice_t *wlandev)
 {
        DBFENTER;
 
-#ifdef CONFIG_HOTPLUG
-       p80211_run_sbin_hotplug(wlandev, WLAN_HOTPLUG_RESUME);
-#endif
-
        DBFEXIT;
 }
 
 static void p80211knetdev_tx_timeout( netdevice_t *netdev)
 {
-       wlandevice_t    *wlandev = (wlandevice_t*)netdev->priv;
+       wlandevice_t    *wlandev = netdev->ml_priv;
        DBFENTER;
 
        if (wlandev->tx_timeout) {