Re: [PATCH for-next v2 3/3] IB/{hw,sw}: remove 'uobject->context' dependency in object creation APIs

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

 



> index 9bc637e49faa..dbce0084d1b2 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -668,6 +668,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  				u32 flags,
>  				struct ib_udata *udata)
>  {
> +	struct bnxt_re_ucontext *uctx;
>  	struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
>  	struct bnxt_re_dev *rdev = pd->rdev;
>  	struct bnxt_re_ah *ah;
> @@ -675,6 +676,9 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  	int rc;
>  	u8 nw_type;
>  
> +	uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext,
> +					 ib_uctx);
> +
>  	if (!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) {
>  		dev_err(rdev_to_dev(rdev), "Failed to alloc AH: GRH not set");
>  		return ERR_PTR(-EINVAL);
> @@ -700,7 +704,7 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  	ah->qplib_ah.flow_label = grh->flow_label;
>  	ah->qplib_ah.hop_limit = grh->hop_limit;
>  	ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr);
> -	if (udata &&
> +	if (uctx &&

We don't even use uctx anywhere here except for the NULL check, so
using this helper is a little pointless.

>  	    !rdma_is_multicast_addr((struct in6_addr *)
>  				    grh->dgid.raw) &&
>  	    !rdma_link_local_addr((struct in6_addr *)
> @@ -732,13 +736,10 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
>  	}
>  
>  	/* Write AVID to shared page. */
> -	if (udata) {
> -		struct ib_ucontext *ib_uctx = ib_pd->uobject->context;
> -		struct bnxt_re_ucontext *uctx;
> +	if (uctx) {
>  		unsigned long flag;
>  		u32 *wrptr;
>  
> -		uctx = container_of(ib_uctx, struct bnxt_re_ucontext, ib_uctx);

And here keeping the uctx dereference in the smaller scrope leads to
much more understandable code.  І'm not 100% sure what your aim here
is, but if you just want to hide the uobject->context dereference why
not add a helper for that specificly?

> -	struct ib_ucontext *context = pd->ib_pd.uobject->context;
> -	struct bnxt_re_ucontext *cntx = container_of(context,
> -						     struct bnxt_re_ucontext,
> -						     ib_uctx);
> +	struct bnxt_re_ucontext *cntx;
> +
> +	cntx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext,
> +					 ib_uctx);
> +

And here we don't need the magic NULL check either, not does hiding the
container_of helper us much if at all..

And so on.



[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