From patchwork Mon Feb 5 18:39:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10201277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 004AD6056A for ; Mon, 5 Feb 2018 18:41:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4EC2287C5 for ; Mon, 5 Feb 2018 18:41:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9252287FB; Mon, 5 Feb 2018 18:41:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5861E287CF for ; Mon, 5 Feb 2018 18:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WS8uv9TK+dnA+G3/sMnvf3Uo2ygkVbsoHMI8r7c3n/4=; b=qZRODo5ajhu48TV9wL2mNFGolx jlTInJH9u+Prj178bryB1YlPniIb7hUBLyv4d1qmcxbdijZl/zEaMmkS8CNOp5A0B+Z+Rgwh+oXsT 5XGWUNefCPC4kkQfn9QpQt1mWMZOqnmkGfkBHmCW4hBBCx2cTscqh32Xjh0hYFqlkPDBpG8xe0UCy c7lbt2nI2YuhcFPirTxpHBUs1+OpNAL5XFRAs2/VCJyLvx0honVpZPEyNT8N6yeojxHRAJzPEpCPA r7NxyYZMP+6JbuBBWKM/tgKVFot33f/SfN9QhTHtDPNmFzvltYpo3CwKo/Agz/A549CDqfiy0+1lM yB6IGJew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eilhY-0002KL-KL; Mon, 05 Feb 2018 18:41:12 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eilgc-0000V6-Ow for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2018 18:40:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EDA37164F; Mon, 5 Feb 2018 10:40:02 -0800 (PST) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BBE9C3F24D; Mon, 5 Feb 2018 10:40:01 -0800 (PST) From: Robin Murphy To: will.deacon@arm.com, mark.rutland@arm.com Subject: [PATCH 5/5] perf/arm-cci: Clean up model discovery Date: Mon, 5 Feb 2018 18:39:46 +0000 Message-Id: X-Mailer: git-send-email 2.16.1.dirty In-Reply-To: References: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: punit.agrawal@arm.com, linux-arm-kernel@lists.infradead.org, pawel.moll@arm.com, suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Robin Murphy --- drivers/perf/arm-cci.c | 40 ++++++++++++++++------------------------ 1 file 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 @@ #include #include #include +#include #include #include #include @@ -371,14 +372,14 @@ static int probe_cci400_revision(void) return CCI400_R1; } -static const struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) +static const struct cci_pmu_model *probe_cci_model(void) { if (platform_has_secure_cci_access()) return &cci_pmu_models[probe_cci400_revision()]; return NULL; } #else /* !CONFIG_ARM_CCI400_PMU */ -static inline struct cci_pmu_model *probe_cci_model(struct platform_device *pdev) +static inline struct cci_pmu_model *probe_cci_model(void) { return NULL; } @@ -1589,20 +1590,6 @@ static const struct of_device_id arm_cci_pmu_matches[] = { {}, }; -static inline const struct cci_pmu_model *get_cci_model(struct platform_device *pdev) -{ - const struct of_device_id *match = of_match_node(arm_cci_pmu_matches, - pdev->dev.of_node); - if (!match) - return NULL; - if (match->data) - return match->data; - - dev_warn(&pdev->dev, "DEPRECATED compatible property," - "requires secure access to CCI registers"); - return probe_cci_model(pdev); -} - static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) { int i; @@ -1614,7 +1601,7 @@ static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs) return false; } -static struct cci_pmu *cci_pmu_alloc(struct platform_device *pdev) +static struct cci_pmu *cci_pmu_alloc(struct device *dev) { struct cci_pmu *cci_pmu; const struct cci_pmu_model *model; @@ -1624,28 +1611,33 @@ static struct cci_pmu *cci_pmu_alloc(struct platform_device *pdev) * them explicitly on an error, as it would end up in driver * detach. */ - model = get_cci_model(pdev); + model = of_device_get_match_data(dev); if (!model) { - dev_warn(&pdev->dev, "CCI PMU version not supported\n"); + dev_warn(dev, + "DEPRECATED compatible property, requires secure access to CCI registers"); + model = probe_cci_model(); + } + if (!model) { + dev_warn(dev, "CCI PMU version not supported\n"); return ERR_PTR(-ENODEV); } - cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*cci_pmu), GFP_KERNEL); + cci_pmu = devm_kzalloc(dev, sizeof(*cci_pmu), GFP_KERNEL); if (!cci_pmu) return ERR_PTR(-ENOMEM); cci_pmu->model = model; - cci_pmu->irqs = devm_kcalloc(&pdev->dev, CCI_PMU_MAX_HW_CNTRS(model), + cci_pmu->irqs = devm_kcalloc(dev, CCI_PMU_MAX_HW_CNTRS(model), sizeof(*cci_pmu->irqs), GFP_KERNEL); if (!cci_pmu->irqs) return ERR_PTR(-ENOMEM); - cci_pmu->hw_events.events = devm_kcalloc(&pdev->dev, + cci_pmu->hw_events.events = devm_kcalloc(dev, CCI_PMU_MAX_HW_CNTRS(model), sizeof(*cci_pmu->hw_events.events), GFP_KERNEL); if (!cci_pmu->hw_events.events) return ERR_PTR(-ENOMEM); - cci_pmu->hw_events.used_mask = devm_kcalloc(&pdev->dev, + cci_pmu->hw_events.used_mask = devm_kcalloc(dev, BITS_TO_LONGS(CCI_PMU_MAX_HW_CNTRS(model)), sizeof(*cci_pmu->hw_events.used_mask), GFP_KERNEL); @@ -1661,7 +1653,7 @@ static int cci_pmu_probe(struct platform_device *pdev) struct cci_pmu *cci_pmu; int i, ret, irq; - cci_pmu = cci_pmu_alloc(pdev); + cci_pmu = cci_pmu_alloc(&pdev->dev); if (IS_ERR(cci_pmu)) return PTR_ERR(cci_pmu);