提交 b4b3f0da 编写于 作者: M Moritz Muehlenhoff 提交者: Greg Kroah-Hartman

Staging: wlan-ng: p80211netdev.c: Coding style cleanups

Signed-off-by: NMoritz Muehlenhoff <jmm@debian.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 f3422882
...@@ -49,13 +49,7 @@ ...@@ -49,13 +49,7 @@
* -------------------------------------------------------------------- * --------------------------------------------------------------------
*/ */
/*================================================================*/
/* System Includes */
#include <linux/version.h> #include <linux/version.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -72,9 +66,8 @@ ...@@ -72,9 +66,8 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/byteorder/generic.h> #include <linux/byteorder/generic.h>
#include <linux/bitops.h>
#include <asm/bitops.h> #include <linux/uaccess.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#ifdef SIOCETHTOOL #ifdef SIOCETHTOOL
...@@ -99,33 +92,22 @@ ...@@ -99,33 +92,22 @@
#include "p80211metastruct.h" #include "p80211metastruct.h"
#include "p80211metadef.h" #include "p80211metadef.h"
/*================================================================*/
/* Local Constants */
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/
/* Local Function Declarations */
/* Support functions */ /* Support functions */
static void p80211netdev_rx_bh(unsigned long arg); static void p80211netdev_rx_bh(unsigned long arg);
/* netdevice method functions */ /* netdevice method functions */
static int p80211knetdev_init( netdevice_t *netdev); static int p80211knetdev_init(netdevice_t *netdev);
static struct net_device_stats* p80211knetdev_get_stats(netdevice_t *netdev); static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev);
static int p80211knetdev_open( netdevice_t *netdev); static int p80211knetdev_open(netdevice_t *netdev);
static int p80211knetdev_stop( netdevice_t *netdev ); static int p80211knetdev_stop(netdevice_t *netdev);
static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev); static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
netdevice_t *netdev);
static void p80211knetdev_set_multicast_list(netdevice_t *dev); static void p80211knetdev_set_multicast_list(netdevice_t *dev);
static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd); static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr,
int cmd);
static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr); static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr);
static void p80211knetdev_tx_timeout(netdevice_t *netdev); static void p80211knetdev_tx_timeout(netdevice_t *netdev);
static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc); static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc);
int wlan_watchdog = 5000; int wlan_watchdog = 5000;
module_param(wlan_watchdog, int, 0644); module_param(wlan_watchdog, int, 0644);
...@@ -135,9 +117,6 @@ int wlan_wext_write = 1; ...@@ -135,9 +117,6 @@ int wlan_wext_write = 1;
module_param(wlan_wext_write, int, 0644); module_param(wlan_wext_write, int, 0644);
MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions"); MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");
/*================================================================*/
/* Function Definitions */
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_init * p80211knetdev_init
* *
...@@ -150,7 +129,7 @@ MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions"); ...@@ -150,7 +129,7 @@ MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");
* Returns: * Returns:
* nothing * nothing
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static int p80211knetdev_init( netdevice_t *netdev) static int p80211knetdev_init(netdevice_t *netdev)
{ {
/* Called in response to register_netdev */ /* Called in response to register_netdev */
/* This is usually the probe function, but the probe has */ /* This is usually the probe function, but the probe has */
...@@ -159,7 +138,6 @@ static int p80211knetdev_init( netdevice_t *netdev) ...@@ -159,7 +138,6 @@ static int p80211knetdev_init( netdevice_t *netdev)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_get_stats * p80211knetdev_get_stats
* *
...@@ -174,8 +152,7 @@ static int p80211knetdev_init( netdevice_t *netdev) ...@@ -174,8 +152,7 @@ static int p80211knetdev_init( netdevice_t *netdev)
* Returns: * Returns:
* the address of the statistics structure * the address of the statistics structure
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static struct net_device_stats* static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev)
p80211knetdev_get_stats(netdevice_t *netdev)
{ {
wlandevice_t *wlandev = netdev->ml_priv; wlandevice_t *wlandev = netdev->ml_priv;
...@@ -185,7 +162,6 @@ p80211knetdev_get_stats(netdevice_t *netdev) ...@@ -185,7 +162,6 @@ p80211knetdev_get_stats(netdevice_t *netdev)
return &(wlandev->linux_stats); return &(wlandev->linux_stats);
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_open * p80211knetdev_open
* *
...@@ -200,20 +176,19 @@ p80211knetdev_get_stats(netdevice_t *netdev) ...@@ -200,20 +176,19 @@ p80211knetdev_get_stats(netdevice_t *netdev)
* Returns: * Returns:
* zero on success, non-zero otherwise * zero on success, non-zero otherwise
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static int p80211knetdev_open( netdevice_t *netdev ) static int p80211knetdev_open(netdevice_t *netdev)
{ {
int result = 0; /* success */ int result = 0; /* success */
wlandevice_t *wlandev = netdev->ml_priv; wlandevice_t *wlandev = netdev->ml_priv;
/* Check to make sure the MSD is running */ /* Check to make sure the MSD is running */
if ( wlandev->msdstate != WLAN_MSD_RUNNING ) { if (wlandev->msdstate != WLAN_MSD_RUNNING)
return -ENODEV; return -ENODEV;
}
/* Tell the MSD to open */ /* Tell the MSD to open */
if ( wlandev->open != NULL) { if (wlandev->open != NULL) {
result = wlandev->open(wlandev); result = wlandev->open(wlandev);
if ( result == 0 ) { if (result == 0) {
netif_start_queue(wlandev->netdev); netif_start_queue(wlandev->netdev);
wlandev->state = WLAN_DEVICE_OPEN; wlandev->state = WLAN_DEVICE_OPEN;
} }
...@@ -224,7 +199,6 @@ static int p80211knetdev_open( netdevice_t *netdev ) ...@@ -224,7 +199,6 @@ static int p80211knetdev_open( netdevice_t *netdev )
return result; return result;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_stop * p80211knetdev_stop
* *
...@@ -237,14 +211,13 @@ static int p80211knetdev_open( netdevice_t *netdev ) ...@@ -237,14 +211,13 @@ static int p80211knetdev_open( netdevice_t *netdev )
* Returns: * Returns:
* zero on success, non-zero otherwise * zero on success, non-zero otherwise
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static int p80211knetdev_stop( netdevice_t *netdev ) static int p80211knetdev_stop(netdevice_t *netdev)
{ {
int result = 0; int result = 0;
wlandevice_t *wlandev = netdev->ml_priv; wlandevice_t *wlandev = netdev->ml_priv;
if ( wlandev->close != NULL ) { if (wlandev->close != NULL)
result = wlandev->close(wlandev); result = wlandev->close(wlandev);
}
netif_stop_queue(wlandev->netdev); netif_stop_queue(wlandev->netdev);
wlandev->state = WLAN_DEVICE_CLOSED; wlandev->state = WLAN_DEVICE_CLOSED;
...@@ -265,8 +238,7 @@ static int p80211knetdev_stop( netdevice_t *netdev ) ...@@ -265,8 +238,7 @@ static int p80211knetdev_stop( netdevice_t *netdev )
* Side effects: * Side effects:
* *
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
void void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb )
{ {
/* Enqueue for post-irq processing */ /* Enqueue for post-irq processing */
skb_queue_tail(&wlandev->nsd_rxq, skb); skb_queue_tail(&wlandev->nsd_rxq, skb);
...@@ -298,12 +270,12 @@ static void p80211netdev_rx_bh(unsigned long arg) ...@@ -298,12 +270,12 @@ static void p80211netdev_rx_bh(unsigned long arg)
u16 fc; u16 fc;
/* Let's empty our our queue */ /* Let's empty our our queue */
while ( (skb = skb_dequeue(&wlandev->nsd_rxq)) ) { while ((skb = skb_dequeue(&wlandev->nsd_rxq))) {
if (wlandev->state == WLAN_DEVICE_OPEN) { if (wlandev->state == WLAN_DEVICE_OPEN) {
if (dev->type != ARPHRD_ETHER) { if (dev->type != ARPHRD_ETHER) {
/* RAW frame; we shouldn't convert it */ /* RAW frame; we shouldn't convert it */
// XXX Append the Prism Header here instead. /* XXX Append the Prism Header here instead. */
/* set up various data fields */ /* set up various data fields */
skb->dev = dev; skb->dev = dev;
...@@ -318,7 +290,7 @@ static void p80211netdev_rx_bh(unsigned long arg) ...@@ -318,7 +290,7 @@ static void p80211netdev_rx_bh(unsigned long arg)
netif_rx_ni(skb); netif_rx_ni(skb);
continue; continue;
} else { } else {
hdr = (p80211_hdr_a3_t *)skb->data; hdr = (p80211_hdr_a3_t *) skb->data;
fc = le16_to_cpu(hdr->fc); fc = le16_to_cpu(hdr->fc);
if (p80211_rx_typedrop(wlandev, fc)) { if (p80211_rx_typedrop(wlandev, fc)) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -328,7 +300,9 @@ static void p80211netdev_rx_bh(unsigned long arg) ...@@ -328,7 +300,9 @@ static void p80211netdev_rx_bh(unsigned long arg)
/* perform mcast filtering */ /* perform mcast filtering */
if (wlandev->netdev->flags & IFF_ALLMULTI) { if (wlandev->netdev->flags & IFF_ALLMULTI) {
/* allow my local address through */ /* allow my local address through */
if (memcmp(hdr->a1, wlandev->netdev->dev_addr, ETH_ALEN) != 0) { if (memcmp
(hdr->a1, wlandev->netdev->dev_addr,
ETH_ALEN) != 0) {
/* but reject anything else that isn't multicast */ /* but reject anything else that isn't multicast */
if (!(hdr->a1[0] & 0x01)) { if (!(hdr->a1[0] & 0x01)) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -337,21 +311,22 @@ static void p80211netdev_rx_bh(unsigned long arg) ...@@ -337,21 +311,22 @@ static void p80211netdev_rx_bh(unsigned long arg)
} }
} }
if ( skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0 ) { if (skb_p80211_to_ether
(wlandev, wlandev->ethconv, skb) == 0) {
skb->dev->last_rx = jiffies; skb->dev->last_rx = jiffies;
wlandev->linux_stats.rx_packets++; wlandev->linux_stats.rx_packets++;
wlandev->linux_stats.rx_bytes += skb->len; wlandev->linux_stats.rx_bytes +=
skb->len;
netif_rx_ni(skb); netif_rx_ni(skb);
continue; continue;
} }
pr_debug( "p80211_to_ether failed.\n"); pr_debug("p80211_to_ether failed.\n");
} }
} }
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_hard_start_xmit * p80211knetdev_hard_start_xmit
* *
...@@ -371,7 +346,8 @@ static void p80211netdev_rx_bh(unsigned long arg) ...@@ -371,7 +346,8 @@ static void p80211netdev_rx_bh(unsigned long arg)
* Returns: * Returns:
* zero on success, non-zero on failure. * zero on success, non-zero on failure.
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev) static int p80211knetdev_hard_start_xmit(struct sk_buff *skb,
netdevice_t *netdev)
{ {
int result = 0; int result = 0;
int txresult = -1; int txresult = -1;
...@@ -379,9 +355,8 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -379,9 +355,8 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
p80211_hdr_t p80211_hdr; p80211_hdr_t p80211_hdr;
p80211_metawep_t p80211_wep; p80211_metawep_t p80211_wep;
if (skb == NULL) { if (skb == NULL)
return 0; return 0;
}
if (wlandev->state != WLAN_DEVICE_OPEN) { if (wlandev->state != WLAN_DEVICE_OPEN) {
result = 1; result = 1;
...@@ -391,7 +366,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -391,7 +366,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
memset(&p80211_hdr, 0, sizeof(p80211_hdr_t)); memset(&p80211_hdr, 0, sizeof(p80211_hdr_t));
memset(&p80211_wep, 0, sizeof(p80211_metawep_t)); memset(&p80211_wep, 0, sizeof(p80211_metawep_t));
if ( netif_queue_stopped(netdev) ) { if (netif_queue_stopped(netdev)) {
pr_debug("called when queue stopped.\n"); pr_debug("called when queue stopped.\n");
result = 1; result = 1;
goto failed; goto failed;
...@@ -400,7 +375,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -400,7 +375,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
netif_stop_queue(netdev); netif_stop_queue(netdev);
/* Check to see that a valid mode is set */ /* Check to see that a valid mode is set */
switch( wlandev->macmode ) { switch (wlandev->macmode) {
case WLAN_MACMODE_IBSS_STA: case WLAN_MACMODE_IBSS_STA:
case WLAN_MACMODE_ESS_STA: case WLAN_MACMODE_ESS_STA:
case WLAN_MACMODE_ESS_AP: case WLAN_MACMODE_ESS_AP:
...@@ -410,7 +385,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -410,7 +385,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
* and return success . * and return success .
* TODO: we need a saner way to handle this * TODO: we need a saner way to handle this
*/ */
if(skb->protocol != ETH_P_80211_RAW) { if (skb->protocol != ETH_P_80211_RAW) {
netif_start_queue(wlandev->netdev); netif_start_queue(wlandev->netdev);
printk(KERN_NOTICE printk(KERN_NOTICE
"Tx attempt prior to association, frame dropped.\n"); "Tx attempt prior to association, frame dropped.\n");
...@@ -422,7 +397,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -422,7 +397,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
} }
/* Check for raw transmits */ /* Check for raw transmits */
if(skb->protocol == ETH_P_80211_RAW) { if (skb->protocol == ETH_P_80211_RAW) {
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN)) {
result = 1; result = 1;
goto failed; goto failed;
...@@ -431,7 +406,9 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -431,7 +406,9 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t)); memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t));
skb_pull(skb, sizeof(p80211_hdr_t)); skb_pull(skb, sizeof(p80211_hdr_t));
} else { } else {
if ( skb_ether_to_p80211(wlandev, wlandev->ethconv, skb, &p80211_hdr, &p80211_wep) != 0 ) { if (skb_ether_to_p80211
(wlandev, wlandev->ethconv, skb, &p80211_hdr,
&p80211_wep) != 0) {
/* convert failed */ /* convert failed */
pr_debug("ether_to_80211(%d) failed.\n", pr_debug("ether_to_80211(%d) failed.\n",
wlandev->ethconv); wlandev->ethconv);
...@@ -439,7 +416,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -439,7 +416,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
goto failed; goto failed;
} }
} }
if ( wlandev->txframe == NULL ) { if (wlandev->txframe == NULL) {
result = 1; result = 1;
goto failed; goto failed;
} }
...@@ -452,18 +429,18 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -452,18 +429,18 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
txresult = wlandev->txframe(wlandev, skb, &p80211_hdr, &p80211_wep); txresult = wlandev->txframe(wlandev, skb, &p80211_hdr, &p80211_wep);
if ( txresult == 0) { if (txresult == 0) {
/* success and more buf */ /* success and more buf */
/* avail, re: hw_txdata */ /* avail, re: hw_txdata */
netif_wake_queue(wlandev->netdev); netif_wake_queue(wlandev->netdev);
result = 0; result = 0;
} else if ( txresult == 1 ) { } else if (txresult == 1) {
/* success, no more avail */ /* success, no more avail */
pr_debug("txframe success, no more bufs\n"); pr_debug("txframe success, no more bufs\n");
/* netdev->tbusy = 1; don't set here, irqhdlr */ /* netdev->tbusy = 1; don't set here, irqhdlr */
/* may have already cleared it */ /* may have already cleared it */
result = 0; result = 0;
} else if ( txresult == 2 ) { } else if (txresult == 2) {
/* alloc failure, drop frame */ /* alloc failure, drop frame */
pr_debug("txframe returned alloc_fail\n"); pr_debug("txframe returned alloc_fail\n");
result = 1; result = 1;
...@@ -473,7 +450,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -473,7 +450,7 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
result = 1; result = 1;
} }
failed: failed:
/* Free up the WEP buffer if it's not the same as the skb */ /* Free up the WEP buffer if it's not the same as the skb */
if ((p80211_wep.data) && (p80211_wep.data != skb->data)) if ((p80211_wep.data) && (p80211_wep.data != skb->data))
kfree(p80211_wep.data); kfree(p80211_wep.data);
...@@ -485,7 +462,6 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd ...@@ -485,7 +462,6 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
return result; return result;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211knetdev_set_multicast_list * p80211knetdev_set_multicast_list
* *
...@@ -531,9 +507,6 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr) ...@@ -531,9 +507,6 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
snprintf(info.version, sizeof(info.version), "%s", snprintf(info.version, sizeof(info.version), "%s",
WLAN_RELEASE); WLAN_RELEASE);
// info.fw_version
// info.bus_info
if (copy_to_user(useraddr, &info, sizeof(info))) if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -589,7 +562,7 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr) ...@@ -589,7 +562,7 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
{ {
int result = 0; int result = 0;
p80211ioctl_req_t *req = (p80211ioctl_req_t*)ifr; p80211ioctl_req_t *req = (p80211ioctl_req_t *) ifr;
wlandevice_t *wlandev = dev->ml_priv; wlandevice_t *wlandev = dev->ml_priv;
u8 *msgbuf; u8 *msgbuf;
...@@ -597,35 +570,36 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) ...@@ -597,35 +570,36 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)
#ifdef SIOCETHTOOL #ifdef SIOCETHTOOL
if (cmd == SIOCETHTOOL) { if (cmd == SIOCETHTOOL) {
result = p80211netdev_ethtool(wlandev, (void __user *) ifr->ifr_data); result =
p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data);
goto bail; goto bail;
} }
#endif #endif
/* Test the magic, assume ifr is good if it's there */ /* Test the magic, assume ifr is good if it's there */
if ( req->magic != P80211_IOCTL_MAGIC ) { if (req->magic != P80211_IOCTL_MAGIC) {
result = -ENOSYS; result = -ENOSYS;
goto bail; goto bail;
} }
if ( cmd == P80211_IFTEST ) { if (cmd == P80211_IFTEST) {
result = 0; result = 0;
goto bail; goto bail;
} else if ( cmd != P80211_IFREQ ) { } else if (cmd != P80211_IFREQ) {
result = -ENOSYS; result = -ENOSYS;
goto bail; goto bail;
} }
/* Allocate a buf of size req->len */ /* Allocate a buf of size req->len */
if ((msgbuf = kmalloc( req->len, GFP_KERNEL))) { if ((msgbuf = kmalloc(req->len, GFP_KERNEL))) {
if ( copy_from_user( msgbuf, (void __user *) req->data, req->len) ) { if (copy_from_user(msgbuf, (void __user *)req->data, req->len))
result = -EFAULT; result = -EFAULT;
} else { else
result = p80211req_dorequest( wlandev, msgbuf); result = p80211req_dorequest(wlandev, msgbuf);
}
if ( result == 0 ) { if (result == 0) {
if ( copy_to_user( (void __user *) req->data, msgbuf, req->len)) { if (copy_to_user
((void __user *)req->data, msgbuf, req->len)) {
result = -EFAULT; result = -EFAULT;
} }
} }
...@@ -672,13 +646,12 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) ...@@ -672,13 +646,12 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
int result = 0; int result = 0;
/* If we're running, we don't allow MAC address changes */ /* If we're running, we don't allow MAC address changes */
if (netif_running(dev)) { if (netif_running(dev))
return -EBUSY; return -EBUSY;
}
/* Set up some convenience pointers. */ /* Set up some convenience pointers. */
mibattr = &dot11req.mibattribute; mibattr = &dot11req.mibattribute;
macaddr = (p80211item_pstr6_t*)&mibattr->data; macaddr = (p80211item_pstr6_t *)&mibattr->data;
resultcode = &dot11req.resultcode; resultcode = &dot11req.resultcode;
/* Set up a dot11req_mibset */ /* Set up a dot11req_mibset */
...@@ -686,8 +659,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) ...@@ -686,8 +659,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
dot11req.msgcode = DIDmsg_dot11req_mibset; dot11req.msgcode = DIDmsg_dot11req_mibset;
dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t); dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t);
memcpy(dot11req.devname, memcpy(dot11req.devname,
((wlandevice_t *)dev->ml_priv)->name, ((wlandevice_t *) dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1);
WLAN_DEVNAMELEN_MAX - 1);
/* Set up the mibattribute argument */ /* Set up the mibattribute argument */
mibattr->did = DIDmsg_dot11req_mibset_mibattribute; mibattr->did = DIDmsg_dot11req_mibset_mibattribute;
...@@ -712,7 +684,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) ...@@ -712,7 +684,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
/* If the request wasn't successful, report an error and don't /* If the request wasn't successful, report an error and don't
* change the netdev address * change the netdev address
*/ */
if ( result != 0 || resultcode->data != P80211ENUM_resultcode_success) { if (result != 0 || resultcode->data != P80211ENUM_resultcode_success) {
printk(KERN_ERR printk(KERN_ERR
"Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); "Low-level driver failed dot11req_mibset(dot11MACAddress).\n");
result = -EADDRNOTAVAIL; result = -EADDRNOTAVAIL;
...@@ -726,9 +698,9 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) ...@@ -726,9 +698,9 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
static int wlan_change_mtu(netdevice_t *dev, int new_mtu) static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
{ {
// 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap) /* 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
// and another 8 for wep. and another 8 for wep. */
if ( (new_mtu < 68) || (new_mtu > (2312 - 20 - 8))) if ((new_mtu < 68) || (new_mtu > (2312 - 20 - 8)))
return -EINVAL; return -EINVAL;
dev->mtu = new_mtu; dev->mtu = new_mtu;
...@@ -736,8 +708,6 @@ static int wlan_change_mtu(netdevice_t *dev, int new_mtu) ...@@ -736,8 +708,6 @@ static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* wlan_setup * wlan_setup
* *
...@@ -773,12 +743,11 @@ int wlan_setup(wlandevice_t *wlandev) ...@@ -773,12 +743,11 @@ int wlan_setup(wlandevice_t *wlandev)
/* Set up the rx queue */ /* Set up the rx queue */
skb_queue_head_init(&wlandev->nsd_rxq); skb_queue_head_init(&wlandev->nsd_rxq);
tasklet_init(&wlandev->rx_bh, tasklet_init(&wlandev->rx_bh,
p80211netdev_rx_bh, p80211netdev_rx_bh, (unsigned long)wlandev);
(unsigned long)wlandev);
/* Allocate and initialize the struct device */ /* Allocate and initialize the struct device */
dev = alloc_netdev(0,"wlan%d",ether_setup); dev = alloc_netdev(0, "wlan%d", ether_setup);
if ( dev == NULL ) { if (dev == NULL) {
printk(KERN_ERR "Failed to alloc netdev.\n"); printk(KERN_ERR "Failed to alloc netdev.\n");
result = 1; result = 1;
} else { } else {
...@@ -845,7 +814,7 @@ int wlan_unsetup(wlandevice_t *wlandev) ...@@ -845,7 +814,7 @@ int wlan_unsetup(wlandevice_t *wlandev)
tasklet_kill(&wlandev->rx_bh); tasklet_kill(&wlandev->rx_bh);
if (wlandev->netdev == NULL ) { if (wlandev->netdev == NULL) {
printk(KERN_ERR "called without wlandev->netdev set.\n"); printk(KERN_ERR "called without wlandev->netdev set.\n");
result = 1; result = 1;
} else { } else {
...@@ -856,8 +825,6 @@ int wlan_unsetup(wlandevice_t *wlandev) ...@@ -856,8 +825,6 @@ int wlan_unsetup(wlandevice_t *wlandev)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* register_wlandev * register_wlandev
* *
...@@ -888,7 +855,6 @@ int register_wlandev(wlandevice_t *wlandev) ...@@ -888,7 +855,6 @@ int register_wlandev(wlandevice_t *wlandev)
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* unregister_wlandev * unregister_wlandev
* *
...@@ -913,14 +879,12 @@ int unregister_wlandev(wlandevice_t *wlandev) ...@@ -913,14 +879,12 @@ int unregister_wlandev(wlandevice_t *wlandev)
unregister_netdev(wlandev->netdev); unregister_netdev(wlandev->netdev);
/* Now to clean out the rx queue */ /* Now to clean out the rx queue */
while ( (skb = skb_dequeue(&wlandev->nsd_rxq)) ) { while ((skb = skb_dequeue(&wlandev->nsd_rxq)))
dev_kfree_skb(skb); dev_kfree_skb(skb);
}
return 0; return 0;
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211netdev_hwremoved * p80211netdev_hwremoved
* *
...@@ -954,14 +918,12 @@ int unregister_wlandev(wlandevice_t *wlandev) ...@@ -954,14 +918,12 @@ int unregister_wlandev(wlandevice_t *wlandev)
void p80211netdev_hwremoved(wlandevice_t *wlandev) void p80211netdev_hwremoved(wlandevice_t *wlandev)
{ {
wlandev->hwremoved = 1; wlandev->hwremoved = 1;
if ( wlandev->state == WLAN_DEVICE_OPEN) { if (wlandev->state == WLAN_DEVICE_OPEN)
netif_stop_queue(wlandev->netdev); netif_stop_queue(wlandev->netdev);
}
netif_device_detach(wlandev->netdev); netif_device_detach(wlandev->netdev);
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
* p80211_rx_typedrop * p80211_rx_typedrop
* *
...@@ -983,7 +945,7 @@ void p80211netdev_hwremoved(wlandevice_t *wlandev) ...@@ -983,7 +945,7 @@ void p80211netdev_hwremoved(wlandevice_t *wlandev)
* Call context: * Call context:
* interrupt * interrupt
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc)
{ {
u16 ftype; u16 ftype;
u16 fstype; u16 fstype;
...@@ -992,10 +954,9 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) ...@@ -992,10 +954,9 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
ftype = WLAN_GET_FC_FTYPE(fc); ftype = WLAN_GET_FC_FTYPE(fc);
fstype = WLAN_GET_FC_FSTYPE(fc); fstype = WLAN_GET_FC_FSTYPE(fc);
#if 0 #if 0
pr_debug( pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
"rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
#endif #endif
switch ( ftype ) { switch (ftype) {
case WLAN_FTYPE_MGMT: case WLAN_FTYPE_MGMT:
if ((wlandev->netdev->flags & IFF_PROMISC) || if ((wlandev->netdev->flags & IFF_PROMISC) ||
(wlandev->netdev->flags & IFF_ALLMULTI)) { (wlandev->netdev->flags & IFF_ALLMULTI)) {
...@@ -1004,7 +965,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) ...@@ -1004,7 +965,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
} }
pr_debug("rx'd mgmt:\n"); pr_debug("rx'd mgmt:\n");
wlandev->rx.mgmt++; wlandev->rx.mgmt++;
switch( fstype ) { switch (fstype) {
case WLAN_FSTYPE_ASSOCREQ: case WLAN_FSTYPE_ASSOCREQ:
/* printk("assocreq"); */ /* printk("assocreq"); */
wlandev->rx.assocreq++; wlandev->rx.assocreq++;
...@@ -1066,7 +1027,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) ...@@ -1066,7 +1027,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
} }
pr_debug("rx'd ctl:\n"); pr_debug("rx'd ctl:\n");
wlandev->rx.ctl++; wlandev->rx.ctl++;
switch( fstype ) { switch (fstype) {
case WLAN_FSTYPE_PSPOLL: case WLAN_FSTYPE_PSPOLL:
/* printk("pspoll"); */ /* printk("pspoll"); */
wlandev->rx.pspoll++; wlandev->rx.pspoll++;
...@@ -1102,7 +1063,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) ...@@ -1102,7 +1063,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
case WLAN_FTYPE_DATA: case WLAN_FTYPE_DATA:
wlandev->rx.data++; wlandev->rx.data++;
switch( fstype ) { switch (fstype) {
case WLAN_FSTYPE_DATAONLY: case WLAN_FSTYPE_DATAONLY:
wlandev->rx.dataonly++; wlandev->rx.dataonly++;
break; break;
...@@ -1142,7 +1103,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc) ...@@ -1142,7 +1103,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
return drop; return drop;
} }
static void p80211knetdev_tx_timeout( netdevice_t *netdev) static void p80211knetdev_tx_timeout(netdevice_t *netdev)
{ {
wlandevice_t *wlandev = netdev->ml_priv; wlandevice_t *wlandev = netdev->ml_priv;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册