[PATCH 4/9] drivers/perf: Remove redundant macro and functions in qcom_l2_pmu.c

From: Qi Liu
Date: Tue May 18 2021 - 03:24:12 EST


Remove L2CACHE_EVENT_ATTR and l2cache_pmu_event_show(), as there is
a general function for this.

Signed-off-by: Qi Liu <liuqi115@xxxxxxxxxx>
---
drivers/perf/qcom_l2_pmu.c | 37 +++++++++++--------------------------
1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index fc54a80..aa3ae21 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -670,33 +670,18 @@ static const struct attribute_group l2_cache_pmu_format_group = {
.attrs = l2_cache_pmu_formats,
};

-static ssize_t l2cache_pmu_event_show(struct device *dev,
- struct device_attribute *attr, char *page)
-{
- struct perf_pmu_events_attr *pmu_attr;
-
- pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
- return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
-}
-
-#define L2CACHE_EVENT_ATTR(_name, _id) \
- (&((struct perf_pmu_events_attr[]) { \
- { .attr = __ATTR(_name, 0444, l2cache_pmu_event_show, NULL), \
- .id = _id, } \
- })[0].attr.attr)
-
static struct attribute *l2_cache_pmu_events[] = {
- L2CACHE_EVENT_ATTR(cycles, L2_EVENT_CYCLES),
- L2CACHE_EVENT_ATTR(dcache-ops, L2_EVENT_DCACHE_OPS),
- L2CACHE_EVENT_ATTR(icache-ops, L2_EVENT_ICACHE_OPS),
- L2CACHE_EVENT_ATTR(tlbi, L2_EVENT_TLBI),
- L2CACHE_EVENT_ATTR(barriers, L2_EVENT_BARRIERS),
- L2CACHE_EVENT_ATTR(total-reads, L2_EVENT_TOTAL_READS),
- L2CACHE_EVENT_ATTR(total-writes, L2_EVENT_TOTAL_WRITES),
- L2CACHE_EVENT_ATTR(total-requests, L2_EVENT_TOTAL_REQUESTS),
- L2CACHE_EVENT_ATTR(ldrex, L2_EVENT_LDREX),
- L2CACHE_EVENT_ATTR(strex, L2_EVENT_STREX),
- L2CACHE_EVENT_ATTR(clrex, L2_EVENT_CLREX),
+ PMU_EVENT_ATTR_ID(cycles, L2_EVENT_CYCLES),
+ PMU_EVENT_ATTR_ID(dcache-ops, L2_EVENT_DCACHE_OPS),
+ PMU_EVENT_ATTR_ID(icache-ops, L2_EVENT_ICACHE_OPS),
+ PMU_EVENT_ATTR_ID(tlbi, L2_EVENT_TLBI),
+ PMU_EVENT_ATTR_ID(barriers, L2_EVENT_BARRIERS),
+ PMU_EVENT_ATTR_ID(total-reads, L2_EVENT_TOTAL_READS),
+ PMU_EVENT_ATTR_ID(total-writes, L2_EVENT_TOTAL_WRITES),
+ PMU_EVENT_ATTR_ID(total-requests, L2_EVENT_TOTAL_REQUESTS),
+ PMU_EVENT_ATTR_ID(ldrex, L2_EVENT_LDREX),
+ PMU_EVENT_ATTR_ID(strex, L2_EVENT_STREX),
+ PMU_EVENT_ATTR_ID(clrex, L2_EVENT_CLREX),
NULL
};

--
2.7.4