Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4b3f0da authored by Moritz Muehlenhoff's avatar Moritz Muehlenhoff Committed by Greg Kroah-Hartman
Browse files

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

parent f3422882
Loading
Loading
Loading
Loading
+128 −167
Original line number Diff line number Diff line
@@ -49,13 +49,7 @@
* --------------------------------------------------------------------
*/


/*================================================================*/
/* System Includes */


#include <linux/version.h>

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -72,9 +66,8 @@
#include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <linux/byteorder/generic.h>

#include <asm/bitops.h>
#include <asm/uaccess.h>
#include <linux/bitops.h>
#include <linux/uaccess.h>
#include <asm/byteorder.h>

#ifdef SIOCETHTOOL
@@ -99,19 +92,6 @@
#include "p80211metastruct.h"
#include "p80211metadef.h"

/*================================================================*/
/* Local Constants */

/*================================================================*/
/* Local Macros */


/*================================================================*/
/* Local Types */

/*================================================================*/
/* Local Function Declarations */

/* Support functions */
static void p80211netdev_rx_bh(unsigned long arg);

@@ -120,9 +100,11 @@ static int p80211knetdev_init( netdevice_t *netdev);
static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev);
static int p80211knetdev_open(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 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 void p80211knetdev_tx_timeout(netdevice_t *netdev);
static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc);
@@ -135,9 +117,6 @@ int wlan_wext_write = 1;
module_param(wlan_wext_write, int, 0644);
MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");

/*================================================================*/
/* Function Definitions */

/*----------------------------------------------------------------
* p80211knetdev_init
*
@@ -159,7 +138,6 @@ static int p80211knetdev_init( netdevice_t *netdev)
	return 0;
}


/*----------------------------------------------------------------
* p80211knetdev_get_stats
*
@@ -174,8 +152,7 @@ static int p80211knetdev_init( netdevice_t *netdev)
* Returns:
*	the address of the statistics structure
----------------------------------------------------------------*/
static struct net_device_stats*
p80211knetdev_get_stats(netdevice_t *netdev)
static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev)
{
	wlandevice_t *wlandev = netdev->ml_priv;

@@ -185,7 +162,6 @@ p80211knetdev_get_stats(netdevice_t *netdev)
	return &(wlandev->linux_stats);
}


/*----------------------------------------------------------------
* p80211knetdev_open
*
@@ -206,9 +182,8 @@ static int p80211knetdev_open( netdevice_t *netdev )
	wlandevice_t *wlandev = netdev->ml_priv;

	/* Check to make sure the MSD is running */
	if ( wlandev->msdstate != WLAN_MSD_RUNNING ) {
	if (wlandev->msdstate != WLAN_MSD_RUNNING)
		return -ENODEV;
	}

	/* Tell the MSD to open */
	if (wlandev->open != NULL) {
@@ -224,7 +199,6 @@ static int p80211knetdev_open( netdevice_t *netdev )
	return result;
}


/*----------------------------------------------------------------
* p80211knetdev_stop
*
@@ -242,9 +216,8 @@ static int p80211knetdev_stop( netdevice_t *netdev )
	int result = 0;
	wlandevice_t *wlandev = netdev->ml_priv;

	if ( wlandev->close != NULL ) {
	if (wlandev->close != NULL)
		result = wlandev->close(wlandev);
	}

	netif_stop_queue(wlandev->netdev);
	wlandev->state = WLAN_DEVICE_CLOSED;
@@ -265,8 +238,7 @@ static int p80211knetdev_stop( netdevice_t *netdev )
* Side effects:
*
----------------------------------------------------------------*/
void
p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb )
void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb)
{
	/* Enqueue for post-irq processing */
	skb_queue_tail(&wlandev->nsd_rxq, skb);
@@ -303,7 +275,7 @@ static void p80211netdev_rx_bh(unsigned long arg)

			if (dev->type != ARPHRD_ETHER) {
				/* 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 */
				skb->dev = dev;
@@ -328,7 +300,9 @@ static void p80211netdev_rx_bh(unsigned long arg)
				/* perform mcast filtering */
				if (wlandev->netdev->flags & IFF_ALLMULTI) {
					/* 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 */
						if (!(hdr->a1[0] & 0x01)) {
							dev_kfree_skb(skb);
@@ -337,10 +311,12 @@ 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;
					wlandev->linux_stats.rx_packets++;
					wlandev->linux_stats.rx_bytes += skb->len;
					wlandev->linux_stats.rx_bytes +=
					    skb->len;
					netif_rx_ni(skb);
					continue;
				}
@@ -351,7 +327,6 @@ static void p80211netdev_rx_bh(unsigned long arg)
	}
}


/*----------------------------------------------------------------
* p80211knetdev_hard_start_xmit
*
@@ -371,7 +346,8 @@ static void p80211netdev_rx_bh(unsigned long arg)
* Returns:
*	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 txresult = -1;
@@ -379,9 +355,8 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
	p80211_hdr_t p80211_hdr;
	p80211_metawep_t p80211_wep;

	if (skb == NULL) {
	if (skb == NULL)
		return 0;
	}

	if (wlandev->state != WLAN_DEVICE_OPEN) {
		result = 1;
@@ -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));
		skb_pull(skb, sizeof(p80211_hdr_t));
	} 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 */
			pr_debug("ether_to_80211(%d) failed.\n",
			       wlandev->ethconv);
@@ -485,7 +462,6 @@ static int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netd
	return result;
}


/*----------------------------------------------------------------
* p80211knetdev_set_multicast_list
*
@@ -531,9 +507,6 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
		snprintf(info.version, sizeof(info.version), "%s",
			 WLAN_RELEASE);

		// info.fw_version
		// info.bus_info

		if (copy_to_user(useraddr, &info, sizeof(info)))
			return -EFAULT;
		return 0;
@@ -597,7 +570,8 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)

#ifdef SIOCETHTOOL
	if (cmd == SIOCETHTOOL) {
		result = p80211netdev_ethtool(wlandev, (void __user *) ifr->ifr_data);
		result =
		    p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data);
		goto bail;
	}
#endif
@@ -618,14 +592,14 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd)

	/* Allocate a buf of size req->len */
	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;
		} else {
		else
			result = p80211req_dorequest(wlandev, msgbuf);
		}

		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;
			}
		}
@@ -672,9 +646,8 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)
	int result = 0;

	/* If we're running, we don't allow MAC address changes */
	if (netif_running(dev)) {
	if (netif_running(dev))
		return -EBUSY;
	}

	/* Set up some convenience pointers. */
	mibattr = &dot11req.mibattribute;
@@ -686,8 +659,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->ml_priv)->name,
		WLAN_DEVNAMELEN_MAX - 1);
	       ((wlandevice_t *) dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1);

	/* Set up the mibattribute argument */
	mibattr->did = DIDmsg_dot11req_mibset_mibattribute;
@@ -726,8 +698,8 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr)

static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
{
	// 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
	// and another 8 for wep.
	/* 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
	   and another 8 for wep. */
	if ((new_mtu < 68) || (new_mtu > (2312 - 20 - 8)))
		return -EINVAL;

@@ -736,8 +708,6 @@ static int wlan_change_mtu(netdevice_t *dev, int new_mtu)
	return 0;
}



/*----------------------------------------------------------------
* wlan_setup
*
@@ -773,8 +743,7 @@ int wlan_setup(wlandevice_t *wlandev)
	/* Set up the rx queue */
	skb_queue_head_init(&wlandev->nsd_rxq);
	tasklet_init(&wlandev->rx_bh,
		     p80211netdev_rx_bh,
		     (unsigned long)wlandev);
		     p80211netdev_rx_bh, (unsigned long)wlandev);

	/* Allocate and initialize the struct device */
	dev = alloc_netdev(0, "wlan%d", ether_setup);
@@ -856,8 +825,6 @@ int wlan_unsetup(wlandevice_t *wlandev)
	return 0;
}



/*----------------------------------------------------------------
* register_wlandev
*
@@ -888,7 +855,6 @@ int register_wlandev(wlandevice_t *wlandev)
	return 0;
}


/*----------------------------------------------------------------
* unregister_wlandev
*
@@ -913,14 +879,12 @@ int unregister_wlandev(wlandevice_t *wlandev)
	unregister_netdev(wlandev->netdev);

	/* 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);
	}

	return 0;
}


/*----------------------------------------------------------------
* p80211netdev_hwremoved
*
@@ -954,14 +918,12 @@ int unregister_wlandev(wlandevice_t *wlandev)
void p80211netdev_hwremoved(wlandevice_t *wlandev)
{
	wlandev->hwremoved = 1;
	if ( wlandev->state == WLAN_DEVICE_OPEN) {
	if (wlandev->state == WLAN_DEVICE_OPEN)
		netif_stop_queue(wlandev->netdev);
	}

	netif_device_detach(wlandev->netdev);
}


/*----------------------------------------------------------------
* p80211_rx_typedrop
*
@@ -992,8 +954,7 @@ static int p80211_rx_typedrop( wlandevice_t *wlandev, u16 fc)
	ftype = WLAN_GET_FC_FTYPE(fc);
	fstype = WLAN_GET_FC_FSTYPE(fc);
#if 0
	pr_debug(
		"rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
	pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype);
#endif
	switch (ftype) {
	case WLAN_FTYPE_MGMT: