linux-mips
[Top] [All Lists]

[PATCH 4/4] MIPS/Perf-events: Cleanup event->destroy at event init

To: <linux-mips@linux-mips.org>, <ralf@linux-mips.org>
Subject: [PATCH 4/4] MIPS/Perf-events: Cleanup event->destroy at event init
From: Deng-Cheng Zhu <dczhu@mips.com>
Date: Mon, 24 Oct 2011 18:56:02 +0800
Cc: Deng-Cheng Zhu <dczhu@mips.com>, Peter Zijlstra <a.p.zijlstra@chello.nl>, Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>, Arnaldo Carvalho de Melo <acme@ghostprotocols.net>, David Daney <david.daney@cavium.com>
In-reply-to: <1319453762-12962-1-git-send-email-dczhu@mips.com>
References: <1319453762-12962-1-git-send-email-dczhu@mips.com>
Sender: linux-mips-bounce@linux-mips.org
Simplify the code by changing the place of event->destroy().

Signed-off-by: Deng-Cheng Zhu <dczhu@mips.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: David Daney <david.daney@cavium.com>
---
 arch/mips/kernel/perf_event.c        |    6 +-----
 arch/mips/kernel/perf_event_mipsxx.c |    3 +++
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/mips/kernel/perf_event.c b/arch/mips/kernel/perf_event.c
index b1d51b5..7a8d0a0 100644
--- a/arch/mips/kernel/perf_event.c
+++ b/arch/mips/kernel/perf_event.c
@@ -397,11 +397,7 @@ static int mipspmu_event_init(struct perf_event *event)
        if (err)
                return err;
 
-       err = __hw_perf_event_init(event);
-       if (err)
-               hw_perf_event_destroy(event);
-
-       return err;
+       return __hw_perf_event_init(event);
 }
 
 static struct pmu pmu = {
diff --git a/arch/mips/kernel/perf_event_mipsxx.c 
b/arch/mips/kernel/perf_event_mipsxx.c
index c804fdd..bd75473 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -628,6 +628,9 @@ static int __hw_perf_event_init(struct perf_event *event)
 
        event->destroy = hw_perf_event_destroy;
 
+       if (err)
+               event->destroy(event);
+
        return err;
 }
 
-- 
1.7.1


<Prev in Thread] Current Thread [Next in Thread>