From patchwork Fri Mar 10 11:04:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 9616055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1668A60417 for ; Fri, 10 Mar 2017 11:07:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36DBC28702 for ; Fri, 10 Mar 2017 11:07:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADF52870E; Fri, 10 Mar 2017 11:07:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B4CCC28702 for ; Fri, 10 Mar 2017 11:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lhTZIU26AW4reWYfzQgCE+D4TlrSdEInz0QPquoDVeY=; b=mCWiJtaipAkEHlxWfX/0jsbRAW Liiw6H6QUdUMP3EQZsijk/7NtqKBR+4ygebzlszJ/UeGWkconwRtTGs5WaGlnJEAIs7Nltqrbhn3N Zuv0ndGUsuTmMlCMIw2P5aBDAc2TzaGyZobVMhejqKxwWhhZ9OJ4McaL8g7EmltargxGs2+XrIz9R CaM/FNkSPDlLjZ6MrFW6z96F/kjAXZsinyydBI7Ed9Lq8T6GSSpMxRSmQ5hpnrYfJfNy5HOg4blpJ 29QJ9oOb87F2Vqpk011l5z86CDczudc5Pv/XtW4eFXWA0z4xk1FfUz78moHDfoKI1AaKG4ri70fgJ qM83Vkfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmIOd-0003OK-CI; Fri, 10 Mar 2017 11:07:43 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmIN2-0002E4-VT for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2017 11:06:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 787C4687; Fri, 10 Mar 2017 03:05:45 -0800 (PST) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5F09B3F3E1; Fri, 10 Mar 2017 03:05:44 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/14] drivers/perf: arm_pmu: factor out pmu registration Date: Fri, 10 Mar 2017 11:04:41 +0000 Message-Id: <1489143891-11596-5-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489143891-11596-1-git-send-email-mark.rutland@arm.com> References: <1489143891-11596-1-git-send-email-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170310_030605_613448_8B8DB017 X-CRM114-Status: UNSURE ( 9.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, lorenzo.pieralisi@arm.com, will.deacon@arm.com, jeremy.linton@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently arm_pmu_device_probe contains probing logic specific to the platform_device infrastructure, and some logic required to safely register the PMU with various systems. This patch factors out the logic relating to the registration of the PMU. This makes arm_pmu_device_probe a little easier to read, and will make it easier to reuse the logic for an ACPI-specific probing mechanism. Signed-off-by: Mark Rutland Cc: Will Deacon --- drivers/perf/arm_pmu.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index e7529a0..4ae9c49 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -982,6 +982,31 @@ void armpmu_free(struct arm_pmu *pmu) kfree(pmu); } +int armpmu_register(struct arm_pmu *pmu) +{ + int ret; + + ret = cpu_pmu_init(pmu); + if (ret) + return ret; + + ret = perf_pmu_register(&pmu->pmu, pmu->name, -1); + if (ret) + goto out_destroy; + + if (!__oprofile_cpu_pmu) + __oprofile_cpu_pmu = pmu; + + pr_info("enabled with %s PMU driver, %d counters available\n", + pmu->name, pmu->num_events); + + return 0; + +out_destroy: + cpu_pmu_destroy(pmu); + return ret; +} + int arm_pmu_device_probe(struct platform_device *pdev, const struct of_device_id *of_table, const struct pmu_probe_info *probe_table) @@ -1025,25 +1050,12 @@ int arm_pmu_device_probe(struct platform_device *pdev, goto out_free; } - - ret = cpu_pmu_init(pmu); + ret = armpmu_register(pmu); if (ret) goto out_free; - ret = perf_pmu_register(&pmu->pmu, pmu->name, -1); - if (ret) - goto out_destroy; - - if (!__oprofile_cpu_pmu) - __oprofile_cpu_pmu = pmu; - - pr_info("enabled with %s PMU driver, %d counters available\n", - pmu->name, pmu->num_events); - return 0; -out_destroy: - cpu_pmu_destroy(pmu); out_free: pr_info("%s: failed to register PMU devices!\n", of_node_full_name(node));