[openib-general] [PATCH] Encapsulate finding of id in sa_query.c
Krishna Kumar
krkumar at us.ibm.com
Fri Nov 5 14:01:22 PST 2004
diff -ruNp trunk/src/linux-kernel/infiniband/core/sa_query.c.org trunk/src/linux-kernel/infiniband/core/sa_query.c
--- trunk/src/linux-kernel/infiniband/core/sa_query.c.org 2004-11-05 13:43:10.000000000 -0800
+++ trunk/src/linux-kernel/infiniband/core/sa_query.c 2004-11-05 13:58:47.000000000 -0800
@@ -387,18 +387,21 @@ static void ib_sa_event(struct ib_event_
}
}
-void ib_sa_cancel_query(int id, struct ib_sa_query *query)
+static inline struct ib_sa_query *ib_sa_find_idr(int id)
{
- unsigned long flags;
+ struct ib_sa_query *query
+ unsigned long flags;
spin_lock_irqsave(&idr_lock, flags);
- if (idr_find(&query_idr, query->id) != query) {
- spin_unlock_irqrestore(&idr_lock, flags);
- return;
- }
+ query = idr_find(&query_idr, id);
spin_unlock_irqrestore(&idr_lock, flags);
+ return query;
+}
- ib_cancel_mad(query->port->agent, query->id);
+void ib_sa_cancel_query(int id, struct ib_sa_query *query)
+{
+ if (ib_sa_find_idr(id) == query)
+ ib_cancel_mad(query->port->agent, query->id);
}
EXPORT_SYMBOL(ib_sa_cancel_query);
@@ -638,10 +641,7 @@ static void send_handler(struct ib_mad_a
struct ib_sa_query *query;
unsigned long flags;
- spin_lock_irqsave(&idr_lock, flags);
- query = idr_find(&query_idr, mad_send_wc->wr_id);
- spin_unlock_irqrestore(&idr_lock, flags);
-
+ query = ib_sa_find_idr(mad_send_wc->wr_id);
if (!query)
return;
@@ -661,12 +661,8 @@ static void recv_handler(struct ib_mad_a
struct ib_mad_recv_wc *mad_recv_wc)
{
struct ib_sa_query *query;
- unsigned long flags;
-
- spin_lock_irqsave(&idr_lock, flags);
- query = idr_find(&query_idr, mad_recv_wc->wc->wr_id);
- spin_unlock_irqrestore(&idr_lock, flags);
+ query = ib_sa_find_idr(mad_recv_wc->wc->wr_id);
if (query) {
if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
query->callback(query,
More information about the general
mailing list