Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Robin Murphy and committed by
Arnd Bergmann
32837954 3ee5e821

+16 -24
+16 -24
drivers/perf/arm-cci.c
··· 8 8 #include <linux/interrupt.h> 9 9 #include <linux/module.h> 10 10 #include <linux/of_address.h> 11 + #include <linux/of_device.h> 11 12 #include <linux/of_irq.h> 12 13 #include <linux/of_platform.h> 13 14 #include <linux/perf_event.h> ··· 372 371 return CCI400_R1; 373 372 } 374 373 375 - static const struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) 374 + static const struct cci_pmu_model *probe_cci_model(void) 376 375 { 377 376 if (platform_has_secure_cci_access()) 378 377 return &cci_pmu_models[probe_cci400_revision()]; 379 378 return NULL; 380 379 } 381 380 #else /* !CONFIG_ARM_CCI400_PMU */ 382 - static inline struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) 381 + static inline struct cci_pmu_model *probe_cci_model(void) 383 382 { 384 383 return NULL; 385 384 } ··· 1590 1589 {}, 1591 1590 }; 1592 1591 1593 - static inline const struct cci_pmu_model *get_cci_model(struct platform_device *pdev) 1594 - { 1595 - const struct of_device_id *match = of_match_node(arm_cci_pmu_matches, 1596 - pdev->dev.of_node); 1597 - if (!match) 1598 - return NULL; 1599 - if (match->data) 1600 - return match->data; 1601 - 1602 - dev_warn(&pdev->dev, "DEPRECATED compatible property," 1603 - "requires secure access to CCI registers"); 1604 - return probe_cci_model(pdev); 1605 - } 1606 - 1607 1592 static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) 1608 1593 { 1609 1594 int i; ··· 1601 1614 return false; 1602 1615 } 1603 1616 1604 - static struct cci_pmu *cci_pmu_alloc(struct platform_device *pdev) 1617 + static struct cci_pmu *cci_pmu_alloc(struct device *dev) 1605 1618 { 1606 1619 struct cci_pmu *cci_pmu; 1607 1620 const struct cci_pmu_model *model; ··· 1611 1624 * them explicitly on an error, as it would end up in driver 1612 1625 * detach. 1613 1626 */ 1614 - model = get_cci_model(pdev); 1627 + model = of_device_get_match_data(dev); 1615 1628 if (!model) { 1616 - dev_warn(&pdev->dev, "CCI PMU version not supported\n"); 1629 + dev_warn(dev, 1630 + "DEPRECATED compatible property, requires secure access to CCI registers"); 1631 + model = probe_cci_model(); 1632 + } 1633 + if (!model) { 1634 + dev_warn(dev, "CCI PMU version not supported\n"); 1617 1635 return ERR_PTR(-ENODEV); 1618 1636 } 1619 1637 1620 - cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*cci_pmu), GFP_KERNEL); 1638 + cci_pmu = devm_kzalloc(dev, sizeof(*cci_pmu), GFP_KERNEL); 1621 1639 if (!cci_pmu) 1622 1640 return ERR_PTR(-ENOMEM); 1623 1641 1624 1642 cci_pmu->model = model; 1625 - cci_pmu->irqs = devm_kcalloc(&pdev->dev, CCI_PMU_MAX_HW_CNTRS(model), 1643 + cci_pmu->irqs = devm_kcalloc(dev, CCI_PMU_MAX_HW_CNTRS(model), 1626 1644 sizeof(*cci_pmu->irqs), GFP_KERNEL); 1627 1645 if (!cci_pmu->irqs) 1628 1646 return ERR_PTR(-ENOMEM); 1629 - cci_pmu->hw_events.events = devm_kcalloc(&pdev->dev, 1647 + cci_pmu->hw_events.events = devm_kcalloc(dev, 1630 1648 CCI_PMU_MAX_HW_CNTRS(model), 1631 1649 sizeof(*cci_pmu->hw_events.events), 1632 1650 GFP_KERNEL); 1633 1651 if (!cci_pmu->hw_events.events) 1634 1652 return ERR_PTR(-ENOMEM); 1635 - cci_pmu->hw_events.used_mask = devm_kcalloc(&pdev->dev, 1653 + cci_pmu->hw_events.used_mask = devm_kcalloc(dev, 1636 1654 BITS_TO_LONGS(CCI_PMU_MAX_HW_CNTRS(model)), 1637 1655 sizeof(*cci_pmu->hw_events.used_mask), 1638 1656 GFP_KERNEL); ··· 1653 1661 struct cci_pmu *cci_pmu; 1654 1662 int i, ret, irq; 1655 1663 1656 - cci_pmu = cci_pmu_alloc(pdev); 1664 + cci_pmu = cci_pmu_alloc(&pdev->dev); 1657 1665 if (IS_ERR(cci_pmu)) 1658 1666 return PTR_ERR(cci_pmu); 1659 1667