Commit eab35953 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo
Browse files

perf pmu: Simplify arguments of __perf_pmu__new_alias



Simplify the arguments of __perf_pmu__new_alias() by passing the whole
'struct pme_event' pointer.

Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210427070139.25256-4-yao.jin@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6b64833b
Loading
Loading
Loading
Loading
+16 −20
Original line number Diff line number Diff line
@@ -306,18 +306,25 @@ static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias,
}

static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
				 char *desc, char *val,
				 char *long_desc, char *topic,
				 char *unit, char *perpkg,
				 char *metric_expr,
				 char *metric_name,
				 char *deprecated)
				 char *desc, char *val, struct pmu_event *pe)
{
	struct parse_events_term *term;
	struct perf_pmu_alias *alias;
	int ret;
	int num;
	char newval[256];
	char *long_desc = NULL, *topic = NULL, *unit = NULL, *perpkg = NULL,
	     *metric_expr = NULL, *metric_name = NULL, *deprecated = NULL;

	if (pe) {
		long_desc = (char *)pe->long_desc;
		topic = (char *)pe->topic;
		unit = (char *)pe->unit;
		perpkg = (char *)pe->perpkg;
		metric_expr = (char *)pe->metric_expr;
		metric_name = (char *)pe->metric_name;
		deprecated = (char *)pe->deprecated;
	}

	alias = malloc(sizeof(*alias));
	if (!alias)
@@ -406,8 +413,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
	/* Remove trailing newline from sysfs file */
	strim(buf);

	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
				     NULL, NULL, NULL, NULL);
	return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL);
}

static inline bool pmu_alias_info_file(char *name)
@@ -798,11 +804,7 @@ void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
		/* need type casts to override 'const' */
		__perf_pmu__new_alias(head, NULL, (char *)pe->name,
				(char *)pe->desc, (char *)pe->event,
				(char *)pe->long_desc, (char *)pe->topic,
				(char *)pe->unit, (char *)pe->perpkg,
				(char *)pe->metric_expr,
				(char *)pe->metric_name,
				(char *)pe->deprecated);
				pe);
	}
}

@@ -869,13 +871,7 @@ static int pmu_add_sys_aliases_iter_fn(struct pmu_event *pe, void *data)
				      (char *)pe->name,
				      (char *)pe->desc,
				      (char *)pe->event,
				      (char *)pe->long_desc,
				      (char *)pe->topic,
				      (char *)pe->unit,
				      (char *)pe->perpkg,
				      (char *)pe->metric_expr,
				      (char *)pe->metric_name,
				      (char *)pe->deprecated);
				      pe);
	}

	return 0;