headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / infiniband / hw / ipath / ipath_verbs_mcast.c
index ee0e1d9..6923e1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 QLogic, Inc. All rights reserved.
+ * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
  * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -31,8 +31,8 @@
  * SOFTWARE.
  */
 
-#include <linux/list.h>
-#include <linux/rcupdate.h>
+#include <linux/rculist.h>
+#include <linux/sched.h>
 
 #include "ipath_verbs.h"
 
@@ -165,10 +165,9 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
 {
        struct rb_node **n = &mcast_tree.rb_node;
        struct rb_node *pn = NULL;
-       unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&mcast_lock, flags);
+       spin_lock_irq(&mcast_lock);
 
        while (*n) {
                struct ipath_mcast *tmcast;
@@ -207,12 +206,17 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
                goto bail;
        }
 
+       spin_lock(&dev->n_mcast_grps_lock);
        if (dev->n_mcast_grps_allocated == ib_ipath_max_mcast_grps) {
+               spin_unlock(&dev->n_mcast_grps_lock);
                ret = ENOMEM;
                goto bail;
        }
 
        dev->n_mcast_grps_allocated++;
+       spin_unlock(&dev->n_mcast_grps_lock);
+
+       mcast->n_attached++;
 
        list_add_tail_rcu(&mqp->list, &mcast->qp_list);
 
@@ -223,7 +227,7 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
        ret = 0;
 
 bail:
-       spin_unlock_irqrestore(&mcast_lock, flags);
+       spin_unlock_irq(&mcast_lock);
 
        return ret;
 }
@@ -284,17 +288,16 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
        struct ipath_mcast *mcast = NULL;
        struct ipath_mcast_qp *p, *tmp;
        struct rb_node *n;
-       unsigned long flags;
        int last = 0;
        int ret;
 
-       spin_lock_irqsave(&mcast_lock, flags);
+       spin_lock_irq(&mcast_lock);
 
        /* Find the GID in the mcast table. */
        n = mcast_tree.rb_node;
        while (1) {
                if (n == NULL) {
-                       spin_unlock_irqrestore(&mcast_lock, flags);
+                       spin_unlock_irq(&mcast_lock);
                        ret = -EINVAL;
                        goto bail;
                }
@@ -329,7 +332,7 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
                break;
        }
 
-       spin_unlock_irqrestore(&mcast_lock, flags);
+       spin_unlock_irq(&mcast_lock);
 
        if (p) {
                /*
@@ -343,7 +346,9 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
                atomic_dec(&mcast->refcount);
                wait_event(mcast->wait, !atomic_read(&mcast->refcount));
                ipath_mcast_free(mcast);
+               spin_lock_irq(&dev->n_mcast_grps_lock);
                dev->n_mcast_grps_allocated--;
+               spin_unlock_irq(&dev->n_mcast_grps_lock);
        }
 
        ret = 0;