Skip to content

Commit

Permalink
drivers/misc/lis3lv02d/lis3lv02d_spi.c: add DT matching table passthr…
Browse files Browse the repository at this point in the history
…u code

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.

[[email protected]: fix lis302dl_spi_dt_ids unused warning when CONFIG_OF=n]
Signed-off-by: Daniel Mack <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: "AnilKumar, Chimata" <[email protected]>
Reviewed-by: Éric Piel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
zonque authored and gregkh committed Sep 26, 2012
1 parent cbac1a8 commit 4bcdea8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/misc/lis3lv02d/lis3lv02d_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <linux/workqueue.h>
#include <linux/spi/spi.h>
#include <linux/pm.h>
#include <linux/of.h>
#include <linux/of_platform.h>

#include "lis3lv02d.h"

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 4bcdea8

Please sign in to comment.