diff options
author | Robin Murphy <robin.murphy@arm.com> | 2018-02-15 13:51:45 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2018-03-06 11:27:09 -0500 |
commit | 32837954db462ecc28051923109ef6e4a221f2b2 (patch) | |
tree | 5074da12f055deb00b313ee2d4de6e765a0faa5a /drivers/perf | |
parent | 3ee5e821f3a1affd406ff1031f4cf6d7b4f81ab3 (diff) |
perf/arm-cci: Clean up model discovery
Since I am the self-appointed of_device_get_match_data() police, it's
only right that I should clean up this driver while I'm otherwise
touching it. This also reveals that we're passing around a struct
platform_device in places where we only ever care about its regular
device, so straighten that out in the process.
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/perf')
-rw-r--r-- | drivers/perf/arm-cci.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c index 242623fbce1f..336f1455cf96 100644 --- a/drivers/perf/arm-cci.c +++ b/drivers/perf/arm-cci.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/of_address.h> | 10 | #include <linux/of_address.h> |
11 | #include <linux/of_device.h> | ||
11 | #include <linux/of_irq.h> | 12 | #include <linux/of_irq.h> |
12 | #include <linux/of_platform.h> | 13 | #include <linux/of_platform.h> |
13 | #include <linux/perf_event.h> | 14 | #include <linux/perf_event.h> |
@@ -371,14 +372,14 @@ static int probe_cci400_revision(void) | |||
371 | return CCI400_R1; | 372 | return CCI400_R1; |
372 | } | 373 | } |
373 | 374 | ||
374 | static const struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) | 375 | static const struct cci_pmu_model *probe_cci_model(void) |
375 | { | 376 | { |
376 | if (platform_has_secure_cci_access()) | 377 | if (platform_has_secure_cci_access()) |
377 | return &cci_pmu_models[probe_cci400_revision()]; | 378 | return &cci_pmu_models[probe_cci400_revision()]; |
378 | return NULL; | 379 | return NULL; |
379 | } | 380 | } |
380 | #else /* !CONFIG_ARM_CCI400_PMU */ | 381 | #else /* !CONFIG_ARM_CCI400_PMU */ |
381 | static inline struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) | 382 | static inline struct cci_pmu_model *probe_cci_model(void) |
382 | { | 383 | { |
383 | return NULL; | 384 | return NULL; |
384 | } | 385 | } |
@@ -1589,20 +1590,6 @@ static const struct of_device_id arm_cci_pmu_matches[] = { | |||
1589 | {}, | 1590 | {}, |
1590 | }; | 1591 | }; |
1591 | 1592 | ||
1592 | static inline const struct cci_pmu_model *get_cci_model(struct platform_device *pdev) | ||
1593 | { | ||
1594 | const struct of_device_id *match = of_match_node(arm_cci_pmu_matches, | ||
1595 | pdev->dev.of_node); | ||
1596 | if (!match) | ||
1597 | return NULL; | ||
1598 | if (match->data) | ||
1599 | return match->data; | ||
1600 | |||
1601 | dev_warn(&pdev->dev, "DEPRECATED compatible property," | ||
1602 | "requires secure access to CCI registers"); | ||
1603 | return probe_cci_model(pdev); | ||
1604 | } | ||
1605 | |||
1606 | static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) | 1593 | static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) |
1607 | { | 1594 | { |
1608 | int i; | 1595 | int i; |
@@ -1614,7 +1601,7 @@ static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) | |||
1614 | return false; | 1601 | return false; |
1615 | } | 1602 | } |
1616 | 1603 | ||
1617 | static struct cci_pmu *cci_pmu_alloc(struct platform_device *pdev) | 1604 | static struct cci_pmu *cci_pmu_alloc(struct device *dev) |
1618 | { | 1605 | { |
1619 | struct cci_pmu *cci_pmu; | 1606 | struct cci_pmu *cci_pmu; |
1620 | const struct cci_pmu_model *model; | 1607 | const struct cci_pmu_model *model; |
@@ -1624,28 +1611,33 @@ static struct cci_pmu *cci_pmu_alloc(struct platform_device *pdev) | |||
1624 | * them explicitly on an error, as it would end up in driver | 1611 | * them explicitly on an error, as it would end up in driver |
1625 | * detach. | 1612 | * detach. |
1626 | */ | 1613 | */ |
1627 | model = get_cci_model(pdev); | 1614 | model = of_device_get_match_data(dev); |
1615 | if (!model) { | ||
1616 | dev_warn(dev, | ||
1617 | "DEPRECATED compatible property, requires secure access to CCI registers"); | ||
1618 | model = probe_cci_model(); | ||
1619 | } | ||
1628 | if (!model) { | 1620 | if (!model) { |
1629 | dev_warn(&pdev->dev, "CCI PMU version not supported\n"); | 1621 | dev_warn(dev, "CCI PMU version not supported\n"); |
1630 | return ERR_PTR(-ENODEV); | 1622 | return ERR_PTR(-ENODEV); |
1631 | } | 1623 | } |
1632 | 1624 | ||
1633 | cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*cci_pmu), GFP_KERNEL); | 1625 | cci_pmu = devm_kzalloc(dev, sizeof(*cci_pmu), GFP_KERNEL); |
1634 | if (!cci_pmu) | 1626 | if (!cci_pmu) |
1635 | return ERR_PTR(-ENOMEM); | 1627 | return ERR_PTR(-ENOMEM); |
1636 | 1628 | ||
1637 | cci_pmu->model = model; | 1629 | cci_pmu->model = model; |
1638 | cci_pmu->irqs = devm_kcalloc(&pdev->dev, CCI_PMU_MAX_HW_CNTRS(model), | 1630 | cci_pmu->irqs = devm_kcalloc(dev, CCI_PMU_MAX_HW_CNTRS(model), |
1639 | sizeof(*cci_pmu->irqs), GFP_KERNEL); | 1631 | sizeof(*cci_pmu->irqs), GFP_KERNEL); |
1640 | if (!cci_pmu->irqs) | 1632 | if (!cci_pmu->irqs) |
1641 | return ERR_PTR(-ENOMEM); | 1633 | return ERR_PTR(-ENOMEM); |
1642 | cci_pmu->hw_events.events = devm_kcalloc(&pdev->dev, | 1634 | cci_pmu->hw_events.events = devm_kcalloc(dev, |
1643 | CCI_PMU_MAX_HW_CNTRS(model), | 1635 | CCI_PMU_MAX_HW_CNTRS(model), |
1644 | sizeof(*cci_pmu->hw_events.events), | 1636 | sizeof(*cci_pmu->hw_events.events), |
1645 | GFP_KERNEL); | 1637 | GFP_KERNEL); |
1646 | if (!cci_pmu->hw_events.events) | 1638 | if (!cci_pmu->hw_events.events) |
1647 | return ERR_PTR(-ENOMEM); | 1639 | return ERR_PTR(-ENOMEM); |
1648 | cci_pmu->hw_events.used_mask = devm_kcalloc(&pdev->dev, | 1640 | cci_pmu->hw_events.used_mask = devm_kcalloc(dev, |
1649 | BITS_TO_LONGS(CCI_PMU_MAX_HW_CNTRS(model)), | 1641 | BITS_TO_LONGS(CCI_PMU_MAX_HW_CNTRS(model)), |
1650 | sizeof(*cci_pmu->hw_events.used_mask), | 1642 | sizeof(*cci_pmu->hw_events.used_mask), |
1651 | GFP_KERNEL); | 1643 | GFP_KERNEL); |
@@ -1661,7 +1653,7 @@ static int cci_pmu_probe(struct platform_device *pdev) | |||
1661 | struct cci_pmu *cci_pmu; | 1653 | struct cci_pmu *cci_pmu; |
1662 | int i, ret, irq; | 1654 | int i, ret, irq; |
1663 | 1655 | ||
1664 | cci_pmu = cci_pmu_alloc(pdev); | 1656 | cci_pmu = cci_pmu_alloc(&pdev->dev); |
1665 | if (IS_ERR(cci_pmu)) | 1657 | if (IS_ERR(cci_pmu)) |
1666 | return PTR_ERR(cci_pmu); | 1658 | return PTR_ERR(cci_pmu); |
1667 | 1659 | ||