Re: [PATCH rdma-next 07/16] RDMA/restrack: Translate from ID to restrack object

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

 



On Mon, Jan 14, 2019 at 04:18:16PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Add new general helper to get restrack entry given by ID and
> their respective type.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>  drivers/infiniband/core/restrack.c | 14 ++++++++++++++
>  include/rdma/restrack.h            | 11 +++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
> index a4f0432cf774..59bb6617a805 100644
> +++ b/drivers/infiniband/core/restrack.c
> @@ -248,6 +248,20 @@ int __must_check rdma_restrack_get(struct rdma_restrack_entry *res)
>  }
>  EXPORT_SYMBOL(rdma_restrack_get);
>  
> +struct rdma_restrack_entry *
> +rdma_restrack_get_byid(struct ib_device *dev,
> +		       enum rdma_restrack_type type, u32 id)
> +{
> +	struct rdma_restrack_root *rt = &dev->res;
> +	struct rdma_restrack_entry *res;
> +
> +	res = xa_load(&rt->xa[type], id);
> +	if (!res || xa_is_err(res) || !rdma_restrack_get(res))
> +		return ERR_PTR(-ENOENT);
> +	return res;
> +}
> +EXPORT_SYMBOL(rdma_restrack_get_byid);
> +
>  static void restrack_release(struct kref *kref)
>  {
>  	struct rdma_restrack_entry *res;
> diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
> index d8d7ea48a91b..fc433d54aad2 100644
> +++ b/include/rdma/restrack.h
> @@ -194,4 +194,15 @@ int rdma_nl_put_driver_u32_hex(struct sk_buff *msg, const char *name,
>  int rdma_nl_put_driver_u64(struct sk_buff *msg, const char *name, u64 value);
>  int rdma_nl_put_driver_u64_hex(struct sk_buff *msg, const char *name,
>  			       u64 value);
> +/**
> + * rdma_restrack_get_byid() - translate from ID to restrack object
> + * @dev: IB device
> + * @type: resource track type
> + * @id: ID to take a look
> + *
> + * Return: Pointer to restrack entry or -ENOENT in case of error.
> + */
> +struct rdma_restrack_entry *rdma_restrack_get_byid(struct ib_device *dev,
> +						   enum rdma_restrack_type type,
> +						   u32 id);

Please don't put funcion kdoc in headers. Like the majority of the
kernel, in rdma the standard is to put them above the implementation
of the function. We keep (slowly) moving the ones that are still wrong
to the right place. Don't add more...

Jason




[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