Devicetree
 help / color / mirror / Atom feed
From: Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [RFC PATCH] ARM: pmu: add OF match support
Date: Tue,  8 Feb 2011 21:53:37 -0600	[thread overview]
Message-ID: <1297223617-19173-1-git-send-email-robherring2@gmail.com> (raw)

From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>

Add OF match table to enable OF style driver binding. The dts entry is like
this:

pmu {
	compatible = "arm,pmu";
	interrupts = <100 101>;
};

The use of pdev->id as an index breaks with OF device binding. Change to use
a counter instead. If more than 1 pmu device is ever really supported, a
better solution to match users with particular pmu is probably needed.

Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
---
 arch/arm/kernel/pmu.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
index b8af96e..7084057 100644
--- a/arch/arm/kernel/pmu.c
+++ b/arch/arm/kernel/pmu.c
@@ -24,30 +24,37 @@
 static volatile long pmu_lock;
 
 static struct platform_device *pmu_devices[ARM_NUM_PMU_DEVICES];
+static int pmu_device_count;
 
 static int __devinit pmu_device_probe(struct platform_device *pdev)
 {
 
-	if (pdev->id < 0 || pdev->id >= ARM_NUM_PMU_DEVICES) {
+	if (pmu_device_count >= ARM_NUM_PMU_DEVICES) {
 		pr_warning("received registration request for unknown "
 				"device %d\n", pdev->id);
 		return -EINVAL;
 	}
 
-	if (pmu_devices[pdev->id])
+	if (pmu_devices[pmu_device_count])
 		pr_warning("registering new PMU device type %d overwrites "
 				"previous registration!\n", pdev->id);
 	else
 		pr_info("registered new PMU device of type %d\n",
 				pdev->id);
 
-	pmu_devices[pdev->id] = pdev;
+	pmu_devices[pmu_device_count++] = pdev;
 	return 0;
 }
 
+static struct of_device_id pmu_device_ids[] = {
+	{ .compatible = "arm,pmu" },
+	{},
+};
+
 static struct platform_driver pmu_driver = {
 	.driver		= {
 		.name	= "arm-pmu",
+		.of_match_table = pmu_device_ids,
 	},
 	.probe		= pmu_device_probe,
 };
-- 
1.7.1

             reply	other threads:[~2011-02-09  3:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09  3:53 Rob Herring [this message]
     [not found] ` <1297223617-19173-1-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-09  9:51   ` [RFC PATCH] ARM: pmu: add OF match support Will Deacon
2011-02-09 17:13   ` Grant Likely
     [not found]     ` <AANLkTi=7azYw8+sYrbDsLOfF1aZynBDo+ub37O9j+k49-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-09 17:17       ` Will Deacon
2011-02-09 17:17     ` Will Deacon
     [not found]     ` <3399156206431206254@unknownmsgid>
2011-02-09 18:09       ` Grant Likely
2011-02-09 18:53         ` Will Deacon
     [not found]         ` <AANLkTin5aA0tq-PYBmRKh6tLv6bHRaK5ymjhsj9T4-Ah-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-09 18:53           ` Will Deacon
     [not found]         ` <-4919269306841091192@unknownmsgid>
2011-02-09 19:03           ` Grant Likely
     [not found]             ` <AANLkTikrBx1Y7MFGCJe=Gx-9fUxhwuYq-BZ4stGBGav6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-09 19:13               ` Lorenzo Pieralisi
2011-02-09 23:00               ` Rob Herring
     [not found]                 ` <4D531CA0.8050402-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-13  6:23                   ` Grant Likely
2011-02-09  9:51 ` Will Deacon
     [not found] ` <001b01cbc83e$ec0a59e0$c41f0da0$@deacon@arm.com>
     [not found]   ` <001b01cbc83e$ec0a59e0$c41f0da0$@deacon-5wv7dgnIgG8@public.gmane.org>
2011-02-09 14:02     ` Rob Herring
     [not found]       ` <4D529E82.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-09 16:55         ` Rob Herring
     [not found]           ` <4D52C6EA.1030600-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-09 17:10             ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297223617-19173-1-git-send-email-robherring2@gmail.com \
    --to=robherring2-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox