Commit 5e458d3f authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

RDMA/restrack: Refactor user/kernel restrack additions

Since we already know if we are user/kernel before calling restrack_add,
move type dependent code into the callers to make the flow more readable.
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0ad699c0
...@@ -177,17 +177,6 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res) ...@@ -177,17 +177,6 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res)
if (!dev) if (!dev)
return; return;
if (res->type != RDMA_RESTRACK_CM_ID || rdma_is_kernel_res(res))
res->task = NULL;
if (!rdma_is_kernel_res(res)) {
if (!res->task)
rdma_restrack_set_task(res, NULL);
res->kern_name = NULL;
} else {
set_kern_name(res);
}
kref_init(&res->kref); kref_init(&res->kref);
init_completion(&res->comp); init_completion(&res->comp);
res->valid = true; res->valid = true;
...@@ -203,6 +192,8 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res) ...@@ -203,6 +192,8 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res)
*/ */
void rdma_restrack_kadd(struct rdma_restrack_entry *res) void rdma_restrack_kadd(struct rdma_restrack_entry *res)
{ {
res->task = NULL;
set_kern_name(res);
res->user = false; res->user = false;
rdma_restrack_add(res); rdma_restrack_add(res);
} }
...@@ -214,6 +205,13 @@ EXPORT_SYMBOL(rdma_restrack_kadd); ...@@ -214,6 +205,13 @@ EXPORT_SYMBOL(rdma_restrack_kadd);
*/ */
void rdma_restrack_uadd(struct rdma_restrack_entry *res) void rdma_restrack_uadd(struct rdma_restrack_entry *res)
{ {
if (res->type != RDMA_RESTRACK_CM_ID)
res->task = NULL;
if (!res->task)
rdma_restrack_set_task(res, NULL);
res->kern_name = NULL;
res->user = true; res->user = true;
rdma_restrack_add(res); rdma_restrack_add(res);
} }
......
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