From 4bcdea86f176e96d44531c1e54a1b5c92672424d Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 26 Sep 2012 13:58:19 -0700 Subject: drivers/misc/lis3lv02d/lis3lv02d_spi.c: add DT matching table passthru code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. [akpm@linux-foundation.org: fix lis302dl_spi_dt_ids unused warning when CONFIG_OF=n] Signed-off-by: Daniel Mack Cc: Rob Herring Cc: "AnilKumar, Chimata" Reviewed-by: Éric Piel Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/misc/lis3lv02d/lis3lv02d_spi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/misc/lis3lv02d/lis3lv02d_spi.c') diff --git a/drivers/misc/lis3lv02d/lis3lv02d_spi.c b/drivers/misc/lis3lv02d/lis3lv02d_spi.c index 80880e984b4f..4b8ccf200194 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d_spi.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_spi.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "lis3lv02d.h" @@ -58,6 +60,14 @@ static int lis3_spi_init(struct lis3lv02d *lis3) static union axis_conversion lis3lv02d_axis_normal = { .as_array = { 1, 2, 3 } }; +#ifdef CONFIG_OF +static struct of_device_id lis302dl_spi_dt_ids[] = { + { .compatible = "st,lis302dl-spi" }, + {} +}; +MODULE_DEVICE_TABLE(of, lis302dl_spi_dt_ids); +#endif + static int __devinit lis302dl_spi_probe(struct spi_device *spi) { int ret; @@ -75,6 +85,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 +137,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), -- cgit v1.2.3