Skip to content

Commit

Permalink
interconnect: Add a common standard aggregate function
Browse files Browse the repository at this point in the history
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 <evgreen@chromium.org>
Reviewed-by: Brian Masney <masneyb@onstation.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
  • Loading branch information
Georgi Djakov committed Dec 16, 2019
1 parent c46ab9d commit 3172e4d
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/interconnect/core.c
Original file line number Diff line number Diff line change
@@ -221,6 +221,16 @@ static int apply_constraints(struct icc_path *path)
return ret;
}

int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
{
*agg_avg += avg_bw;
*agg_peak = max(*agg_peak, peak_bw);

return 0;
}
EXPORT_SYMBOL_GPL(icc_std_aggregate);

/* of_icc_xlate_onecell() - Translate function using a single index.
* @spec: OF phandle args to map into an interconnect node.
* @data: private data (pointer to struct icc_onecell_data)
8 changes: 8 additions & 0 deletions include/linux/interconnect-provider.h
Original file line number Diff line number Diff line change
@@ -92,6 +92,8 @@ struct icc_node {

#if IS_ENABLED(CONFIG_INTERCONNECT)

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

#else

static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
{
return -ENOTSUPP;
}

static inline struct icc_node *icc_node_create(int id)
{
return ERR_PTR(-ENOTSUPP);

0 comments on commit 3172e4d

Please sign in to comment.