Commit 5ff8c8fa authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

RDMA/cma: Rename cma_device ref/deref helpers to to get/put

Helper functions which increment/decrement reference count of the
structure read better when they are named with the get/put suffix.

Hence, rename cma_ref/deref_dev() to cma_dev_get/put().

Link: https://lore.kernel.org/r/20200126142652.104803-5-leon@kernel.orgSigned-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent cc055dd3
...@@ -247,11 +247,17 @@ enum { ...@@ -247,11 +247,17 @@ enum {
CMA_OPTION_AFONLY, CMA_OPTION_AFONLY,
}; };
void cma_ref_dev(struct cma_device *cma_dev) void cma_dev_get(struct cma_device *cma_dev)
{ {
atomic_inc(&cma_dev->refcount); atomic_inc(&cma_dev->refcount);
} }
void cma_dev_put(struct cma_device *cma_dev)
{
if (atomic_dec_and_test(&cma_dev->refcount))
complete(&cma_dev->comp);
}
struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter, struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
void *cookie) void *cookie)
{ {
...@@ -267,7 +273,7 @@ struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter, ...@@ -267,7 +273,7 @@ struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
} }
if (found_cma_dev) if (found_cma_dev)
cma_ref_dev(found_cma_dev); cma_dev_get(found_cma_dev);
mutex_unlock(&lock); mutex_unlock(&lock);
return found_cma_dev; return found_cma_dev;
} }
...@@ -463,7 +469,7 @@ static int cma_igmp_send(struct net_device *ndev, union ib_gid *mgid, bool join) ...@@ -463,7 +469,7 @@ static int cma_igmp_send(struct net_device *ndev, union ib_gid *mgid, bool join)
static void _cma_attach_to_dev(struct rdma_id_private *id_priv, static void _cma_attach_to_dev(struct rdma_id_private *id_priv,
struct cma_device *cma_dev) struct cma_device *cma_dev)
{ {
cma_ref_dev(cma_dev); cma_dev_get(cma_dev);
id_priv->cma_dev = cma_dev; id_priv->cma_dev = cma_dev;
id_priv->id.device = cma_dev->device; id_priv->id.device = cma_dev->device;
id_priv->id.route.addr.dev_addr.transport = id_priv->id.route.addr.dev_addr.transport =
...@@ -484,12 +490,6 @@ static void cma_attach_to_dev(struct rdma_id_private *id_priv, ...@@ -484,12 +490,6 @@ static void cma_attach_to_dev(struct rdma_id_private *id_priv,
rdma_start_port(cma_dev->device)]; rdma_start_port(cma_dev->device)];
} }
void cma_deref_dev(struct cma_device *cma_dev)
{
if (atomic_dec_and_test(&cma_dev->refcount))
complete(&cma_dev->comp);
}
static inline void release_mc(struct kref *kref) static inline void release_mc(struct kref *kref)
{ {
struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref); struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref);
...@@ -502,7 +502,7 @@ static void cma_release_dev(struct rdma_id_private *id_priv) ...@@ -502,7 +502,7 @@ static void cma_release_dev(struct rdma_id_private *id_priv)
{ {
mutex_lock(&lock); mutex_lock(&lock);
list_del(&id_priv->list); list_del(&id_priv->list);
cma_deref_dev(id_priv->cma_dev); cma_dev_put(id_priv->cma_dev);
id_priv->cma_dev = NULL; id_priv->cma_dev = NULL;
mutex_unlock(&lock); mutex_unlock(&lock);
} }
...@@ -4728,7 +4728,7 @@ static void cma_process_remove(struct cma_device *cma_dev) ...@@ -4728,7 +4728,7 @@ static void cma_process_remove(struct cma_device *cma_dev)
} }
mutex_unlock(&lock); mutex_unlock(&lock);
cma_deref_dev(cma_dev); cma_dev_put(cma_dev);
wait_for_completion(&cma_dev->comp); wait_for_completion(&cma_dev->comp);
} }
......
...@@ -94,7 +94,7 @@ static int cma_configfs_params_get(struct config_item *item, ...@@ -94,7 +94,7 @@ static int cma_configfs_params_get(struct config_item *item,
static void cma_configfs_params_put(struct cma_device *cma_dev) static void cma_configfs_params_put(struct cma_device *cma_dev)
{ {
cma_deref_dev(cma_dev); cma_dev_put(cma_dev);
} }
static ssize_t default_roce_mode_show(struct config_item *item, static ssize_t default_roce_mode_show(struct config_item *item,
...@@ -312,12 +312,12 @@ static struct config_group *make_cma_dev(struct config_group *group, ...@@ -312,12 +312,12 @@ static struct config_group *make_cma_dev(struct config_group *group,
configfs_add_default_group(&cma_dev_group->ports_group, configfs_add_default_group(&cma_dev_group->ports_group,
&cma_dev_group->device_group); &cma_dev_group->device_group);
cma_deref_dev(cma_dev); cma_dev_put(cma_dev);
return &cma_dev_group->device_group; return &cma_dev_group->device_group;
fail: fail:
if (cma_dev) if (cma_dev)
cma_deref_dev(cma_dev); cma_dev_put(cma_dev);
kfree(cma_dev_group); kfree(cma_dev_group);
return ERR_PTR(err); return ERR_PTR(err);
} }
......
...@@ -111,8 +111,8 @@ static inline void cma_configfs_exit(void) ...@@ -111,8 +111,8 @@ static inline void cma_configfs_exit(void)
} }
#endif #endif
void cma_ref_dev(struct cma_device *dev); void cma_dev_get(struct cma_device *dev);
void cma_deref_dev(struct cma_device *dev); void cma_dev_put(struct cma_device *dev);
typedef bool (*cma_device_filter)(struct ib_device *, void *); typedef bool (*cma_device_filter)(struct ib_device *, void *);
struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter, struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
void *cookie); void *cookie);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment