[PATCH 29/43] rtc: m48t86: add DT support for m48t86

Nikita Shubin posted 43 patches 2 years, 9 months ago
There is a newer version of this series
[PATCH 29/43] rtc: m48t86: add DT support for m48t86
Posted by Nikita Shubin 2 years, 9 months ago
- get regs from device tree

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
 drivers/rtc/rtc-m48t86.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index 481c9525b1dd..d65727ac283a 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/bcd.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #define M48T86_SEC		0x00
 #define M48T86_SECALRM		0x01
@@ -269,9 +270,18 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id m48t86_rtc_of_ids[] = {
+	{ .compatible = "dallas,rtc-m48t86" },
+	{ /* end of table */ },
+};
+MODULE_DEVICE_TABLE(of, m48t86_rtc_of_ids);
+#endif
+
 static struct platform_driver m48t86_rtc_platform_driver = {
 	.driver		= {
 		.name	= "rtc-m48t86",
+		.of_match_table = of_match_ptr(m48t86_rtc_of_ids),
 	},
 	.probe		= m48t86_rtc_probe,
 };
-- 
2.39.2
Re: [PATCH 29/43] rtc: m48t86: add DT support for m48t86
Posted by Arnd Bergmann 2 years, 9 months ago
On Mon, Apr 24, 2023, at 14:34, Nikita Shubin wrote:
> - get regs from device tree
>
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>

Acked-by: Arnd Bergmann <arnd@arndb.de>

> 
> +#ifdef CONFIG_OF
> +static const struct of_device_id m48t86_rtc_of_ids[] = {
> +	{ .compatible = "dallas,rtc-m48t86" },
> +	{ /* end of table */ },
> +};
> +MODULE_DEVICE_TABLE(of, m48t86_rtc_of_ids);
> +#endif
> +
>  static struct platform_driver m48t86_rtc_platform_driver = {
>  	.driver		= {
>  		.name	= "rtc-m48t86",
> +		.of_match_table = of_match_ptr(m48t86_rtc_of_ids),
>  	},
>  	.probe		= m48t86_rtc_probe,

If you end up doing another revision, I'd suggest you drop the
of_match_ptr() and the #ifdef: there is no point in saving a
few bytes of space for non-DT kernel builds if both the machines
that use this device always rquire CONFIG_OF to be enabled.

     Arnd