patch-2.3.19 linux/net/irda/irda_device.c

Next file: linux/net/irda/irlan/Config.in
Previous file: linux/net/irda/ircomm/ircomm_tty_ioctl.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.18/linux/net/irda/irda_device.c linux/net/irda/irda_device.c
@@ -1,12 +1,12 @@
 /*********************************************************************
  *                
  * Filename:      irda_device.c
- * Version:       0.5
+ * Version:       0.6
  * Description:   Abstract device driver layer and helper functions
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Wed Sep  2 20:22:08 1998
- * Modified at:   Tue Aug 24 14:31:13 1999
+ * Modified at:   Tue Sep 28 08:40:31 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * Modified at:   Fri May 28  3:11 CST 1999
  * Modified by:   Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
@@ -155,16 +155,16 @@
 
 	/* Allocate memory if needed */
 	if (self->rx_buff.truesize > 0) {
-		self->rx_buff.head = ( __u8 *) kmalloc(self->rx_buff.truesize,
-						       self->rx_buff.flags);
+		self->rx_buff.head = (__u8 *) kmalloc(self->rx_buff.truesize,
+						      self->rx_buff.flags);
 		if (self->rx_buff.head == NULL)
 			return -ENOMEM;
 
 		memset(self->rx_buff.head, 0, self->rx_buff.truesize);
 	}
 	if (self->tx_buff.truesize > 0) {
-		self->tx_buff.head = ( __u8 *) kmalloc(self->tx_buff.truesize, 
-						       self->tx_buff.flags);
+		self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, 
+						      self->tx_buff.flags);
 		if (self->tx_buff.head == NULL) {
 			kfree(self->rx_buff.head);
 			return -ENOMEM;
@@ -191,14 +191,15 @@
 	/* Initialize IrDA net device */
 	do {
 		sprintf(self->name, "%s%d", "irda", i++);
-	} while (dev_get(self->name) != NULL);
+	} while (dev_get(self->name));
 	
 	self->netdev.name = self->name;
 	self->netdev.priv = (void *) self;
 	self->netdev.next = NULL;
-
-	if ((result = register_netdev(&self->netdev)) != 0) {
-		DEBUG(0, __FUNCTION__ "(), register_netdev() failed!\n");
+	
+	result = register_netdev(&self->netdev);
+	if (result) {
+		ERROR(__FUNCTION__ "(), register_netdev() failed!\n");
 		return -1;
 	}
 	
@@ -213,12 +214,9 @@
 	
 	hashbin_insert(irda_device, (QUEUE *) self, (int) self, NULL);
 	
-	/* Open network device */
-	dev_open(&self->netdev);
-
 	MESSAGE("IrDA: Registered device %s\n", self->name);
 
-	irda_device_set_media_busy(self, FALSE);
+	irda_device_set_media_busy(&self->netdev, FALSE);
 
 	return 0;
 }
@@ -238,8 +236,6 @@
 
 	/* We do this test to know if the device has been registered at all */
 	if (self->netdev.type == ARPHRD_IRDA) {
-		dev_close(&self->netdev);
-		
 		/* Remove netdevice */
 		unregister_netdev(&self->netdev);
 	}
@@ -284,10 +280,14 @@
  *    Called when we have detected that another station is transmiting
  *    in contention mode.
  */
-void irda_device_set_media_busy(struct irda_device *self, int status) 
+void irda_device_set_media_busy(struct net_device *dev, int status) 
 {
+	struct irda_device *self;
+
 	DEBUG(4, __FUNCTION__ "(%s)\n", status ? "TRUE" : "FALSE");
 
+	self = dev->priv;
+
 	ASSERT(self != NULL, return;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return;);
 
@@ -359,7 +359,7 @@
  *    Change the speed of the currently used irda_device
  *
  */
-inline void irda_device_change_speed(struct irda_device *self, int speed)
+void irda_device_change_speed(struct irda_device *self, int speed)
 {
 	ASSERT(self != NULL, return;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return;);
@@ -369,16 +369,24 @@
 				speed);
 }
 
-inline int irda_device_is_media_busy( struct irda_device *self)
+int irda_device_is_media_busy(struct net_device *dev)
 {
+	struct irda_device *self;
+	
+	self = dev->priv;
+
 	ASSERT(self != NULL, return FALSE;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return FALSE;);
 	
 	return self->media_busy;
 }
 
-inline int irda_device_is_receiving( struct irda_device *self)
+int irda_device_is_receiving(struct net_device *dev)
 {
+	struct irda_device *self;
+	
+	self = dev->priv;
+	
 	ASSERT(self != NULL, return FALSE;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return FALSE;);
 
@@ -388,15 +396,21 @@
 		return FALSE;
 }
 
-inline struct qos_info *irda_device_get_qos(struct irda_device *self)
+struct qos_info *irda_device_get_qos(struct net_device *dev)
 {
+	struct irda_device *self;
+
+	ASSERT(dev != NULL, return NULL;);
+
+	self = dev->priv;
+
 	ASSERT(self != NULL, return NULL;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return NULL;);
 
 	return &self->qos;
 }
 
-static struct enet_statistics *irda_device_get_stats( struct net_device *dev)
+static struct enet_statistics *irda_device_get_stats(struct net_device *dev)
 {
 	struct irda_device *priv = (struct irda_device *) dev->priv;
 
@@ -464,7 +478,7 @@
 	 * Open new IrLAP layer instance, now that everything should be
 	 * initialized properly 
 	 */
-	self->irlap = irlap_open(self);
+	self->irlap = irlap_open(dev);
         
 	/* It's now safe to initilize the saddr */
 	memcpy(self->netdev.dev_addr, &self->irlap->saddr, 4);
@@ -508,7 +522,8 @@
 	return 0;
 }
 
-static int irda_device_net_hard_header(struct sk_buff *skb, struct net_device *dev,
+static int irda_device_net_hard_header(struct sk_buff *skb, 
+				       struct net_device *dev,
 				       unsigned short type, void *daddr, 
 				       void *saddr, unsigned len)
 {
@@ -521,22 +536,21 @@
 	return 0;
 }
 
-static int irda_device_net_set_config( struct net_device *dev, struct ifmap *map)
+static int irda_device_net_set_config(struct net_device *dev, 
+				      struct ifmap *map)
 {
 	DEBUG( 0, __FUNCTION__ "()\n");
 
 	return 0;
 }
 
-static int irda_device_net_change_mtu( struct net_device *dev, int new_mtu)
+static int irda_device_net_change_mtu(struct net_device *dev, int new_mtu)
 {
      DEBUG( 0, __FUNCTION__ "()\n");
      
      return 0;  
 }
 
-
-#define SIOCSDONGLE     SIOCDEVPRIVATE
 static int irda_device_net_ioctl(struct net_device *dev, /* ioctl device */
 				 struct ifreq *rq,   /* Data passed */
 				 int	cmd)	     /* Ioctl number */
@@ -548,16 +562,14 @@
 #endif
 	struct irda_device *self;
 
-	DEBUG(4, __FUNCTION__ "()\n");
-
 	ASSERT(dev != NULL, return -1;);
 
-	self = (struct irda_device *) dev->priv;
+	self = dev->priv;
 
 	ASSERT(self != NULL, return -1;);
 	ASSERT(self->magic == IRDA_DEVICE_MAGIC, return -1;);
 
-	DEBUG(0, "%s: ->irda_device_net_ioctl(cmd=0x%X)\n", dev->name, cmd);
+	DEBUG(0, __FUNCTION__ "(), %s, (cmd=0x%X)\n", dev->name, cmd);
 	
 	/* Disable interrupts & save flags */
 	save_flags(flags);
@@ -647,9 +659,15 @@
 #endif 
 		break;
 #endif
+	case SIOCSBANDWIDTH: /* Set bandwidth */
+		irda_device_change_speed(self, rq->ifr_bandwidth);
+		break;
 	case SIOCSDONGLE: /* Set dongle */
 		/* Initialize dongle */
 		irda_device_init_dongle(self, (int) rq->ifr_data);
+		break;
+	case SIOCSMEDIABUSY: /* Set media busy */
+		irda_device_set_media_busy(&self->netdev, TRUE);
 		break;
 	default:
 		ret = -EOPNOTSUPP;

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