diff mbox series

[2/2] iio: temperature: tmp006: Add OF device matching support

Message ID d0114a66fa3e9fb07a98dde3cc0bd87c526a3753.1684089997.git.anupnewsmail@gmail.com
State Accepted
Commit 12a875055c15279c4f2db14cb0b593d81d16fc0b
Headers show
Series Add dt-binding support for ti tmp006 | expand

Commit Message

Anup Sharma May 14, 2023, 7:03 p.m. UTC
Adds an of_device_id table entry to the driver, enabling
device matching through device tree. With this update, the driver
can now match devices using both the i2c_device_id entry and the
newly added of_device_id table.

Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
---
 drivers/iio/temperature/tmp006.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Krzysztof Kozlowski May 15, 2023, 6:18 a.m. UTC | #1
On 14/05/2023 21:03, Anup Sharma wrote:
> Adds an of_device_id table entry to the driver, enabling
> device matching through device tree. With this update, the driver
> can now match devices using both the i2c_device_id entry and the
> newly added of_device_id table.
> 
> Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> ---
>  drivers/iio/temperature/tmp006.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
> index cdf08477e63f..2b1782263cc9 100644
> --- a/drivers/iio/temperature/tmp006.c
> +++ b/drivers/iio/temperature/tmp006.c
> @@ -17,6 +17,7 @@
>  #include <linux/module.h>
>  #include <linux/pm.h>
>  #include <linux/bitops.h>
> +#include <linux/mod_devicetable.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -272,15 +273,22 @@ static int tmp006_resume(struct device *dev)
>  
>  static DEFINE_SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume);
>  
> +static const struct of_device_id tmp006_of_match[] = {
> +	{ .compatible = "ti,tmp006", },
> +	{ }
> +};
> +

Drop blank line.

> +MODULE_DEVICE_TABLE(of, tmp006_of_match);
> +
>  static const struct i2c_device_id tmp006_id[] = {
>  	{ "tmp006", 0 },
>  	{ }
>  };
> -MODULE_DEVICE_TABLE(i2c, tmp006_id);

This should stay.


Best regards,
Krzysztof
Andy Shevchenko May 15, 2023, 9:45 p.m. UTC | #2
On Mon, May 15, 2023 at 12:33:06AM +0530, Anup Sharma wrote:
> Adds an of_device_id table entry to the driver, enabling
> device matching through device tree. With this update, the driver
> can now match devices using both the i2c_device_id entry and the
> newly added of_device_id table.

...

>  #include <linux/module.h>
>  #include <linux/pm.h>
>  #include <linux/bitops.h>

> +#include <linux/mod_devicetable.h>

Can you try to keep this ordered as much as possible? (For example, by locating
a new inclusion near to module.h)

...

> +static const struct of_device_id tmp006_of_match[] = {
> +	{ .compatible = "ti,tmp006", },

Inner comma is not needed.

> +	{ }
> +};
diff mbox series

Patch

diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index cdf08477e63f..2b1782263cc9 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -17,6 +17,7 @@ 
 #include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/bitops.h>
+#include <linux/mod_devicetable.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -272,15 +273,22 @@  static int tmp006_resume(struct device *dev)
 
 static DEFINE_SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume);
 
+static const struct of_device_id tmp006_of_match[] = {
+	{ .compatible = "ti,tmp006", },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, tmp006_of_match);
+
 static const struct i2c_device_id tmp006_id[] = {
 	{ "tmp006", 0 },
 	{ }
 };
-MODULE_DEVICE_TABLE(i2c, tmp006_id);
 
 static struct i2c_driver tmp006_driver = {
 	.driver = {
 		.name	= "tmp006",
+		.of_match_table = tmp006_of_match,
 		.pm	= pm_sleep_ptr(&tmp006_pm_ops),
 	},
 	.probe_new = tmp006_probe,