Skip to contentSkip to conversation

rtc: rtc-ds3232: add device tree support

PATCH In review Peter Robinson 2 participants 4 messages Nov 28, 2016 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: rtc-ds3232: add device tree support

Set the of_match_table for this driver so that devices can be described in the device tree. This device is used in a number of NXP devices as well as the CryptoCap and is already defined in the various device trees.

---
 drivers/rtc/rtc-ds3232.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rtc/rtc-ds3232.c +10 -0
index b1f20d8..711cc5b 100644
@@ -15,6 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
@@ -438,9 +439,18 @@ static const struct i2c_device_id ds3232_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds3232_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ds3232_of_match[] = {
+	{ .compatible = "dallas,ds3232", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ds3232_of_match);
+#endif
+
 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,
Signature · 11 lines
2.9.3

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

Hi,

Quoted 4 lines · Peter Robinson

Set the of_match_table for this driver so that devices can be described in the device tree. This device is used in a number of NXP devices as well as the CryptoCap and is already defined in the various device trees.

This is useless (as you mention it is already used in various device trees) as it will already be probed properly using the "dallas,ds3232" compatible string.

Quoted 39 lines
---
 drivers/rtc/rtc-ds3232.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rtc/rtc-ds3232.c +10 -0
index b1f20d8..711cc5b 100644
@@ -15,6 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
@@ -438,9 +439,18 @@ static const struct i2c_device_id ds3232_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds3232_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ds3232_of_match[] = {
+	{ .compatible = "dallas,ds3232", },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ds3232_of_match);
+#endif
+
 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,
Signature · 1 line
2.9.3
Signature · 13 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#2 lore raw
Quoted 11 lines · Alexandre Belloni

Hi,

Quoted 4 lines · Peter Robinson

Set the of_match_table for this driver so that devices can be described in the device tree. This device is used in a number of NXP devices as well as the CryptoCap and is already defined in the various device trees.

This is useless (as you mention it is already used in various device trees) as it will already be probed properly using the "dallas,ds3232" compatible string.

Why? The driver doesn't currently set the compatible string.

Quoted 44 lines
Quoted 37 lines
---
 drivers/rtc/rtc-ds3232.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rtc/rtc-ds3232.c +10 -1
index b1f20d8..711cc5b 100644
@@ -15,6 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
@@ -438,9 +439,18 @@ static const struct i2c_device_id ds3232_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds3232_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ds3232_of_match[] = {
+     { .compatible = "dallas,ds3232", },
+     { }
+};
+MODULE_DEVICE_TABLE(of, ds3232_of_match);
+#endif
+
 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,
--
Quoted 2 lines

2.9.3

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

Signature · 8 lines
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#3 lore raw
Quoted 10 lines · Peter Robinson
Quoted 8 lines · Alexandre Belloni

Hi,

Quoted 4 lines · Peter Robinson

Set the of_match_table for this driver so that devices can be described in the device tree. This device is used in a number of NXP devices as well as the CryptoCap and is already defined in the various device trees.

Quoted 6 lines
Quoted 3 lines

This is useless (as you mention it is already used in various device trees) as it will already be probed properly using the "dallas,ds3232" compatible string.

Why? The driver doesn't currently set the compatible string.

The i2c core does that for you using the i2c_device_id array.

Quoted 44 lines
Quoted 44 lines
Quoted 37 lines
---
 drivers/rtc/rtc-ds3232.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rtc/rtc-ds3232.c +10 -1
index b1f20d8..711cc5b 100644
@@ -15,6 +15,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
@@ -438,9 +439,18 @@ static const struct i2c_device_id ds3232_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ds3232_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ds3232_of_match[] = {
+     { .compatible = "dallas,ds3232", },
+     { }
+};
+MODULE_DEVICE_TABLE(of, ds3232_of_match);
+#endif
+
 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,
--
Quoted 2 lines

2.9.3

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

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

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.