patch-2.4.0-prerelease linux/drivers/net/hamradio/bpqether.c

Next file: linux/drivers/net/hamradio/mkiss.c
Previous file: linux/drivers/net/hamradio/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test12/linux/drivers/net/hamradio/bpqether.c linux/drivers/net/hamradio/bpqether.c
@@ -1,5 +1,5 @@
 /*
- *	G8BPQ compatible "AX.25 via ethernet" driver release 003
+ *	G8BPQ compatible "AX.25 via ethernet" driver release 004
  *
  *	This code REQUIRES 2.0.0 or higher/ NET3.029
  *
@@ -65,6 +65,7 @@
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
+#include <linux/if_ether.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
@@ -86,6 +87,8 @@
 
 #include <linux/bpqether.h>
 
+static const char banner[] __initdata = KERN_INFO "AX.25: bpqether driver version 004\n";
+
 static unsigned char ax25_bcast[AX25_ADDR_LEN] =
 	{'Q' << 1, 'S' << 1, 'T' << 1, ' ' << 1, ' ' << 1, ' ' << 1, '0' << 1};
 static unsigned char ax25_defaddr[AX25_ADDR_LEN] =
@@ -100,16 +103,12 @@
 static char *bpq_print_ethaddr(unsigned char *);
 
 static struct packet_type bpq_packet_type = {
-	0,		/* ntohs(ETH_P_BPQ),*/
-	0,		/* copy */
-	bpq_rcv,
-	NULL,
-	NULL,
+	type:	__constant_htons(ETH_P_BPQ),
+	func:	bpq_rcv,
 };
 
 static struct notifier_block bpq_dev_notifier = {
-	bpq_device_event,
-	0
+	notifier_call:	bpq_device_event,
 };
 
 
@@ -123,7 +122,7 @@
 	struct net_device_stats stats;	/* some statistics */
 	char   dest_addr[6];		/* ether destination address */
 	char   acpt_addr[6];		/* accept ether frames from this address only */
-} *bpq_devices = NULL;
+} *bpq_devices;
 
 
 /* ------------------------------------------------------------------------ */
@@ -132,19 +131,17 @@
 /*
  *	Get the ethernet device for a BPQ device
  */
-static __inline__ struct net_device *bpq_get_ether_dev(struct net_device *dev)
+static inline struct net_device *bpq_get_ether_dev(struct net_device *dev)
 {
-	struct bpqdev *bpq;
-
-	bpq = (struct bpqdev *)dev->priv;
+	struct bpqdev *bpq = (struct bpqdev *) dev->priv;
 
-	return (bpq != NULL) ? bpq->ethdev : NULL;
+	return bpq ? bpq->ethdev : NULL;
 }
 
 /*
  *	Get the BPQ device for the ethernet device
  */
-static __inline__ struct net_device *bpq_get_ax25_dev(struct net_device *dev)
+static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev)
 {
 	struct bpqdev *bpq;
 
@@ -155,7 +152,7 @@
 	return NULL;
 }
 
-static __inline__ int dev_is_ethdev(struct net_device *dev)
+static inline int dev_is_ethdev(struct net_device *dev)
 {
 	return (
 			dev->type == ARPHRD_ETHER
@@ -245,8 +242,8 @@
 	skb_pull(skb, 2);	/* Remove the length bytes */
 	skb_trim(skb, len);	/* Set the length of the data */
 
-	((struct bpqdev *)dev->priv)->stats.rx_packets++;
-	((struct bpqdev *)dev->priv)->stats.rx_bytes+=len;
+	bpq->stats.rx_packets++;
+	bpq->stats.rx_bytes += len;
 
 	ptr = skb_push(skb, 1);
 	*ptr = 0;
@@ -333,9 +330,7 @@
  */
 static struct net_device_stats *bpq_get_stats(struct net_device *dev)
 {
-	struct bpqdev *bpq;
-
-	bpq = (struct bpqdev *)dev->priv;
+	struct bpqdev *bpq = (struct bpqdev *) dev->priv;
 
 	return &bpq->stats;
 }
@@ -361,7 +356,6 @@
  */
 static int bpq_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-	int err;
 	struct bpq_ethaddr *ethaddr = (struct bpq_ethaddr *)ifr->ifr_data;
 	struct bpqdev *bpq = dev->priv;
 	struct bpq_req req;
@@ -374,9 +368,8 @@
 
 	switch (cmd) {
 		case SIOCSBPQETHOPT:
-			if ((err = verify_area(VERIFY_WRITE, ifr->ifr_data, sizeof(struct bpq_req))) != 0)
-				return err;
-			copy_from_user(&req, ifr->ifr_data, sizeof(struct bpq_req));
+			if (copy_from_user(&req, ifr->ifr_data, sizeof(struct bpq_req)))
+				return -EFAULT;
 			switch (req.cmd) {
 				case SIOCGBPQETHPARAM:
 				case SIOCSBPQETHPARAM:
@@ -387,10 +380,10 @@
 			break;
 
 		case SIOCSBPQETHADDR:
-			if ((err = verify_area(VERIFY_READ, ethaddr, sizeof(struct bpq_ethaddr))) != 0)
-				return err;
-			copy_from_user(bpq->dest_addr, ethaddr->destination, ETH_ALEN);
-			copy_from_user(bpq->acpt_addr, ethaddr->accept, ETH_ALEN);
+			if (copy_from_user(bpq->dest_addr, ethaddr->destination, ETH_ALEN))
+				return -EFAULT;
+			if (copy_from_user(bpq->acpt_addr, ethaddr->accept, ETH_ALEN))
+				return -EFAULT;
 			break;
 
 		default:
@@ -617,14 +610,13 @@
 {
 	struct net_device *dev;
 
-	bpq_packet_type.type  = htons(ETH_P_BPQ);
 	dev_add_pack(&bpq_packet_type);
 
 	register_netdevice_notifier(&bpq_dev_notifier);
 
-	printk(KERN_INFO "AX.25: bpqether driver version 0.01\n");
+	printk(banner);
 
-	proc_net_create ("bpqether", 0, bpq_get_info);
+	proc_net_create("bpqether", 0, bpq_get_info);
 
 	read_lock_bh(&dev_base_lock);
 	for (dev = dev_base; dev != NULL; dev = dev->next) {
@@ -646,7 +638,7 @@
 
 	unregister_netdevice_notifier(&bpq_dev_notifier);
 
-	proc_net_remove ("bpqether");
+	proc_net_remove("bpqether");
 
 	for (bpq = bpq_devices; bpq != NULL; bpq = bpq->next)
 		unregister_netdev(&bpq->axdev);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)