[RFC][PATCH 5/9] perf: arm, convert to new API pmu->init_event
From: Lin Ming
Date: Mon May 10 2010 - 05:28:32 EST
perf: arm, convert to new API pmu->init_event
Signed-off-by: Lin Ming <ming.m.lin@xxxxxxxxx>
---
arch/arm/kernel/perf_event.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 8400ddf..565f13a 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -270,13 +270,6 @@ out:
return err;
}
-static struct pmu pmu = {
- .enable = armpmu_enable,
- .disable = armpmu_disable,
- .unthrottle = armpmu_unthrottle,
- .read = armpmu_read,
-};
-
static int
validate_event(struct cpu_hw_events *cpuc,
struct perf_event *event)
@@ -446,20 +439,19 @@ __hw_perf_event_init(struct perf_event *event)
return err;
}
-struct pmu *
-hw_perf_event_init(struct perf_event *event)
+static int armpmu_init_event(struct perf_event *event)
{
int err = 0;
if (!armpmu)
- return ERR_PTR(-ENODEV);
+ return -ENODEV;
event->destroy = hw_perf_event_destroy;
if (!atomic_inc_not_zero(&active_events)) {
if (atomic_read(&active_events) > perf_max_events) {
atomic_dec(&active_events);
- return ERR_PTR(-ENOSPC);
+ return -ENOSPC;
}
mutex_lock(&pmu_reserve_mutex);
@@ -473,15 +465,23 @@ hw_perf_event_init(struct perf_event *event)
}
if (err)
- return ERR_PTR(err);
+ return err;
err = __hw_perf_event_init(event);
if (err)
hw_perf_event_destroy(event);
- return err ? ERR_PTR(err) : &pmu;
+ return err;
}
+static struct pmu pmu = {
+ .enable = armpmu_enable,
+ .disable = armpmu_disable,
+ .unthrottle = armpmu_unthrottle,
+ .read = armpmu_read,
+ .init_event = armpmu_init_event,
+};
+
void
hw_perf_enable(void)
{
@@ -2138,6 +2138,8 @@ init_hw_perf_events(void)
pr_info("enabled with %s PMU driver, %d counters available\n",
armpmu->name, armpmu->num_events);
+ perf_event_register_pmu(&pmu);
+
return 0;
}
arch_initcall(init_hw_perf_events);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/