patch-2.3.99-pre3 linux/net/atm/signaling.c

Next file: linux/net/atm/signaling.h
Previous file: linux/net/atm/resources.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre2/linux/net/atm/signaling.c linux/net/atm/signaling.c
@@ -12,6 +12,7 @@
 #include <linux/atmsap.h>
 #include <linux/atmsvc.h>
 #include <linux/atmdev.h>
+#include <linux/bitops.h>
 
 #include "resources.h"
 #include "signaling.h"
@@ -30,29 +31,33 @@
 
 
 struct atm_vcc *sigd = NULL;
-static wait_queue_head_t sigd_sleep;
+static DECLARE_WAIT_QUEUE_HEAD(sigd_sleep);
 
 
 static void sigd_put_skb(struct sk_buff *skb)
 {
 #ifdef WAIT_FOR_DEMON
 	static unsigned long silence = 0;
-#endif
+	DECLARE_WAITQUEUE(wait,current);
 
+	add_wait_queue(&sigd_sleep,&wait);
 	while (!sigd) {
-#ifdef WAIT_FOR_DEMON
+		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (time_after(jiffies, silence) || silence == 0) {
 			printk(KERN_INFO "atmsvc: waiting for signaling demon "
 			    "...\n");
 			silence = (jiffies+30*HZ)|1;
 		}
-		sleep_on(&sigd_sleep);
+		schedule();
+	}
+	remove_wait_queue(&sigd_sleep,&wait);
 #else
+	if (!sigd) {
 		printk(KERN_WARNING "atmsvc: no signaling demon\n");
 		kfree_skb(skb);
 		return;
-#endif
 	}
+#endif
 	atm_force_charge(sigd,skb->truesize);
 	skb_queue_tail(&sigd->recvq,skb);
 	wake_up(&sigd->sleep);
@@ -63,7 +68,8 @@
 {
 	struct sk_buff *skb;
 
-	if ((vcc->flags & ATM_VF_RELEASED) || !(vcc->flags & ATM_VF_READY))
+	if (test_bit(ATM_VF_RELEASED,&vcc->flags) ||
+	    !test_bit(ATM_VF_READY,&vcc->flags))
 		return;
 	msg->type = as_error;
 	if (!vcc->dev->ops->change_qos) msg->reply = -EOPNOTSUPP;
@@ -114,7 +120,8 @@
 				session_vcc->qos = msg->qos;
 			break;
 		case as_error:
-			vcc->flags &= ~(ATM_VF_REGIS | ATM_VF_READY);
+			clear_bit(ATM_VF_REGIS,&vcc->flags);
+			clear_bit(ATM_VF_READY,&vcc->flags);
 			vcc->reply = msg->reply;
 			break;
 		case as_indicate:
@@ -133,8 +140,8 @@
 			}
 			return 0;
 		case as_close:
-			vcc->flags |= ATM_VF_RELEASED;
-			vcc->flags &= ~ATM_VF_READY;
+			set_bit(ATM_VF_RELEASED,&vcc->flags);
+			clear_bit(ATM_VF_READY,&vcc->flags);
 			vcc->reply = msg->reply;
 			break;
 		case as_modify:
@@ -177,7 +184,7 @@
 	if (!pvc) memset(&msg->pvc,0,sizeof(msg->pvc));
 	else msg->pvc = *pvc;
 	sigd_put_skb(skb);
-	if (vcc) vcc->flags |= ATM_VF_REGIS;
+	if (vcc) set_bit(ATM_VF_REGIS,&vcc->flags);
 }
 
 
@@ -185,8 +192,8 @@
 {
 	while (vcc) {
 		if (vcc->family == PF_ATMSVC &&
-		    !(vcc->flags & ATM_VF_META)) {
-			vcc->flags |= ATM_VF_RELEASED;
+		    !test_bit(ATM_VF_META,&vcc->flags)) {
+			set_bit(ATM_VF_RELEASED,&vcc->flags);
 			vcc->reply = -EUNATCH;
 			wake_up(&vcc->sleep);
 		}
@@ -223,7 +230,7 @@
 	999,		/* dummy device number */
 	NULL,NULL,	/* pretend not to have any VCCs */
 	NULL,NULL,	/* no data */
-	0,		/* no flags */
+	{ 0 },		/* no flags */
 	NULL,		/* no local address */
 	{ 0 }		/* no ESI, no statistics */
 };
@@ -235,13 +242,8 @@
 	DPRINTK("sigd_attach\n");
 	sigd = vcc;
 	bind_vcc(vcc,&sigd_dev);
-	vcc->flags |= ATM_VF_READY | ATM_VF_META;
+	set_bit(ATM_VF_META,&vcc->flags);
+	set_bit(ATM_VF_READY,&vcc->flags);
 	wake_up(&sigd_sleep);
 	return 0;
-}
-
-
-void signaling_init(void)
-{
-	init_waitqueue_head(&sigd_sleep);
 }

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