From e4548a8a5ad34919a94b282369212b661e1d4382 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megous@megous.com>
Date: Fri, 10 Nov 2017 13:23:01 +0100
Subject: [PATCH 41/82] iio: ltr501: Add OF compatibles

So that driver can be configured from DTS.

Signed-off-by: Ondrej Jirman <megous@megous.com>
---
 drivers/iio/light/ltr501.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 830a2d45aa4d..bdb296dcb7c0 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/regmap.h>
 #include <linux/acpi.h>
+#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/events.h>
@@ -1558,6 +1559,7 @@ static int ltr501_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
 
+#ifdef CONFIG_ACPI
 static const struct acpi_device_id ltr_acpi_match[] = {
 	{"LTER0501", ltr501},
 	{"LTER0559", ltr559},
@@ -1565,6 +1567,7 @@ static const struct acpi_device_id ltr_acpi_match[] = {
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, ltr_acpi_match);
+#endif
 
 static const struct i2c_device_id ltr501_id[] = {
 	{ "ltr501", ltr501},
@@ -1574,11 +1577,22 @@ static const struct i2c_device_id ltr501_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ltr501_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id ltr501_of_match[] = {
+	{ .compatible = "ltr,ltr501", .data = (void*)ltr501 },
+	{ .compatible = "ltr,ltr559", .data = (void*)ltr559 },
+	{ .compatible = "ltr,ltr301", .data = (void*)ltr301 },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ltr501_of_match);
+#endif
+
 static struct i2c_driver ltr501_driver = {
 	.driver = {
-		.name   = LTR501_DRV_NAME,
-		.pm	= &ltr501_pm_ops,
+		.name = LTR501_DRV_NAME,
+		.pm = &ltr501_pm_ops,
 		.acpi_match_table = ACPI_PTR(ltr_acpi_match),
+		.of_match_table = of_match_ptr(ltr501_of_match)
 	},
 	.probe  = ltr501_probe,
 	.remove	= ltr501_remove,
-- 
2.20.1

