diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-07-04 07:50:27 +0200 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-07-04 21:47:01 +0200 |
commit | 6c61d2a55c4e5980e231fac9bb54e6ff1a5e811b (patch) | |
tree | 09b2b9bfb5ac867602397711de458b0f44883873 /include/rdma/uverbs_named_ioctl.h | |
parent | RDMA/uverbs: Simplify method definition macros (diff) | |
download | linux-6c61d2a55c4e5980e231fac9bb54e6ff1a5e811b.tar.xz linux-6c61d2a55c4e5980e231fac9bb54e6ff1a5e811b.zip |
RDMA/uverbs: Simplify UVERBS_OBJECT and _TREE family of macros
Instead of the large set of indirecting macros, define the few needed
macros to directly instantiate the struct uverbs_oject_tree_def and
associated objects list.
This is small amount of code duplication but the readability is far
better.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Diffstat (limited to 'include/rdma/uverbs_named_ioctl.h')
-rw-r--r-- | include/rdma/uverbs_named_ioctl.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/include/rdma/uverbs_named_ioctl.h b/include/rdma/uverbs_named_ioctl.h index 06eac48ec4f2..3ee045d7da4c 100644 --- a/include/rdma/uverbs_named_ioctl.h +++ b/include/rdma/uverbs_named_ioctl.h @@ -45,8 +45,9 @@ #define UVERBS_HANDLER(id) _UVERBS_NAME(UVERBS_MODULE_NAME, _handler_##id) #define UVERBS_OBJECT(id) _UVERBS_NAME(UVERBS_MOUDLE_NAME, _object_##id) -#define UVERBS_METHOD_ATTRS(id) \ - _UVERBS_NAME(UVERBS_MODULE_NAME, _method_attrs_##id) +/* These are static so they do not need to be qualified */ +#define UVERBS_METHOD_ATTRS(method_id) _method_attrs_##method_id +#define UVERBS_OBJECT_METHODS(object_id) _object_methods_##object_id #define DECLARE_UVERBS_NAMED_METHOD(_method_id, ...) \ static const struct uverbs_attr_def *const UVERBS_METHOD_ATTRS( \ @@ -72,14 +73,19 @@ .attrs = &UVERBS_METHOD_ATTRS(_method_id), \ } -#define DECLARE_UVERBS_NAMED_OBJECT(id, ...) \ - DECLARE_UVERBS_OBJECT(UVERBS_OBJECT(id), id, ##__VA_ARGS__) +#define DECLARE_UVERBS_NAMED_OBJECT(_object_id, _type_attrs, ...) \ + static const struct uverbs_method_def *const UVERBS_OBJECT_METHODS( \ + _object_id)[] = { __VA_ARGS__ }; \ + const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \ + .id = _object_id, \ + .type_attrs = _type_attrs, \ + .num_methods = ARRAY_SIZE(UVERBS_OBJECT_METHODS(_object_id)), \ + .methods = &UVERBS_OBJECT_METHODS(_object_id) \ + } #define DECLARE_UVERBS_GLOBAL_METHODS(_name, ...) \ DECLARE_UVERBS_NAMED_OBJECT(_name, NULL, ##__VA_ARGS__) -#define _UVERBS_COMP_NAME(x, y, z) _UVERBS_NAME(_UVERBS_NAME(x, y), z) - /* Used by drivers to declare a complete parsing tree for a single method that * differs only in having additional driver specific attributes. */ @@ -91,11 +97,19 @@ .num_attrs = ARRAY_SIZE(UVERBS_METHOD_ATTRS(_method_id)), \ .attrs = &UVERBS_METHOD_ATTRS(_method_id), \ }; \ - static DECLARE_UVERBS_OBJECT( \ - _UVERBS_COMP_NAME(UVERBS_MODULE_NAME, _object_id, _name), \ - _object_id, NULL, &UVERBS_METHOD(_method_id)); \ - static DECLARE_UVERBS_OBJECT_TREE( \ - _name, \ - &_UVERBS_COMP_NAME(UVERBS_MODULE_NAME, _object_id, _name)) + static const struct uverbs_method_def *const UVERBS_OBJECT_METHODS( \ + _object_id)[] = { &UVERBS_METHOD(_method_id) }; \ + static const struct uverbs_object_def _name##_struct = { \ + .id = _object_id, \ + .num_methods = 1, \ + .methods = &UVERBS_OBJECT_METHODS(_object_id) \ + }; \ + static const struct uverbs_object_def *const _name##_ptrs[] = { \ + &_name##_struct, \ + }; \ + static const struct uverbs_object_tree_def _name = { \ + .num_objects = 1, \ + .objects = &_name##_ptrs, \ + } #endif |