linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
@ 2017-03-03 14:29 Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 01/13] rtc: rv8803: Add OF device ID table Javier Martinez Canillas
                   ` (14 more replies)
  0 siblings, 15 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

Hello,

This series add OF device ID tables to RTC I2C drivers whose devices are
either used in Device Tree source files or are listed in binding docs as
a compatible string.

That's done because the plan is to change the I2C core to report proper OF
modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
a device was registered via DT or using the legacy platform data.

So these patches will make sure that RTC I2C drivers modules will continue
to be autoloaded once the I2C core is changed to report proper OF modalias.

Best regards,
Javier


Javier Martinez Canillas (13):
  rtc: rv8803: Add OF device ID table
  rtc: rv3029: Add OF device ID table
  rtc: bq32k: Add OF device ID table
  rtc: ds1307: Add OF device ID table
  rtc: rx8010: Add OF device ID table
  rtc: ds3232: Add OF device ID table
  rtc: rtc-ds1672: Add OF device ID table
  rtc: ds1374: Set .of_match_table to OF device ID table
  rtc: isl1208: Add OF device ID table
  rtc: s35390a: Add OF device ID table
  rtc: rx8581: Add OF device ID table
  rtc: m41t80: Add OF device ID table
  rtc: rs5c372: Add OF device ID table

 drivers/rtc/rtc-bq32k.c    |  7 +++++
 drivers/rtc/rtc-ds1307.c   | 68 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/rtc/rtc-ds1374.c   |  1 +
 drivers/rtc/rtc-ds1672.c   |  9 +++++-
 drivers/rtc/rtc-ds3232.c   |  7 +++++
 drivers/rtc/rtc-isl1208.c  | 12 ++++++--
 drivers/rtc/rtc-m41t80.c   | 63 ++++++++++++++++++++++++++++++++++++++++--
 drivers/rtc/rtc-rs5c372.c  | 37 ++++++++++++++++++++++++-
 drivers/rtc/rtc-rv3029c2.c |  9 ++++++
 drivers/rtc/rtc-rv8803.c   | 21 +++++++++++++-
 drivers/rtc/rtc-rx8010.c   |  7 +++++
 drivers/rtc/rtc-rx8581.c   |  7 +++++
 drivers/rtc/rtc-s35390a.c  |  8 ++++++
 13 files changed, 248 insertions(+), 8 deletions(-)

-- 
2.9.3

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

* [PATCH 01/13] rtc: rv8803: Add OF device ID table
  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
  2017-03-03 14:29 ` [PATCH 02/13] rtc: rv3029: " Javier Martinez Canillas
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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

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

* [PATCH 02/13] rtc: rv3029: Add OF device ID table
  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 ` [PATCH 01/13] rtc: rv8803: Add OF device ID table Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 03/13] rtc: bq32k: " Javier Martinez Canillas
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-rv3029c2.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index 1f9f7b4bf3fb..85fa1da03762 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -875,9 +875,18 @@ static struct i2c_device_id rv3029_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rv3029_id);
 
+static const struct of_device_id rv3029_of_match[] = {
+	{ .compatible = "rv3029" },
+	{ .compatible = "rv3029c2" },
+	{ .compatible = "mc,rv3029c2" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rv3029_of_match);
+
 static struct i2c_driver rv3029_driver = {
 	.driver = {
 		.name = "rtc-rv3029c2",
+		.of_match_table = of_match_ptr(rv3029_of_match),
 	},
 	.probe		= rv3029_i2c_probe,
 	.id_table	= rv3029_id,
-- 
2.9.3

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

* [PATCH 03/13] rtc: bq32k: Add OF device ID table
  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 ` [PATCH 01/13] rtc: rv8803: Add OF device ID table Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 02/13] rtc: rv3029: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 04/13] rtc: ds1307: " Javier Martinez Canillas
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-bq32k.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 2b223935001f..98ac8d5c7901 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -310,9 +310,16 @@ static const struct i2c_device_id bq32k_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, bq32k_id);
 
+static const struct of_device_id bq32k_of_match[] = {
+	{ .compatible = "ti,bq32000" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, bq32k_of_match);
+
 static struct i2c_driver bq32k_driver = {
 	.driver = {
 		.name	= "bq32k",
+		.of_match_table = of_match_ptr(bq32k_of_match),
 	},
 	.probe		= bq32k_probe,
 	.remove		= bq32k_remove,
-- 
2.9.3

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

* [PATCH 04/13] rtc: ds1307: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (2 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 03/13] rtc: bq32k: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 05/13] rtc: rx8010: " Javier Martinez Canillas
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-ds1307.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 4ad97be48043..f085b487bbe7 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -16,6 +16,7 @@
 #include <linux/i2c.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/rtc/ds1307.h>
 #include <linux/rtc.h>
 #include <linux/slab.h>
@@ -192,6 +193,65 @@ static const struct i2c_device_id ds1307_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds1307_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ds1307_of_match[] = {
+	{
+		.compatible = "dallas,ds1307",
+		.data = (void *)ds_1307
+	},
+	{
+		.compatible = "dallas,ds1337",
+		.data = (void *)ds_1337
+	},
+	{
+		.compatible = "dallas,ds1338",
+		.data = (void *)ds_1338
+	},
+	{
+		.compatible = "dallas,ds1339",
+		.data = (void *)ds_1339
+	},
+	{
+		.compatible = "dallas,ds1388",
+		.data = (void *)ds_1388
+	},
+	{
+		.compatible = "dallas,ds1340",
+		.data = (void *)ds_1340
+	},
+	{
+		.compatible = "maxim,ds3231",
+		.data = (void *)ds_3231
+	},
+	{
+		.compatible = "st,m41t00",
+		.data = (void *)m41t00
+	},
+	{
+		.compatible = "microchip,mcp7940x",
+		.data = (void *)mcp794xx
+	},
+	{
+		.compatible = "microchip,mcp7941x",
+		.data = (void *)mcp794xx
+	},
+	{
+		.compatible = "pericom,pt7c4338",
+		.data = (void *)ds_1307
+	},
+	{
+		.compatible = "epson,rx8025",
+		.data = (void *)rx_8025
+	},
+	{
+		.compatible = "isil,isl12057",
+		.data = (void *)ds_1337
+	},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ds1307_of_match);
+#endif
+
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id ds1307_acpi_ids[] = {
 	{ .id = "DS1307", .driver_data = ds_1307 },
@@ -1318,7 +1378,12 @@ static int ds1307_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, ds1307);
 
 	ds1307->client	= client;
-	if (id) {
+
+	if (client->dev.of_node) {
+		ds1307->type = (enum ds_type)
+			of_device_get_match_data(&client->dev);
+		chip = &chips[ds1307->type];
+	} else if (id) {
 		chip = &chips[id->driver_data];
 		ds1307->type = id->driver_data;
 	} else {
@@ -1711,6 +1776,7 @@ static int ds1307_remove(struct i2c_client *client)
 static struct i2c_driver ds1307_driver = {
 	.driver = {
 		.name	= "rtc-ds1307",
+		.of_match_table = of_match_ptr(ds1307_of_match),
 		.acpi_match_table = ACPI_PTR(ds1307_acpi_ids),
 	},
 	.probe		= ds1307_probe,
-- 
2.9.3

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

* [PATCH 05/13] rtc: rx8010: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (3 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 04/13] rtc: ds1307: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 06/13] rtc: ds3232: " Javier Martinez Canillas
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-rx8010.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
index d08da371912c..1ed3403ff8ac 100644
--- a/drivers/rtc/rtc-rx8010.c
+++ b/drivers/rtc/rtc-rx8010.c
@@ -59,6 +59,12 @@ static const struct i2c_device_id rx8010_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rx8010_id);
 
+static const struct of_device_id rx8010_of_match[] = {
+	{ .compatible = "epson,rx8010" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rx8010_of_match);
+
 struct rx8010_data {
 	struct i2c_client *client;
 	struct rtc_device *rtc;
@@ -487,6 +493,7 @@ static int rx8010_probe(struct i2c_client *client,
 static struct i2c_driver rx8010_driver = {
 	.driver = {
 		.name = "rtc-rx8010",
+		.of_match_table = of_match_ptr(rx8010_of_match),
 	},
 	.probe		= rx8010_probe,
 	.id_table	= rx8010_id,
-- 
2.9.3

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

* [PATCH 06/13] rtc: ds3232: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (4 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 05/13] rtc: rx8010: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 07/13] rtc: rtc-ds1672: " Javier Martinez Canillas
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-ds3232.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c
index 9bb39a06b994..deff431a37c4 100644
--- a/drivers/rtc/rtc-ds3232.c
+++ b/drivers/rtc/rtc-ds3232.c
@@ -442,9 +442,16 @@ static const struct i2c_device_id ds3232_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds3232_id);
 
+static const struct of_device_id ds3232_of_match[] = {
+	{ .compatible = "dallas,ds3232" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ds3232_of_match);
+
 static struct i2c_driver ds3232_driver = {
 	.driver = {
 		.name = "rtc-ds3232",
+		.of_match_table = of_match_ptr(ds3232_of_match),
 		.pm	= &ds3232_pm_ops,
 	},
 	.probe = ds3232_i2c_probe,
-- 
2.9.3

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

* [PATCH 07/13] rtc: rtc-ds1672: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (5 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 06/13] rtc: ds3232: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 08/13] rtc: ds1374: Set .of_match_table to " Javier Martinez Canillas
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-ds1672.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 5c18ac7394c4..7bf46bfe11a4 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -196,10 +196,17 @@ static struct i2c_device_id ds1672_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds1672_id);
 
+static const struct of_device_id ds1672_of_match[] = {
+	{ .compatible = "dallas,ds1672" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ds1672_of_match);
+
 static struct i2c_driver ds1672_driver = {
 	.driver = {
 		   .name = "rtc-ds1672",
-		   },
+		   .of_match_table = of_match_ptr(ds1672_of_match),
+	},
 	.probe = &ds1672_probe,
 	.id_table = ds1672_id,
 };
-- 
2.9.3

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

* [PATCH 08/13] rtc: ds1374: Set .of_match_table to OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (6 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 07/13] rtc: rtc-ds1672: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 09/13] rtc: isl1208: Add " Javier Martinez Canillas
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

The driver has a OF device ID table but the struct i2c_driver
.of_match_table field is not set.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

 drivers/rtc/rtc-ds1374.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 52429f0a57cc..4cd115e93223 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -704,6 +704,7 @@ static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume);
 static struct i2c_driver ds1374_driver = {
 	.driver = {
 		.name = "rtc-ds1374",
+		.of_match_table = of_match_ptr(ds1374_of_match),
 		.pm = &ds1374_pm,
 	},
 	.probe = ds1374_probe,
-- 
2.9.3

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

* [PATCH 09/13] rtc: isl1208: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (7 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 08/13] rtc: ds1374: Set .of_match_table to " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 10/13] rtc: s35390a: " Javier Martinez Canillas
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-isl1208.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 2893785f0eba..8dd299c6a1f3 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -687,10 +687,18 @@ static const struct i2c_device_id isl1208_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, isl1208_id);
 
+static const struct of_device_id isl1208_of_match[] = {
+	{ .compatible = "isil,isl1208" },
+	{ .compatible = "isil,isl1218" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, isl1208_of_match);
+
 static struct i2c_driver isl1208_driver = {
 	.driver = {
-		   .name = "rtc-isl1208",
-		   },
+		.name = "rtc-isl1208",
+		.of_match_table = of_match_ptr(isl1208_of_match),
+	},
 	.probe = isl1208_probe,
 	.remove = isl1208_remove,
 	.id_table = isl1208_id,
-- 
2.9.3

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

* [PATCH 10/13] rtc: s35390a: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (8 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 09/13] rtc: isl1208: Add " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 11/13] rtc: rx8581: " Javier Martinez Canillas
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-s35390a.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 5dab4665ca3b..449820eeefe8 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -58,6 +58,13 @@ static const struct i2c_device_id s35390a_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, s35390a_id);
 
+static const struct of_device_id s35390a_of_match[] = {
+	{ .compatible = "s35390a" },
+	{ .compatible = "sii,s35390a" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, s35390a_of_match);
+
 struct s35390a {
 	struct i2c_client *client[8];
 	struct rtc_device *rtc;
@@ -502,6 +509,7 @@ static int s35390a_remove(struct i2c_client *client)
 static struct i2c_driver s35390a_driver = {
 	.driver		= {
 		.name	= "rtc-s35390a",
+		.of_match_table = of_match_ptr(s35390a_of_match),
 	},
 	.probe		= s35390a_probe,
 	.remove		= s35390a_remove,
-- 
2.9.3

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

* [PATCH 11/13] rtc: rx8581: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (9 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 10/13] rtc: s35390a: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 12/13] rtc: m41t80: " Javier Martinez Canillas
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-rx8581.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index 0c362a3d1f17..9998d7937688 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -308,9 +308,16 @@ static const struct i2c_device_id rx8581_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rx8581_id);
 
+static const struct of_device_id rx8581_of_match[] = {
+	{ .compatible = "epson,rx8581" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rx8581_of_match);
+
 static struct i2c_driver rx8581_driver = {
 	.driver		= {
 		.name	= "rtc-rx8581",
+		.of_match_table = of_match_ptr(rx8581_of_match),
 	},
 	.probe		= rx8581_probe,
 	.id_table	= rx8581_id,
-- 
2.9.3

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

* [PATCH 12/13] rtc: m41t80: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (10 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 11/13] rtc: rx8581: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` Javier Martinez Canillas
  2017-03-03 14:29 ` [PATCH 13/13] rtc: rs5c372: " Javier Martinez Canillas
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-m41t80.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 58698d21c2c3..5b070aa711f9 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/rtc.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
@@ -86,8 +87,61 @@ static const struct i2c_device_id m41t80_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, m41t80_id);
 
+static const struct of_device_id m41t80_of_match[] = {
+	{
+		.compatible = "st,m41t62",
+		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT)
+	},
+	{
+		.compatible = "st,m41t65",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_WD)
+	},
+	{
+		.compatible = "st,m41t80",
+		.data = (void *)(M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t81",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t81s",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t82",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t83",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t84",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t85",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,m41t87",
+		.data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ)
+	},
+	{
+		.compatible = "st,rv4162",
+		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
+	},
+	{
+		.compatible = "rv4162",
+		.data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT)
+	},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, m41t80_of_match);
+
 struct m41t80_data {
-	u8 features;
+	unsigned long features;
 	struct rtc_device *rtc;
 };
 
@@ -786,7 +840,11 @@ static int m41t80_probe(struct i2c_client *client,
 	if (!m41t80_data)
 		return -ENOMEM;
 
-	m41t80_data->features = id->driver_data;
+	if (client->dev.of_node)
+		m41t80_data->features = (unsigned long)
+			of_device_get_match_data(&client->dev);
+	else
+		m41t80_data->features = id->driver_data;
 	i2c_set_clientdata(client, m41t80_data);
 
 	if (client->irq > 0) {
@@ -894,6 +952,7 @@ static int m41t80_remove(struct i2c_client *client)
 static struct i2c_driver m41t80_driver = {
 	.driver = {
 		.name = "rtc-m41t80",
+		.of_match_table = of_match_ptr(m41t80_of_match),
 		.pm = &m41t80_pm,
 	},
 	.probe = m41t80_probe,
-- 
2.9.3

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

* [PATCH 13/13] rtc: rs5c372: Add OF device ID table
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (11 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 12/13] rtc: m41t80: " Javier Martinez Canillas
@ 2017-03-03 14:29 ` 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-09  0:30 ` Alexandre Belloni
  14 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 14:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Alexandre Belloni, rtc-linux, Alessandro Zummo

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-rs5c372.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index c8c757466783..d4eff8d7131f 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -15,6 +15,7 @@
 #include <linux/bcd.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 
 /*
  * Ricoh has a family of I2C based RTCs, which differ only slightly from
@@ -83,6 +84,35 @@ static const struct i2c_device_id rs5c372_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rs5c372_id);
 
+static const struct of_device_id rs5c372_of_match[] = {
+	{
+		.compatible = "ricoh,r2025sd",
+		.data = (void *)rtc_r2025sd
+	},
+	{
+		.compatible = "ricoh,r2221tl",
+		.data = (void *)rtc_r2221tl
+	},
+	{
+		.compatible = "ricoh,rs5c372a",
+		.data = (void *)rtc_rs5c372a
+	},
+	{
+		.compatible = "ricoh,rs5c372b",
+		.data = (void *)rtc_rs5c372b
+	},
+	{
+		.compatible = "ricoh,rv5c386",
+		.data = (void *)rtc_rv5c386
+	},
+	{
+		.compatible = "ricoh,rv5c387a",
+		.data = (void *)rtc_rv5c387a
+	},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rs5c372_of_match);
+
 /* REVISIT:  this assumes that:
  *  - we're in the 21st century, so it's safe to ignore the century
  *    bit for rv5c38[67] (REG_MONTH bit 7);
@@ -581,7 +611,11 @@ static int rs5c372_probe(struct i2c_client *client,
 
 	rs5c372->client = client;
 	i2c_set_clientdata(client, rs5c372);
-	rs5c372->type = id->driver_data;
+	if (client->dev.of_node)
+		rs5c372->type = (enum rtc_type)
+			of_device_get_match_data(&client->dev);
+	else
+		rs5c372->type = id->driver_data;
 
 	/* we read registers 0x0f then 0x00-0x0f; skip the first one */
 	rs5c372->regs = &rs5c372->buf[1];
@@ -673,6 +707,7 @@ static int rs5c372_remove(struct i2c_client *client)
 static struct i2c_driver rs5c372_driver = {
 	.driver		= {
 		.name	= "rtc-rs5c372",
+		.of_match_table = of_match_ptr(rs5c372_of_match),
 	},
 	.probe		= rs5c372_probe,
 	.remove		= rs5c372_remove,
-- 
2.9.3

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

* Re: [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (12 preceding siblings ...)
  2017-03-03 14:29 ` [PATCH 13/13] rtc: rs5c372: " Javier Martinez Canillas
@ 2017-03-03 15:01 ` Alexandre Belloni
  2017-03-03 15:27   ` Javier Martinez Canillas
  2017-03-09  0:30 ` Alexandre Belloni
  14 siblings, 1 reply; 19+ messages in thread
From: Alexandre Belloni @ 2017-03-03 15:01 UTC (permalink / raw)
  To: Javier Martinez Canillas; +Cc: linux-kernel, rtc-linux, Alessandro Zummo

Hi,

On 03/03/2017 at 11:29:11 -0300, Javier Martinez Canillas wrote:
> This series add OF device ID tables to RTC I2C drivers whose devices are
> either used in Device Tree source files or are listed in binding docs as
> a compatible string.
> 
> That's done because the plan is to change the I2C core to report proper OF
> modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
> a device was registered via DT or using the legacy platform data.
> 

Doesn't that break the DT ABI for all i2c devices? A lot of people are
getting the vendor wrong in the compatible string and because the i2c
core doesn't care, the driver is still probed. Dropping that will break
all those DTBs.
Or will that only affect module autoload?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 15:27 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-kernel, rtc-linux, Alessandro Zummo

Hello Alexandre,

On 03/03/2017 12:01 PM, Alexandre Belloni wrote:
> Hi,
> 
> On 03/03/2017 at 11:29:11 -0300, Javier Martinez Canillas wrote:
>> This series add OF device ID tables to RTC I2C drivers whose devices are
>> either used in Device Tree source files or are listed in binding docs as
>> a compatible string.
>>
>> That's done because the plan is to change the I2C core to report proper OF
>> modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
>> a device was registered via DT or using the legacy platform data.
>>
> 
> Doesn't that break the DT ABI for all i2c devices? A lot of people are
> getting the vendor wrong in the compatible string and because the i2c
> core doesn't care, the driver is still probed. Dropping that will break
> all those DTBs.
> Or will that only affect module autoload?
> 

The change will only be for module autoload. The I2C core will still attempt
to match the I2C device ID table as a fallback if fails to match the OF one.
So there's no change in the match logic for drivers that do the wrong thing.

If someone is using a wrong vendor prefix and the DT can't be changed, then
an entry in the OF device ID table has to be added for "wrong_vendor,device"
so the MODALIAS uevent can be "of:N*T*wrong_vendor,device".

This is the RFC patch for the I2C core so you get a better idea:

https://patchwork.kernel.org/patch/6903981/

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

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

* Re: [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
  2017-03-03 15:27   ` Javier Martinez Canillas
@ 2017-03-03 16:04     ` Alexandre Belloni
  2017-03-03 17:08       ` Javier Martinez Canillas
  0 siblings, 1 reply; 19+ messages in thread
From: Alexandre Belloni @ 2017-03-03 16:04 UTC (permalink / raw)
  To: Javier Martinez Canillas; +Cc: linux-kernel, rtc-linux, Alessandro Zummo

On 03/03/2017 at 12:27:23 -0300, Javier Martinez Canillas wrote:
> On 03/03/2017 12:01 PM, Alexandre Belloni wrote:
> > On 03/03/2017 at 11:29:11 -0300, Javier Martinez Canillas wrote:
> >> This series add OF device ID tables to RTC I2C drivers whose devices are
> >> either used in Device Tree source files or are listed in binding docs as
> >> a compatible string.
> >>
> >> That's done because the plan is to change the I2C core to report proper OF
> >> modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
> >> a device was registered via DT or using the legacy platform data.
> >>
> > 
> > Doesn't that break the DT ABI for all i2c devices? A lot of people are
> > getting the vendor wrong in the compatible string and because the i2c
> > core doesn't care, the driver is still probed. Dropping that will break
> > all those DTBs.
> > Or will that only affect module autoload?
> > 
> 
> The change will only be for module autoload. The I2C core will still attempt
> to match the I2C device ID table as a fallback if fails to match the OF one.
> So there's no change in the match logic for drivers that do the wrong thing.
> 

I'm probably not seeing the big picture here but then I don't understand
why you are reworking the id->driver_data handling and using
of_device_get_match_data instead.

If this is related to b8a1a4cd5a98a2adf8dfd6902cd98e57d910ee12, that is
a completely different issue (and that is probably the kind of changes
that should be notified to maintainers).

> If someone is using a wrong vendor prefix and the DT can't be changed, then
> an entry in the OF device ID table has to be added for "wrong_vendor,device"
> so the MODALIAS uevent can be "of:N*T*wrong_vendor,device".
> 

And then, we end up with a crap load of useless strings that are matched
against at boottime...
I'm saying that because all the rv3029 compatible strings are wrong.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
  2017-03-03 16:04     ` Alexandre Belloni
@ 2017-03-03 17:08       ` Javier Martinez Canillas
  0 siblings, 0 replies; 19+ messages in thread
From: Javier Martinez Canillas @ 2017-03-03 17:08 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-kernel, rtc-linux, Alessandro Zummo

Hello Alexandre,

Sorry for the long email...

On 03/03/2017 01:04 PM, Alexandre Belloni wrote:
> On 03/03/2017 at 12:27:23 -0300, Javier Martinez Canillas wrote:
>> On 03/03/2017 12:01 PM, Alexandre Belloni wrote:
>>> On 03/03/2017 at 11:29:11 -0300, Javier Martinez Canillas wrote:
>>>> This series add OF device ID tables to RTC I2C drivers whose devices are
>>>> either used in Device Tree source files or are listed in binding docs as
>>>> a compatible string.
>>>>
>>>> That's done because the plan is to change the I2C core to report proper OF
>>>> modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
>>>> a device was registered via DT or using the legacy platform data.
>>>>
>>>
>>> Doesn't that break the DT ABI for all i2c devices? A lot of people are
>>> getting the vendor wrong in the compatible string and because the i2c
>>> core doesn't care, the driver is still probed. Dropping that will break
>>> all those DTBs.
>>> Or will that only affect module autoload?
>>>
>>
>> The change will only be for module autoload. The I2C core will still attempt
>> to match the I2C device ID table as a fallback if fails to match the OF one.
>> So there's no change in the match logic for drivers that do the wrong thing.
>>
> 
> I'm probably not seeing the big picture here but then I don't understand

The big picture is to make the I2C subsystem to be consistent with other
subsystems.

Take the platform bus as an example, platform drivers define an OF ID table
if the platform devices are going to be registered via DT and a platform ID
table if the driver supports legacy platform device registration.

But that's not the case for I2C, either only a I2C device ID table is defined
(and the vendor prefix not used which lead to the current situation of wrong
DT's) or a OF device ID table is used to match but still a I2C device table
with duplicated entries is needed only to make the driver module to autoload.

> why you are reworking the id->driver_data handling and using
> of_device_get_match_data instead.
>

I meant that the proposed change to the I2C core is only for module autoload.
The driver changes are for both match and autoload (once I2C core is fixed).

So the change to use the of_device_id .data instead of the i2c_device_id
.driver_data is to use the correct entry in case the I2C core matches using
the OF table instead of the I2C table. Another option is to do the opposite
of what's needed currently, that is to have an I2C table to match and only
use the OF table to populate the OF aliases in the module (i.e: not setting
the .of_match_table field).

But I think that if the device is registered via OF, then the correct thing
to do is to match using the OF table and the OF aliases for module autoload.
 
> If this is related to b8a1a4cd5a98a2adf8dfd6902cd98e57d910ee12, that is
> a completely different issue (and that is probably the kind of changes
> that should be notified to maintainers).
>

It's related in some way. There were two reasons why a I2C driver required a
I2C table:

1) Because their probe function received a struct i2c_device_id as argument.

2) Because the reported MODALIAS is always i2c:<foo> regardless of how the
   device was registered (legacy platform dev or DT).

Lee's commit that you mention solves (1) and I'm trying to solve (2).

>> If someone is using a wrong vendor prefix and the DT can't be changed, then
>> an entry in the OF device ID table has to be added for "wrong_vendor,device"
>> so the MODALIAS uevent can be "of:N*T*wrong_vendor,device".
>>
> 
> And then, we end up with a crap load of useless strings that are matched
> against at boottime...
> I'm saying that because all the rv3029 compatible strings are wrong.
> 

Yeah... that's the joy of the DT backward compatibility. The reason why added
those (wrong) compatibles for rv3029 is because there are mainline users that
are either not using a vendor or using a wrong one (mc instead of microchip).

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

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

* Re: [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it
  2017-03-03 14:29 [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Javier Martinez Canillas
                   ` (13 preceding siblings ...)
  2017-03-03 15:01 ` [PATCH 00/13] rtc: Add OF device table to I2C drivers that are missing it Alexandre Belloni
@ 2017-03-09  0:30 ` Alexandre Belloni
  14 siblings, 0 replies; 19+ messages in thread
From: Alexandre Belloni @ 2017-03-09  0:30 UTC (permalink / raw)
  To: Javier Martinez Canillas; +Cc: linux-kernel, rtc-linux, Alessandro Zummo

On 03/03/2017 at 11:29:11 -0300, Javier Martinez Canillas wrote:
> Hello,
> 
> This series add OF device ID tables to RTC I2C drivers whose devices are
> either used in Device Tree source files or are listed in binding docs as
> a compatible string.
> 
> That's done because the plan is to change the I2C core to report proper OF
> modaliases instead of always reporting a MODALIAS=i2c:<foo> regardless if
> a device was registered via DT or using the legacy platform data.
> 
> So these patches will make sure that RTC I2C drivers modules will continue
> to be autoloaded once the I2C core is changed to report proper OF modalias.
> 
> Best regards,
> Javier
> 
> 
> Javier Martinez Canillas (13):
>   rtc: rv8803: Add OF device ID table
>   rtc: rv3029: Add OF device ID table
>   rtc: bq32k: Add OF device ID table
>   rtc: ds1307: Add OF device ID table
>   rtc: rx8010: Add OF device ID table
>   rtc: ds3232: Add OF device ID table
>   rtc: rtc-ds1672: Add OF device ID table
>   rtc: ds1374: Set .of_match_table to OF device ID table
>   rtc: isl1208: Add OF device ID table
>   rtc: s35390a: Add OF device ID table
>   rtc: rx8581: Add OF device ID table
>   rtc: m41t80: Add OF device ID table
>   rtc: rs5c372: Add OF device ID table
> 

All applied, thanks!

>  drivers/rtc/rtc-bq32k.c    |  7 +++++
>  drivers/rtc/rtc-ds1307.c   | 68 +++++++++++++++++++++++++++++++++++++++++++++-
>  drivers/rtc/rtc-ds1374.c   |  1 +
>  drivers/rtc/rtc-ds1672.c   |  9 +++++-
>  drivers/rtc/rtc-ds3232.c   |  7 +++++
>  drivers/rtc/rtc-isl1208.c  | 12 ++++++--
>  drivers/rtc/rtc-m41t80.c   | 63 ++++++++++++++++++++++++++++++++++++++++--
>  drivers/rtc/rtc-rs5c372.c  | 37 ++++++++++++++++++++++++-
>  drivers/rtc/rtc-rv3029c2.c |  9 ++++++
>  drivers/rtc/rtc-rv8803.c   | 21 +++++++++++++-
>  drivers/rtc/rtc-rx8010.c   |  7 +++++
>  drivers/rtc/rtc-rx8581.c   |  7 +++++
>  drivers/rtc/rtc-s35390a.c  |  8 ++++++
>  13 files changed, 248 insertions(+), 8 deletions(-)
> 
> -- 
> 2.9.3
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

end of thread, other threads:[~2017-03-09  3:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 01/13] rtc: rv8803: Add OF device ID table Javier Martinez Canillas
2017-03-03 14:29 ` [PATCH 02/13] rtc: rv3029: " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).