diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2019-01-30 13:49:05 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-01-31 07:20:23 +0300 |
commit | 5e458d3f899ef6158d59b6909b8df9348868ccc4 (patch) | |
tree | fee8ca690b42977f0061901e381f72b2b4d71a7c | |
parent | 0ad699c0edc97a864177679dd67f2ccd73b07cb7 (diff) | |
download | linux-5e458d3f899ef6158d59b6909b8df9348868ccc4.tar.xz |
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: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r-- | drivers/infiniband/core/restrack.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c index 0ade3da0a5c7..bd7770ed4174 100644 --- a/drivers/infiniband/core/restrack.c +++ b/drivers/infiniband/core/restrack.c @@ -177,17 +177,6 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res) if (!dev) 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); init_completion(&res->comp); res->valid = true; @@ -203,6 +192,8 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res) */ void rdma_restrack_kadd(struct rdma_restrack_entry *res) { + res->task = NULL; + set_kern_name(res); res->user = false; rdma_restrack_add(res); } @@ -214,6 +205,13 @@ EXPORT_SYMBOL(rdma_restrack_kadd); */ 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; rdma_restrack_add(res); } |