diff options
author | Jason Gunthorpe | 2018-07-04 10:32:06 +0200 |
---|---|---|
committer | Jason Gunthorpe | 2018-07-09 19:26:17 +0200 |
commit | c33e73af2183fb9fcd993e37abcdecc058b22d91 (patch) | |
tree | f85591d06f6362c845a38f8473be7916ee238822 /drivers/infiniband/core/rdma_core.c | |
parent | RDMA/uverbs: Combine MIN_SZ_OR_ZERO with UVERBS_ATTR_STRUCT (diff) | |
download | kernel-qcow2-linux-c33e73af2183fb9fcd993e37abcdecc058b22d91.tar.gz kernel-qcow2-linux-c33e73af2183fb9fcd993e37abcdecc058b22d91.tar.xz kernel-qcow2-linux-c33e73af2183fb9fcd993e37abcdecc058b22d91.zip |
IB/uverbs: Add a uobj_perform_destroy helper
This consolidates a bunch of repeated code patterns into a helper.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/rdma_core.c')
-rw-r--r-- | drivers/infiniband/core/rdma_core.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c index c67bcdda5760..38d3929f6e65 100644 --- a/drivers/infiniband/core/rdma_core.c +++ b/drivers/infiniband/core/rdma_core.c @@ -128,6 +128,28 @@ static int uverbs_try_lock_object(struct ib_uobject *uobj, bool exclusive) return atomic_cmpxchg(&uobj->usecnt, 0, -1) == 0 ? 0 : -EBUSY; } +/* + * Does both rdma_lookup_get_uobject() and rdma_remove_commit_uobject(), then + * returns success_res on success (negative errno on failure). For use by + * callers that do not need the uobj. + */ +int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id, + struct ib_uverbs_file *ufile, int success_res) +{ + struct ib_uobject *uobj; + int ret; + + uobj = rdma_lookup_get_uobject(type, ufile->ucontext, id, true); + if (IS_ERR(uobj)) + return PTR_ERR(uobj); + + ret = rdma_remove_commit_uobject(uobj); + if (ret) + return ret; + + return success_res; +} + static struct ib_uobject *alloc_uobj(struct ib_ucontext *context, const struct uverbs_obj_type *type) { |