devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <zonque@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: eric.piel@tremplin-utc.net, grant.likely@secretlab.ca,
	rob.herring@calxeda.com, devicetree-discuss@lists.ozlabs.org,
	Daniel Mack <zonque@gmail.com>
Subject: [PATCH v3 2/2] lis3-spi: add DT matching table passthru code
Date: Mon, 30 Jul 2012 09:36:15 +0200	[thread overview]
Message-ID: <1343633775-6268-2-git-send-email-zonque@gmail.com> (raw)
In-Reply-To: <1343633775-6268-1-git-send-email-zonque@gmail.com>

If probed from a device tree, this driver now passes the node
information to the generic part, so the runtime information can be
derived.

Successfully tested on a PXA3xx board.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---

No changes from v1 and v2

 drivers/misc/lis3lv02d/lis3lv02d_spi.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d_spi.c b/drivers/misc/lis3lv02d/lis3lv02d_spi.c
index 80880e9..8616054 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_spi.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_spi.c
@@ -17,6 +17,7 @@
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
 #include <linux/pm.h>
+#include <linux/of_platform.h>
 
 #include "lis3lv02d.h"
 
@@ -58,6 +59,12 @@ static int lis3_spi_init(struct lis3lv02d *lis3)
 static union axis_conversion lis3lv02d_axis_normal =
 	{ .as_array = { 1, 2, 3 } };
 
+static struct of_device_id lis302dl_spi_dt_ids[] = {
+	{ .compatible = "st,lis302dl-spi" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, lis302dl_spi_dt_ids);
+
 static int __devinit lis302dl_spi_probe(struct spi_device *spi)
 {
 	int ret;
@@ -75,6 +82,12 @@ static int __devinit lis302dl_spi_probe(struct spi_device *spi)
 	lis3_dev.irq		= spi->irq;
 	lis3_dev.ac		= lis3lv02d_axis_normal;
 	lis3_dev.pdata		= spi->dev.platform_data;
+
+#ifdef CONFIG_OF
+	if (of_match_device(lis302dl_spi_dt_ids, &spi->dev))
+		lis3_dev.of_node = spi->dev.of_node;
+#endif
+
 	spi_set_drvdata(spi, &lis3_dev);
 
 	return lis3lv02d_init_device(&lis3_dev);
@@ -121,6 +134,7 @@ static struct spi_driver lis302dl_spi_driver = {
 		.name   = DRV_NAME,
 		.owner  = THIS_MODULE,
 		.pm	= &lis3lv02d_spi_pm,
+		.of_match_table = of_match_ptr(lis302dl_spi_dt_ids),
 	},
 	.probe	= lis302dl_spi_probe,
 	.remove	= __devexit_p(lis302dl_spi_remove),
-- 
1.7.11.2

  reply	other threads:[~2012-07-30  7:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-30  7:36 [PATCH v3 1/2] lis3: add generic DT matching code Daniel Mack
2012-07-30  7:36 ` Daniel Mack [this message]
     [not found] ` <1343633775-6268-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-08-05 16:18   ` Daniel Mack
2012-08-06  4:52     ` Rob Herring
     [not found]       ` <501F4DA4.6010506-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-08-06  5:21         ` Daniel Mack
     [not found]     ` <501E9CE2.20500-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-08-06 10:45       ` AnilKumar, Chimata
2012-08-07 18:49         ` Daniel Mack
     [not found]           ` <5021631D.1030505-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-08-08  5:19             ` AnilKumar, Chimata
2012-08-08  6:57               ` Daniel Mack
2012-08-15  7:13           ` Éric Piel
     [not found]             ` <502B4C19.7060701-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
2012-08-15  8:20               ` Daniel Mack

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=1343633775-6268-2-git-send-email-zonque@gmail.com \
    --to=zonque@gmail.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=eric.piel@tremplin-utc.net \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    /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;
as well as URLs for NNTP newsgroup(s).