mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier@osg.samsung.com>
To: linux-kernel@vger.kernel.org
Cc: Javier Martinez Canillas <javier@osg.samsung.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	rtc-linux@googlegroups.com,
	Alessandro Zummo <a.zummo@towertech.it>
Subject: [PATCH 01/13] rtc: rv8803: Add OF device ID table
Date: Fri,  3 Mar 2017 11:29:12 -0300	[thread overview]
Message-ID: <20170303142925.17915-2-javier@osg.samsung.com> (raw)
In-Reply-To: <20170303142925.17915-1-javier@osg.samsung.com>

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>
---

 drivers/rtc/rtc-rv8803.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index f9277e536f7e..9ad97ab29866 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/rtc.h>
 
 #define RV8803_I2C_TRY_COUNT		4
@@ -556,7 +557,11 @@ static int rv8803_probe(struct i2c_client *client,
 
 	mutex_init(&rv8803->flags_lock);
 	rv8803->client = client;
-	rv8803->type = id->driver_data;
+	if (client->dev.of_node)
+		rv8803->type = (enum rv8803_type)
+			of_device_get_match_data(&client->dev);
+	else
+		rv8803->type = id->driver_data;
 	i2c_set_clientdata(client, rv8803);
 
 	flags = rv8803_read_reg(client, RV8803_FLAG);
@@ -627,9 +632,23 @@ static const struct i2c_device_id rv8803_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rv8803_id);
 
+static const struct of_device_id rv8803_of_match[] = {
+	{
+		.compatible = "microcrystal,rv8803",
+		.data = (void *)rx_8900
+	},
+	{
+		.compatible = "epson,rx8900",
+		.data = (void *)rx_8900
+	},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rv8803_of_match);
+
 static struct i2c_driver rv8803_driver = {
 	.driver = {
 		.name = "rtc-rv8803",
+		.of_match_table = of_match_ptr(rv8803_of_match),
 	},
 	.probe		= rv8803_probe,
 	.remove		= rv8803_remove,
-- 
2.9.3

  reply	other threads:[~2017-03-03 14:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
2017-03-03 14:29 ` Javier Martinez Canillas [this message]
2017-03-03 14:29 ` [PATCH 02/13] rtc: rv3029: Add OF device ID table Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 03/13] rtc: bq32k: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 04/13] rtc: ds1307: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 05/13] rtc: rx8010: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 06/13] rtc: ds3232: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 07/13] rtc: rtc-ds1672: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 08/13] rtc: ds1374: Set .of_match_table to " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 09/13] rtc: isl1208: Add " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 10/13] rtc: s35390a: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 11/13] rtc: rx8581: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 12/13] rtc: m41t80: " Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 13/13] rtc: rs5c372: " Javier Martinez Canillas
2017-03-03 15:01 ` [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Alexandre Belloni
2017-03-03 15:27   ` Javier Martinez Canillas
2017-03-03 16:04     ` Alexandre Belloni
2017-03-03 17:08       ` Javier Martinez Canillas
2017-03-09  0:30 ` Alexandre Belloni

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=20170303142925.17915-2-javier@osg.samsung.com \
    --to=javier@osg.samsung.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.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

all inboxes | Powered by JetHome®