Re: [PATCH for-next v2 2/3] IB/verbs: add helper function rdma_udata_to_drv_context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 28, 2019 at 12:12:23PM +0200, Shamir Rabinovitch wrote:
> +/**
> + * 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);                   \
> +	})

Please don't hide that much magic in a helper.  Opencoding this
makes it much more obvious what is going on.  I don't actually
have rdma_get_ucontext in my tree, but an ERR_PTR return for a
private data accessor also sounds like a bad idea - in general we
use NULL returns for that.

Last but not least your series does not even seem to add a user of this
helper.  Where do you want to use it?



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux