From: Mark Rutland Date: Tue, 11 Apr 2017 08:39:47 +0000 (+0100) Subject: drivers/perf: arm_pmu: factor out pmu registration X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=74a2b3ea2d8c6c1f73103a0fcb50b5c214c0d864;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drivers/perf: arm_pmu: factor out pmu registration 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 Tested-by: Jeremy Linton Cc: Will Deacon Signed-off-by: Will Deacon --- diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 1cb8b1a1c122..985bd081f3e7 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -982,6 +982,31 @@ static 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));