From 9867f5c6695f0a17cde9a4dc140fe026b4e40d4a Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Wed, 25 Jul 2018 21:40:13 -0600 Subject: IB/uverbs: Convert 'bool exclusive' into an enum This is more readable, and future patches will need a 3rd lookup type. Signed-off-by: Jason Gunthorpe --- include/rdma/uverbs_std_types.h | 13 +++++++------ include/rdma/uverbs_types.h | 16 +++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'include/rdma') diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h index c2f89e41cbd2..8c54e1439ba1 100644 --- a/include/rdma/uverbs_std_types.h +++ b/include/rdma/uverbs_std_types.h @@ -58,11 +58,12 @@ static inline const struct uverbs_object_tree_def *uverbs_default_get_objects(vo #define uobj_get_read(_type, _id, _ufile) \ rdma_lookup_get_uobject(uobj_get_type(_type), _ufile, \ - _uobj_check_id(_id), false) + _uobj_check_id(_id), UVERBS_LOOKUP_READ) #define ufd_get_read(_type, _fdnum, _ufile) \ rdma_lookup_get_uobject(uobj_get_type(_type), _ufile, \ - (_fdnum)*typecheck(s32, _fdnum), false) + (_fdnum)*typecheck(s32, _fdnum), \ + UVERBS_LOOKUP_READ) static inline void *_uobj_get_obj_read(struct ib_uobject *uobj) { @@ -76,7 +77,7 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj) #define uobj_get_write(_type, _id, _ufile) \ rdma_lookup_get_uobject(uobj_get_type(_type), _ufile, \ - _uobj_check_id(_id), true) + _uobj_check_id(_id), UVERBS_LOOKUP_WRITE) int __uobj_perform_destroy(const struct uverbs_obj_type *type, u32 id, struct ib_uverbs_file *ufile, int success_res); @@ -92,12 +93,12 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_obj_type *type, static inline void uobj_put_destroy(struct ib_uobject *uobj) { - rdma_lookup_put_uobject(uobj, true); + rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); } static inline void uobj_put_read(struct ib_uobject *uobj) { - rdma_lookup_put_uobject(uobj, false); + rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_READ); } #define uobj_put_obj_read(_obj) \ @@ -105,7 +106,7 @@ static inline void uobj_put_read(struct ib_uobject *uobj) static inline void uobj_put_write(struct ib_uobject *uobj) { - rdma_lookup_put_uobject(uobj, true); + rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); } static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj, diff --git a/include/rdma/uverbs_types.h b/include/rdma/uverbs_types.h index 875dd8c16ba3..0676672dbbb9 100644 --- a/include/rdma/uverbs_types.h +++ b/include/rdma/uverbs_types.h @@ -38,6 +38,11 @@ struct uverbs_obj_type; +enum rdma_lookup_mode { + UVERBS_LOOKUP_READ, + UVERBS_LOOKUP_WRITE, +}; + /* * The following sequences are valid: * Success flow: @@ -78,8 +83,8 @@ struct uverbs_obj_type_class { struct ib_uobject *(*lookup_get)(const struct uverbs_obj_type *type, struct ib_uverbs_file *ufile, s64 id, - bool exclusive); - void (*lookup_put)(struct ib_uobject *uobj, bool exclusive); + enum rdma_lookup_mode mode); + void (*lookup_put)(struct ib_uobject *uobj, enum rdma_lookup_mode mode); /* This does not consume the kref on uobj */ int __must_check (*remove_commit)(struct ib_uobject *uobj, enum rdma_remove_reason why); @@ -116,9 +121,10 @@ struct uverbs_obj_idr_type { }; struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_obj_type *type, - struct ib_uverbs_file *ufile, - s64 id, bool exclusive); -void rdma_lookup_put_uobject(struct ib_uobject *uobj, bool exclusive); + struct ib_uverbs_file *ufile, s64 id, + enum rdma_lookup_mode mode); +void rdma_lookup_put_uobject(struct ib_uobject *uobj, + enum rdma_lookup_mode mode); struct ib_uobject *rdma_alloc_begin_uobject(const struct uverbs_obj_type *type, struct ib_uverbs_file *ufile); void rdma_alloc_abort_uobject(struct ib_uobject *uobj); -- cgit v1.2.3-59-g8ed1b