Commit 74a2b3ea authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

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: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarJeremy Linton <jeremy.linton@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 70cd908a
...@@ -982,6 +982,31 @@ static void armpmu_free(struct arm_pmu *pmu) ...@@ -982,6 +982,31 @@ static void armpmu_free(struct arm_pmu *pmu)
kfree(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, int arm_pmu_device_probe(struct platform_device *pdev,
const struct of_device_id *of_table, const struct of_device_id *of_table,
const struct pmu_probe_info *probe_table) const struct pmu_probe_info *probe_table)
...@@ -1025,25 +1050,12 @@ int arm_pmu_device_probe(struct platform_device *pdev, ...@@ -1025,25 +1050,12 @@ int arm_pmu_device_probe(struct platform_device *pdev,
goto out_free; goto out_free;
} }
ret = armpmu_register(pmu);
ret = cpu_pmu_init(pmu);
if (ret) if (ret)
goto out_free; 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; return 0;
out_destroy:
cpu_pmu_destroy(pmu);
out_free: out_free:
pr_info("%s: failed to register PMU devices!\n", pr_info("%s: failed to register PMU devices!\n",
of_node_full_name(node)); of_node_full_name(node));
......
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