On Mon, Jan 28, 2019 at 12:12:23PM +0200, Shamir Rabinovitch wrote: > Helper function to get driver's context out of ib_udata wrapped > in uverbs_attr_bundle for uer objects or NULL for kernel objects. > > Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@xxxxxxxxxx> > include/rdma/ib_verbs.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > index 94b6e1dd4dab..fb4d078d6db3 100644 > +++ b/include/rdma/ib_verbs.h > @@ -4264,4 +4264,18 @@ static inline struct ib_device *rdma_device_to_ibdev(struct device *device) > */ > #define rdma_device_to_drv_device(dev, drv_dev_struct, ibdev_member) \ > container_of(rdma_device_to_ibdev(dev), drv_dev_struct, ibdev_member) > + > +/** > + * rdma_udata_to_drv_context - Helper macro to get the driver's context out of > + * ib_udata which is embadded in uverbs_attr_bundle. > + * > + * NOTE: This macro return NULL for kernel objects and valid driver context for > + * user objects. > + */ > +#define rdma_udata_to_drv_context(udata, drv_dev_struct, member) \ > + ({ struct ib_ucontext *_ibctx = rdma_get_ucontext(udata); \ > + IS_ERR(_ibctx) ? NULL : \ > + container_of(_ibctx, drv_dev_struct, member); \ > + }) This macro body is the same as container_of_safe Jason