int arm_pmu_device_probe(struct platform_device *pdev, const struct of_device_id *of_table, const struct pmu_probe_info *probe_table) { const struct of_device_id *of_id; armpmu_init_fn init_fn; struct device_node *node = pdev->dev.of_node; struct arm_pmu *pmu; int ret = -ENODEV; pmu = armpmu_alloc(); if (!pmu) return -ENOMEM; pmu->plat_device = pdev; ret = pmu_parse_irqs(pmu); if (ret) goto out_free; if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) { init_fn = of_id->data; pmu->secure_access = of_property_read_bool(pdev->dev.of_node, "secure-reg-access"); /* arm64 systems boot only as non-secure */ if (IS_ENABLED(CONFIG_ARM64) && pmu->secure_access) { pr_warn("ignoring \"secure-reg-access\" property for arm64\n"); pmu->secure_access = false; } ret = init_fn(pmu); } else if (probe_table) { cpumask_setall(&pmu->supported_cpus); ret = probe_current_pmu(pmu, probe_table); } if (ret) { pr_info("%pOF: failed to probe PMU!\n", node); goto out_free; } ret = armpmu_request_irqs(pmu); if (ret) goto out_free_irqs; ret = armpmu_register(pmu); if (ret) goto out_free; return 0; out_free_irqs: armpmu_free_irqs(pmu); out_free: pr_info("%pOF: failed to register PMU devices!\n", node); armpmu_free(pmu); return ret; }
static int cpu_pmu_device_probe(struct platform_device *pdev) { const struct of_device_id *of_id; const int (*init_fn)(struct arm_pmu *); struct device_node *node = pdev->dev.of_node; struct arm_pmu *pmu; int ret = -ENODEV; if (cpu_pmu) { pr_info("attempt to register multiple PMU devices!\n"); return -ENOSPC; } pmu = kzalloc(sizeof(struct arm_pmu), GFP_KERNEL); if (!pmu) { pr_info("failed to allocate PMU device!\n"); return -ENOMEM; } cpu_pmu = pmu; cpu_pmu->plat_device = pdev; if (node && (of_id = of_match_node(cpu_pmu_of_device_ids, pdev->dev.of_node))) { init_fn = of_id->data; ret = of_pmu_irq_cfg(pdev); if (!ret) ret = init_fn(pmu); } else { ret = probe_current_pmu(pmu); } if (ret) { pr_info("failed to probe PMU!\n"); goto out_free; } ret = cpu_pmu_init(cpu_pmu); if (ret) goto out_free; ret = armpmu_register(cpu_pmu, -1); if (ret) goto out_destroy; return 0; out_destroy: cpu_pmu_destroy(cpu_pmu); out_free: pr_info("failed to register PMU devices!\n"); kfree(pmu); return ret; }