From patchwork Mon Jun 13 09:35:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 874302 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5D9betW009675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Jun 2011 09:38:00 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QW3aF-0007Yb-Tq; Mon, 13 Jun 2011 09:37:24 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QW3aD-0003vT-Q4; Mon, 13 Jun 2011 09:37:21 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QW3ZZ-0003k9-NH for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2011 09:36:43 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 13 Jun 2011 10:36:12 +0100 Received: from localhost.localdomain ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 13 Jun 2011 10:36:43 +0100 From: Mark Rutland To: Rob Herring Subject: [PATCH 4/4] ARM: pmu: add platform_device_id table support Date: Mon, 13 Jun 2011 10:35:57 +0100 Message-Id: <1307957757-23001-5-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <4DEFA5E1.9010600@gmail.com> References: <4DEFA5E1.9010600@gmail.com> X-OriginalArrivalTime: 13 Jun 2011 09:36:43.0676 (UTC) FILETIME=[67EFEDC0:01CC29AD] X-MC-Unique: 111061310361209101 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110613_053642_019136_2C1F781F X-CRM114-Status: GOOD ( 10.21 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: Mark Rutland , Jamie Iles , Will Deacon , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Jun 2011 09:38:01 +0000 (UTC) This patch adds support for platform_device_id tables, allowing new PMU types to be registered with the correct type, without requiring new platform_driver shims to provide the type. Macros matching functionality of the of_device_id table macros are provided for convenience. Cc: Jamie Iles Cc: Will Deacon Acked-by: Jamie Iles --- arch/arm/kernel/pmu.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c index d34cf88..23c3af2 100644 --- a/arch/arm/kernel/pmu.c +++ b/arch/arm/kernel/pmu.c @@ -62,9 +62,22 @@ static struct of_device_id armpmu_of_device_ids[] = { {}, }; +#define PLAT_MATCH_PMU(name, type) { \ + .name = name, \ + .driver_data = (void *) type, \ +} + +#define PLAT_MATCH_CPU(name) PLAT_MATCH_PMU(name, ARM_PMU_DEVICE_CPU) + +static struct platform_device_id armpmu_plat_device_ids[] = { + /* None for now */ + {}, +}; + enum arm_pmu_type armpmu_device_type(struct platform_device *pdev) { const struct of_device_id *of_id; + const struct platform_device_id *pdev_id; /* provided by of_device_id table */ if (pdev->dev.of_node) { @@ -73,6 +86,11 @@ enum arm_pmu_type armpmu_device_type(struct platform_device *pdev) return (enum arm_pmu_type) of_id->data; } + /* Provided by platform_device_id table */ + if ((pdev_id = platform_get_device_id(pdev))) { + return (enum arm_pmu_type) pdev_id->driver_data; + } + /* Provided by a 'legacy' platform_device */ return ARM_PMU_DEVICE_CPU; } @@ -88,6 +106,7 @@ static struct platform_driver armpmu_driver = { .of_match_table = armpmu_of_device_ids, }, .probe = armpmu_device_probe, + .id_table = armpmu_plat_device_ids, }; static int __init register_pmu_driver(void)