Skip to content

Commit 3172e4d

Browse files
author
Georgi Djakov
committed
interconnect: Add a common standard aggregate function
Currently there is one very standard aggregation method that is used by several drivers. Let's add this as a common function, so that drivers could just point to it, instead of copy/pasting code. Suggested-by: Evan Green <[email protected]> Reviewed-by: Brian Masney <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Reviewed-by: Evan Green <[email protected]> Signed-off-by: Georgi Djakov <[email protected]>
1 parent c46ab9d commit 3172e4d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/interconnect/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ static int apply_constraints(struct icc_path *path)
221221
return ret;
222222
}
223223

224+
int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
225+
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
226+
{
227+
*agg_avg += avg_bw;
228+
*agg_peak = max(*agg_peak, peak_bw);
229+
230+
return 0;
231+
}
232+
EXPORT_SYMBOL_GPL(icc_std_aggregate);
233+
224234
/* of_icc_xlate_onecell() - Translate function using a single index.
225235
* @spec: OF phandle args to map into an interconnect node.
226236
* @data: private data (pointer to struct icc_onecell_data)

include/linux/interconnect-provider.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ struct icc_node {
9292

9393
#if IS_ENABLED(CONFIG_INTERCONNECT)
9494

95+
int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
96+
u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
9597
struct icc_node *icc_node_create(int id);
9698
void icc_node_destroy(int id);
9799
int icc_link_create(struct icc_node *node, const int dst_id);
@@ -104,6 +106,12 @@ int icc_provider_del(struct icc_provider *provider);
104106

105107
#else
106108

109+
static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
110+
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
111+
{
112+
return -ENOTSUPP;
113+
}
114+
107115
static inline struct icc_node *icc_node_create(int id)
108116
{
109117
return ERR_PTR(-ENOTSUPP);

0 commit comments

Comments
 (0)