RDMA/cma: Use refcount API to reflect refcount
authorParav Pandit <parav@mellanox.com>
Sun, 26 Jan 2020 14:26:52 +0000 (16:26 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 11 Feb 2020 18:00:40 +0000 (14:00 -0400)
Use a refcount_t for atomics being used as a refcount.

Link: https://lore.kernel.org/r/20200126142652.104803-8-leon@kernel.org
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cma.c
drivers/infiniband/core/cma_priv.h

index 605afeed122fd91b57a57e2bced04f555b84eeb7..5165158a7aaa7dfff98d6b2ef34829d4cd791b11 100644 (file)
@@ -842,12 +842,12 @@ found:
 
 static void cma_id_get(struct rdma_id_private *id_priv)
 {
-       atomic_inc(&id_priv->refcount);
+       refcount_inc(&id_priv->refcount);
 }
 
 static void cma_id_put(struct rdma_id_private *id_priv)
 {
-       if (atomic_dec_and_test(&id_priv->refcount))
+       if (refcount_dec_and_test(&id_priv->refcount))
                complete(&id_priv->comp);
 }
 
@@ -875,7 +875,7 @@ struct rdma_cm_id *__rdma_create_id(struct net *net,
        spin_lock_init(&id_priv->lock);
        mutex_init(&id_priv->qp_mutex);
        init_completion(&id_priv->comp);
-       atomic_set(&id_priv->refcount, 1);
+       refcount_set(&id_priv->refcount, 1);
        mutex_init(&id_priv->handler_mutex);
        INIT_LIST_HEAD(&id_priv->listen_list);
        INIT_LIST_HEAD(&id_priv->mc_list);
index 4e04c442ff86af3869fd080f4b9896ba9877189c..5edcf44a93078c58333df79185febe252e7f3ad7 100644 (file)
@@ -66,7 +66,7 @@ struct rdma_id_private {
        struct mutex            qp_mutex;
 
        struct completion       comp;
-       atomic_t                refcount;
+       refcount_t refcount;
        struct mutex            handler_mutex;
 
        int                     backlog;