Re: [PATCH rdma-next] RDMA/nldev: Dynamically generate restrack dumpit callbacks

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

 



On Thu, Dec 20, 2018 at 02:06:40PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> There is no need to manually write same callbacks,
> automatically generate them using C-macro language.
> 
> This macro is going it be extended to generate doit
> callbacks too, hence give general name for this macro.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/core/nldev.c | 39 ++++++++++-----------------------
>  1 file changed, 11 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index d4ce7106e4b8..0126074e27f2 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -1087,35 +1087,18 @@ next:		idx++;
>  	return ret;
>  }
>  
> -static int nldev_res_get_qp_dumpit(struct sk_buff *skb,
> -				   struct netlink_callback *cb)
> -{
> -	return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_QP);
> -}
> -
> -static int nldev_res_get_cm_id_dumpit(struct sk_buff *skb,
> -				      struct netlink_callback *cb)
> -{
> -	return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_CM_ID);
> -}
> -
> -static int nldev_res_get_cq_dumpit(struct sk_buff *skb,
> -				   struct netlink_callback *cb)
> -{
> -	return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_CQ);
> -}
> -
> -static int nldev_res_get_mr_dumpit(struct sk_buff *skb,
> -				   struct netlink_callback *cb)
> -{
> -	return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_MR);
> -}
> +#define RES_GET_FUNCS(name, type)                                            \
> +	static int nldev_res_get_##name##_dumpit(struct sk_buff *skb,            \
> +					       struct netlink_callback *cb)    \
> +	{                                                                      \
> +		return res_get_common_dumpit(skb, cb, type);                   \
> +	}
>  
> -static int nldev_res_get_pd_dumpit(struct sk_buff *skb,
> -				   struct netlink_callback *cb)
> -{
> -	return res_get_common_dumpit(skb, cb, RDMA_RESTRACK_PD);
> -}
> +RES_GET_FUNCS(qp, RDMA_RESTRACK_QP);
> +RES_GET_FUNCS(cm_id, RDMA_RESTRACK_CM_ID);
> +RES_GET_FUNCS(cq, RDMA_RESTRACK_CQ);
> +RES_GET_FUNCS(pd, RDMA_RESTRACK_PD);
> +RES_GET_FUNCS(mr, RDMA_RESTRACK_MR);

FWIW:

Reviewed-by: Yuval Shaia <yuval.shaia@xxxxxxxxxx>

>  
>  static int nldev_get_sys_get_dumpit(struct sk_buff *skb,
>  				    struct netlink_callback *cb)
> -- 
> 2.19.1
> 



[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