aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier@osg.samsung.com>2017-02-22 13:14:20 -0500
committerMark Brown <broonie@kernel.org>2017-02-22 13:50:09 -0500
commit68c97b92c0a0dfdc134564f1f1c04b1c8ed27bba (patch)
tree97b3c226ea9ff3342aca0535b829ab7f62f90bcf
parent57f22cd29cf1b4ff2aea8505eae2d3ed71ca5de4 (diff)
spi: sc18is602: Add OF device ID table
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-sc18is602.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/spi/spi-sc18is602.c b/drivers/spi/spi-sc18is602.c
index f63714ffb62f..52cf0e9189c2 100644
--- a/drivers/spi/spi-sc18is602.c
+++ b/drivers/spi/spi-sc18is602.c
@@ -21,6 +21,7 @@
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/of_device.h>
24#include <linux/of.h> 25#include <linux/of.h>
25#include <linux/platform_data/sc18is602.h> 26#include <linux/platform_data/sc18is602.h>
26#include <linux/gpio/consumer.h> 27#include <linux/gpio/consumer.h>
@@ -271,7 +272,10 @@ static int sc18is602_probe(struct i2c_client *client,
271 hw->dev = dev; 272 hw->dev = dev;
272 hw->ctrl = 0xff; 273 hw->ctrl = 0xff;
273 274
274 hw->id = id->driver_data; 275 if (client->dev.of_node)
276 hw->id = (enum chips)of_device_get_match_data(&client->dev);
277 else
278 hw->id = id->driver_data;
275 279
276 switch (hw->id) { 280 switch (hw->id) {
277 case sc18is602: 281 case sc18is602:
@@ -323,9 +327,27 @@ static const struct i2c_device_id sc18is602_id[] = {
323}; 327};
324MODULE_DEVICE_TABLE(i2c, sc18is602_id); 328MODULE_DEVICE_TABLE(i2c, sc18is602_id);
325 329
330static const struct of_device_id sc18is602_of_match[] = {
331 {
332 .compatible = "nxp,sc18is602",
333 .data = (void *)sc18is602
334 },
335 {
336 .compatible = "nxp,sc18is602b",
337 .data = (void *)sc18is602b
338 },
339 {
340 .compatible = "nxp,sc18is603",
341 .data = (void *)sc18is603
342 },
343 { },
344};
345MODULE_DEVICE_TABLE(of, sc18is602_of_match);
346
326static struct i2c_driver sc18is602_driver = { 347static struct i2c_driver sc18is602_driver = {
327 .driver = { 348 .driver = {
328 .name = "sc18is602", 349 .name = "sc18is602",
350 .of_match_table = of_match_ptr(sc18is602_of_match),
329 }, 351 },
330 .probe = sc18is602_probe, 352 .probe = sc18is602_probe,
331 .id_table = sc18is602_id, 353 .id_table = sc18is602_id,