mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shrirang Bagul <shrirang.bagul@canonical.com>
To: jic23@kernel.org
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	denis.ciocca@st.com, tiberiu.a.breana@intel.com,
	lorenzo.bianconi83@gmail.com, linus.walleij@linaro.org,
	gregor.boirie@parrot.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shrirang Bagul <shrirang.bagul@canonical.com>
Subject: [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle
Date: Thu, 24 Nov 2016 13:33:43 +0800	[thread overview]
Message-ID: <20161124053345.11254-2-shrirang.bagul@canonical.com> (raw)
In-Reply-To: <20161124053345.11254-1-shrirang.bagul@canonical.com>

Add support to match st sensors using information passed from ACPI DST
tables.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
---
 drivers/iio/common/st_sensors/st_sensors_i2c.c | 20 ++++++++++++++++++++
 include/linux/iio/common/st_sensors_i2c.h      |  9 +++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
index b43aa36..c83df4d 100644
--- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
+++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/iio/iio.h>
 #include <linux/of_device.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/common/st_sensors_i2c.h>
 
@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
 EXPORT_SYMBOL(st_sensors_of_i2c_probe);
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev)
+{
+	const struct acpi_device_id *acpi_id;
+	kernel_ulong_t driver_data = 0;
+
+	if (ACPI_HANDLE(dev)) {
+		acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
+		if (!acpi_id) {
+			dev_err(dev, "No driver data\n");
+			return -EINVAL;
+		}
+		driver_data = acpi_id->driver_data;
+	}
+	return driver_data;
+}
+EXPORT_SYMBOL(st_sensors_match_acpi_device);
+#endif
+
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
index 1796af0..254de3c 100644
--- a/include/linux/iio/common/st_sensors_i2c.h
+++ b/include/linux/iio/common/st_sensors_i2c.h
@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
 }
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev);
+#else
+static inline int st_sensors_match_acpi_device(struct device *dev)
+{
+	return -ENODEV;
+}
+#endif
+
 #endif /* ST_SENSORS_I2C_H */
-- 
2.9.3

  reply	other threads:[~2016-11-24  5:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24  5:33 [PATCH 0/3] iio: st_sensors: Support ACPI probe for st_sensors Shrirang Bagul
2016-11-24  5:33 ` Shrirang Bagul [this message]
2016-11-27 11:15   ` [PATCH 1/3] iio: st_sensors: match sensors using ACPI handle Jonathan Cameron
2016-11-24  5:33 ` [PATCH 2/3] iio: st_accel: Support sensor i2c probe using acpi Shrirang Bagul
2016-11-24 14:26   ` Linus Walleij
2016-11-27 11:14     ` Jonathan Cameron
2016-11-29  4:27       ` Shrirang Bagul
2016-11-24  5:33 ` [PATCH 3/3] iio: st_pressure: Support " Shrirang Bagul
2016-11-24 14:28   ` Linus Walleij
2016-11-27 11:12     ` Jonathan Cameron
2016-11-29  4:25       ` Shrirang Bagul
2016-11-30 13:04         ` Linus Walleij
2016-11-30 17:20         ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161124053345.11254-2-shrirang.bagul@canonical.com \
    --to=shrirang.bagul@canonical.com \
    --cc=denis.ciocca@st.com \
    --cc=gregor.boirie@parrot.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=tiberiu.a.breana@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®