[openib-general] [PATCH] agent: Rename ib_get_agent_mad to ib_get_agent_port and eliminate duplicated call to it in agent_mad_send

Hal Rosenstock halr at voltaire.com
Tue Nov 9 06:27:59 PST 2004


agent: Rename ib_get_agent_mad to ib_get_agent_port and eliminate
duplicated call to it in agent_mad_send (pointed out by Sean Hefty)

Index: agent.c
===================================================================
--- agent.c	(revision 1180)
+++ agent.c	(working copy)
@@ -35,8 +35,8 @@
 
 
 static inline struct ib_agent_port_private *
-__ib_get_agent_mad(struct ib_device *device, int port_num,
-		   struct ib_mad_agent *mad_agent)
+__ib_get_agent_port(struct ib_device *device, int port_num,
+		    struct ib_mad_agent *mad_agent)
 {
 	struct ib_agent_port_private *entry;
 
@@ -61,14 +61,14 @@
 }
 
 static inline struct ib_agent_port_private *
-ib_get_agent_mad(struct ib_device *device, int port_num,
-		 struct ib_mad_agent *mad_agent)
+ib_get_agent_port(struct ib_device *device, int port_num,
+		  struct ib_mad_agent *mad_agent)
 {
 	struct ib_agent_port_private *entry;
 	unsigned long flags;
 
 	spin_lock_irqsave(&ib_agent_port_list_lock, flags);
-	entry = __ib_get_agent_mad(device, port_num, mad_agent);
+	entry = __ib_get_agent_port(device, port_num, mad_agent);
 	spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
 
 	return entry;
@@ -82,7 +82,7 @@
 
 	if (smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
 		return 1;
-	port_priv = ib_get_agent_mad(device, port_num, NULL);
+	port_priv = ib_get_agent_port(device, port_num, NULL);
 	if (!port_priv) {
 		printk(KERN_DEBUG SPFX "smi_check_local_dr_smp %s port %d "
 		       "not open\n",
@@ -94,11 +94,11 @@
 }
 
 static int agent_mad_send(struct ib_mad_agent *mad_agent,
+			  struct ib_agent_port_private *port_priv,
 			  struct ib_mad *mad,
 			  struct ib_grh *grh,
 			  struct ib_wc *wc)
 {
-	struct ib_agent_port_private *port_priv;
 	struct ib_agent_send_wr *agent_send_wr;
 	struct ib_sge gather_list;
 	struct ib_send_wr send_wr;
@@ -107,15 +107,6 @@
 	unsigned long flags;
 	int ret = 1;
 
-	/* Find matching MAD agent */
-	port_priv = ib_get_agent_mad(NULL, 0, mad_agent);
-	if (!port_priv) {
-		printk(KERN_ERR SPFX "agent_mad_send: no matching MAD agent "
-		       "%p\n",
-		       mad_agent);
-		goto out;
-	}
-
 	agent_send_wr = kmalloc(sizeof(*agent_send_wr), GFP_KERNEL);
 	if (!agent_send_wr)
 		goto out;
@@ -213,7 +204,7 @@
 	struct ib_agent_port_private *port_priv;
 	struct ib_mad_agent *mad_agent;
 
-	port_priv = ib_get_agent_mad(device, port_num, NULL);
+	port_priv = ib_get_agent_port(device, port_num, NULL);
 	if (!port_priv) {
 		printk(KERN_DEBUG SPFX "agent_send %s port %d not open\n",
 		       device->name, port_num);
@@ -235,7 +226,7 @@
 			return 1;
 	}
 
-	return agent_mad_send(mad_agent, mad, grh, wc);
+	return agent_mad_send(mad_agent, port_priv, mad, grh, wc);
 }
 
 static void agent_send_handler(struct ib_mad_agent *mad_agent,
@@ -247,7 +238,7 @@
 	unsigned long			flags;
 
 	/* Find matching MAD agent */
-	port_priv = ib_get_agent_mad(NULL, 0, mad_agent);
+	port_priv = ib_get_agent_port(NULL, 0, mad_agent);
 	if (!port_priv) {
 		printk(KERN_ERR SPFX "agent_send_handler: no matching MAD "
 		       "agent %p\n", mad_agent);
@@ -296,7 +287,7 @@
 	unsigned long flags;
 
 	/* First, check if port already open for SMI */
-	port_priv = ib_get_agent_mad(device, port_num, NULL);
+	port_priv = ib_get_agent_port(device, port_num, NULL);
 	if (port_priv) {
 		printk(KERN_DEBUG SPFX "%s port %d already open\n",
 		       device->name, port_num);
@@ -388,7 +379,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&ib_agent_port_list_lock, flags);
-	port_priv = __ib_get_agent_mad(device, port_num, NULL);
+	port_priv = __ib_get_agent_port(device, port_num, NULL);
 	if (port_priv == NULL) {
 		spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
 		printk(KERN_ERR SPFX "Port %d not found\n", port_num);






More information about the general mailing list