All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: adxl34x: Add OF match support
@ 2014-12-18  2:15 ` Laurent Pinchart
  0 siblings, 0 replies; 28+ messages in thread
From: Laurent Pinchart @ 2014-12-18  2:15 UTC (permalink / raw)
  To: linux-input; +Cc: linux-sh, linux-i2c, Geert Uytterhoeven, Wolfram Sang

The I2C subsystem can match devices without explicit OF support based on
the part of their compatible property after the comma. However, this
mechanism uses the first compatible value only. For adxl34x OF device
nodes the compatible property should list the more specific
"adi,adxl345" or "adi,adxl346" value first and the "adi,adxl34x"
fallback value second. This prevents the device node from being matched
with the adxl34x driver.

Fix this by adding an OF match table with an "adi,adxl34x" compatible
entry.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/input/misc/adxl34x-i2c.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Another option would have been to add "adxl325" and "adxl326" entries to the
adxl34x_id I2C match table, but it would have had the drawback of requiring a
driver update for every new device.

diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c
index 416f47ddcc90..22687b738811 100644
--- a/drivers/input/misc/adxl34x-i2c.c
+++ b/drivers/input/misc/adxl34x-i2c.c
@@ -10,6 +10,7 @@
 #include <linux/input.h>	/* BUS_I2C */
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/types.h>
 #include <linux/pm.h>
 #include "adxl34x.h"
@@ -137,11 +138,21 @@ static const struct i2c_device_id adxl34x_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, adxl34x_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id adxl34x_of_id[] = {
+	{ .compatible = "adi,adxl34x", },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, adxl34x_of_id);
+#endif
+
 static struct i2c_driver adxl34x_driver = {
 	.driver = {
 		.name = "adxl34x",
 		.owner = THIS_MODULE,
 		.pm = &adxl34x_i2c_pm,
+		.of_match_table = of_match_ptr(adxl34x_of_id),
 	},
 	.probe    = adxl34x_i2c_probe,
 	.remove   = adxl34x_i2c_remove,
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2015-01-15 14:38 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18  2:15 [PATCH] input: adxl34x: Add OF match support Laurent Pinchart
2014-12-18  2:15 ` Laurent Pinchart
2014-12-18  8:21 ` Wolfram Sang
2014-12-18  8:21   ` Wolfram Sang
2014-12-18 12:49   ` Laurent Pinchart
2014-12-18 12:49     ` Laurent Pinchart
2014-12-18 13:03     ` Geert Uytterhoeven
2014-12-18 13:03       ` Geert Uytterhoeven
     [not found]       ` <CAMuHMdXcfe0JQhZzGSAoqjKR346-QJrvyi=afHF7cAaHKa56pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-18 19:23         ` Laurent Pinchart
2014-12-18 19:23           ` Laurent Pinchart
2015-01-05  8:27           ` Laurent Pinchart
2015-01-05  8:27             ` Laurent Pinchart
2015-01-06 13:28           ` Geert Uytterhoeven
2015-01-06 13:28             ` Geert Uytterhoeven
2015-01-15 12:53     ` Wolfram Sang
2015-01-15 12:53       ` Wolfram Sang
2015-01-15 13:03       ` Geert Uytterhoeven
2015-01-15 13:03         ` Geert Uytterhoeven
2015-01-15 14:19       ` Laurent Pinchart
2015-01-15 14:19         ` Laurent Pinchart
2015-01-15 14:23         ` Laurent Pinchart
2015-01-15 14:23           ` Laurent Pinchart
2015-01-15 14:36           ` Wolfram Sang
2015-01-15 14:36             ` Wolfram Sang
2015-01-15 14:38             ` Laurent Pinchart
2015-01-15 14:38               ` Laurent Pinchart
2015-01-15 14:23         ` Geert Uytterhoeven
2015-01-15 14:23           ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.