lkml.org 
[lkml]   [2021]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH rdma-next v2 04/13] RDMA/core: Add a helper API rdma_free_hw_stats_struct
On Thu, Sep 30, 2021 at 11:02:20AM +0300, Leon Romanovsky wrote:

> +
> +struct rdma_hw_stats *rdma_alloc_hw_stats_struct(
> + const struct rdma_stat_desc *descs, int num_counters,
> + unsigned long lifespan)
> +{

The kdoc should be moved here too from the header

> + struct rdma_hw_stats *stats;
> +
> + stats = kzalloc(struct_size(stats, value, num_counters), GFP_KERNEL);
> + if (!stats)
> + return NULL;
> +
> + stats->descs = descs;
> + stats->num_counters = num_counters;
> + stats->lifespan = msecs_to_jiffies(lifespan);
> +
> + return stats;
> +}
> +EXPORT_SYMBOL(rdma_alloc_hw_stats_struct);
> +
> +void rdma_free_hw_stats_struct(struct rdma_hw_stats *stats)
> +{
> + kfree(stats);
> +}
> +EXPORT_SYMBOL(rdma_free_hw_stats_struct);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index aa1e1029b736..5e8a5ed47e9a 100644
> +++ b/include/rdma/ib_verbs.h
> @@ -589,24 +589,14 @@ struct rdma_hw_stats {
> * @num_counters - How many elements in array
> * @lifespan - How many milliseconds between updates
> */
> -static inline struct rdma_hw_stats *rdma_alloc_hw_stats_struct(
> - const struct rdma_stat_desc *descs, int num_counters,
> - unsigned long lifespan)
> -{
> - struct rdma_hw_stats *stats;
> -
> - stats = kzalloc(sizeof(*stats) + num_counters * sizeof(u64),
> - GFP_KERNEL);
> - if (!stats)
> - return NULL;
> -
> - stats->descs = descs;
> - stats->num_counters = num_counters;
> - stats->lifespan = msecs_to_jiffies(lifespan);
> -
> - return stats;
> -}
> +struct rdma_hw_stats *rdma_alloc_hw_stats_struct(
> + const struct rdma_stat_desc *descs, int num_counters,
> + unsigned long lifespan);
>
> +/**
> + * rdma_free_hw_stats_struct - Helper function to release rdma_hw_stats
> + */
> +void rdma_free_hw_stats_struct(struct rdma_hw_stats *stats);

Ditto

Jason

\
 
 \ /
  Last update: 2021-10-04 19:59    [W:0.051 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site