]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
IB/cm: Add and use a helper function to add cm_id's to the port list
authorParav Pandit <parav@mellanox.com>
Tue, 13 Mar 2018 14:06:18 +0000 (16:06 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 15 Mar 2018 21:17:48 +0000 (15:17 -0600)
Add and use helper function add_cm_id_to_port_list() to attach
cm_id to port list.

Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cm.c

index e6749157fd86c35550df617cc89b6120a29fb5d4..c5cd1b3ffa54eb762c394e4f1078e1615d62bcf8 100644 (file)
@@ -462,6 +462,26 @@ static int cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
                                       grh, &av->ah_attr);
 }
 
+static int add_cm_id_to_port_list(struct cm_id_private *cm_id_priv,
+                                 struct cm_av *av,
+                                 struct cm_port *port)
+{
+       unsigned long flags;
+       int ret = 0;
+
+       spin_lock_irqsave(&cm.lock, flags);
+
+       if (&cm_id_priv->av == av)
+               list_add_tail(&cm_id_priv->prim_list, &port->cm_priv_prim_list);
+       else if (&cm_id_priv->alt_av == av)
+               list_add_tail(&cm_id_priv->altr_list, &port->cm_priv_altr_list);
+       else
+               ret = -EINVAL;
+
+       spin_unlock_irqrestore(&cm.lock, flags);
+       return ret;
+}
+
 static int cm_init_av_by_path(struct sa_path_rec *path, struct cm_av *av,
                              struct cm_id_private *cm_id_priv)
 {
@@ -502,16 +522,7 @@ static int cm_init_av_by_path(struct sa_path_rec *path, struct cm_av *av,
 
        av->timeout = path->packet_life_time + 1;
 
-       spin_lock_irqsave(&cm.lock, flags);
-       if (&cm_id_priv->av == av)
-               list_add_tail(&cm_id_priv->prim_list, &port->cm_priv_prim_list);
-       else if (&cm_id_priv->alt_av == av)
-               list_add_tail(&cm_id_priv->altr_list, &port->cm_priv_altr_list);
-       else
-               ret = -EINVAL;
-
-       spin_unlock_irqrestore(&cm.lock, flags);
-
+       ret = add_cm_id_to_port_list(cm_id_priv, av, port);
        return ret;
 }