Commit 2bcb2b64 authored by Robert Richter's avatar Robert Richter

oprofile, ARM: Rework op_create_counter()

This patch simplifies op_create_counter(). Removing if/else if paths
and return code variable by direct returning from function.
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
parent 9c91283a
...@@ -71,28 +71,28 @@ static void op_perf_setup(void) ...@@ -71,28 +71,28 @@ static void op_perf_setup(void)
static int op_create_counter(int cpu, int event) static int op_create_counter(int cpu, int event)
{ {
int ret = 0;
struct perf_event *pevent; struct perf_event *pevent;
if (!counter_config[event].enabled || (perf_events[cpu][event] != NULL)) if (!counter_config[event].enabled || perf_events[cpu][event])
return ret; return 0;
pevent = perf_event_create_kernel_counter(&counter_config[event].attr, pevent = perf_event_create_kernel_counter(&counter_config[event].attr,
cpu, -1, cpu, -1,
op_overflow_handler); op_overflow_handler);
if (IS_ERR(pevent)) { if (IS_ERR(pevent))
ret = PTR_ERR(pevent); return PTR_ERR(pevent);
} else if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
perf_event_release_kernel(pevent); perf_event_release_kernel(pevent);
pr_warning("oprofile: failed to enable event %d " pr_warning("oprofile: failed to enable event %d "
"on CPU %d\n", event, cpu); "on CPU %d\n", event, cpu);
ret = -EBUSY; return -EBUSY;
} else {
perf_events[cpu][event] = pevent;
} }
return ret; perf_events[cpu][event] = pevent;
return 0;
} }
static void op_destroy_counter(int cpu, int event) static void op_destroy_counter(int cpu, int event)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment