All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	lorenzo.bianconi-qxv4g6HH51o@public.gmane.org,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: [PATCH v3 4/4] iio: pressure: st_pressure_spi: add OF capability to st_pressure_spi
Date: Tue, 27 Jun 2017 00:53:46 +0200	[thread overview]
Message-ID: <20170626225346.12019-5-lorenzo.bianconi@st.com> (raw)
In-Reply-To: <20170626225346.12019-1-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>

Add device tree support for LPS22HB, LPS25H, LPS331AP, LPS001WP
pressure sensors

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 drivers/iio/pressure/st_pressure_spi.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index 550508025af1..f5ebd36bb4bf 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -18,6 +18,36 @@
 #include <linux/iio/common/st_sensors_spi.h>
 #include "st_pressure.h"
 
+#ifdef CONFIG_OF
+/*
+ * For new single-chip sensors use <device_name> as compatible string.
+ * For old single-chip devices keep <device_name>-press to maintain
+ * compatibility
+ */
+static const struct of_device_id st_press_of_match[] = {
+	{
+		.compatible = "st,lps001wp-press",
+		.data = LPS001WP_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps25h-press",
+		.data = LPS25H_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps331ap-press",
+		.data = LPS331AP_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps22hb-press",
+		.data = LPS22HB_PRESS_DEV_NAME,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, st_press_of_match);
+#else
+#define st_press_of_match	NULL
+#endif
+
 static int st_press_spi_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
@@ -30,6 +60,8 @@ static int st_press_spi_probe(struct spi_device *spi)
 
 	press_data = iio_priv(indio_dev);
 
+	st_sensors_of_name_probe(&spi->dev, st_press_of_match,
+				 spi->modalias, sizeof(spi->modalias));
 	st_sensors_spi_configure(indio_dev, spi, press_data);
 
 	err = st_press_common_probe(indio_dev);
@@ -58,6 +90,7 @@ MODULE_DEVICE_TABLE(spi, st_press_id_table);
 static struct spi_driver st_press_driver = {
 	.driver = {
 		.name = "st-press-spi",
+		.of_match_table = of_match_ptr(st_press_of_match),
 	},
 	.probe = st_press_spi_probe,
 	.remove = st_press_spi_remove,
-- 
2.13.1

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
To: jic23@kernel.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	lorenzo.bianconi@st.com, linus.walleij@linaro.org
Subject: [PATCH v3 4/4] iio: pressure: st_pressure_spi: add OF capability to st_pressure_spi
Date: Tue, 27 Jun 2017 00:53:46 +0200	[thread overview]
Message-ID: <20170626225346.12019-5-lorenzo.bianconi@st.com> (raw)
In-Reply-To: <20170626225346.12019-1-lorenzo.bianconi@st.com>

Add device tree support for LPS22HB, LPS25H, LPS331AP, LPS001WP
pressure sensors

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/pressure/st_pressure_spi.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index 550508025af1..f5ebd36bb4bf 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -18,6 +18,36 @@
 #include <linux/iio/common/st_sensors_spi.h>
 #include "st_pressure.h"
 
+#ifdef CONFIG_OF
+/*
+ * For new single-chip sensors use <device_name> as compatible string.
+ * For old single-chip devices keep <device_name>-press to maintain
+ * compatibility
+ */
+static const struct of_device_id st_press_of_match[] = {
+	{
+		.compatible = "st,lps001wp-press",
+		.data = LPS001WP_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps25h-press",
+		.data = LPS25H_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps331ap-press",
+		.data = LPS331AP_PRESS_DEV_NAME,
+	},
+	{
+		.compatible = "st,lps22hb-press",
+		.data = LPS22HB_PRESS_DEV_NAME,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, st_press_of_match);
+#else
+#define st_press_of_match	NULL
+#endif
+
 static int st_press_spi_probe(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev;
@@ -30,6 +60,8 @@ static int st_press_spi_probe(struct spi_device *spi)
 
 	press_data = iio_priv(indio_dev);
 
+	st_sensors_of_name_probe(&spi->dev, st_press_of_match,
+				 spi->modalias, sizeof(spi->modalias));
 	st_sensors_spi_configure(indio_dev, spi, press_data);
 
 	err = st_press_common_probe(indio_dev);
@@ -58,6 +90,7 @@ MODULE_DEVICE_TABLE(spi, st_press_id_table);
 static struct spi_driver st_press_driver = {
 	.driver = {
 		.name = "st-press-spi",
+		.of_match_table = of_match_ptr(st_press_of_match),
 	},
 	.probe = st_press_spi_probe,
 	.remove = st_press_spi_remove,
-- 
2.13.1

  parent reply	other threads:[~2017-06-26 22:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 22:53 [PATCH v3 0/4] Add OF support to ST sensor framework Lorenzo Bianconi
2017-06-26 22:53 ` Lorenzo Bianconi
     [not found] ` <20170626225346.12019-1-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-26 22:53   ` [PATCH v3 1/4] iio: accel: st_accel_spi: add OF capability to st_accel_spi Lorenzo Bianconi
2017-06-26 22:53     ` Lorenzo Bianconi
     [not found]     ` <20170626225346.12019-2-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-29 12:48       ` Linus Walleij
2017-06-29 12:48         ` Linus Walleij
     [not found]         ` <CACRpkdbF3iVLSr3kBNGmoZjoPX=1KOO74OS3wmTSxFrzqwak3A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-01 12:13           ` Jonathan Cameron
2017-07-01 12:13             ` Jonathan Cameron
2017-06-26 22:53   ` [PATCH v3 2/4] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi Lorenzo Bianconi
2017-06-26 22:53     ` Lorenzo Bianconi
     [not found]     ` <20170626225346.12019-3-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-29 12:49       ` Linus Walleij
2017-06-29 12:49         ` Linus Walleij
     [not found]         ` <CACRpkdZ=5VbnMLVG6=AjaZoD2eO25jVDcz6R9Xy-q3h1-49-Vw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-01 12:14           ` Jonathan Cameron
2017-07-01 12:14             ` Jonathan Cameron
2017-06-26 22:53   ` [PATCH v3 3/4] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi Lorenzo Bianconi
2017-06-26 22:53     ` Lorenzo Bianconi
     [not found]     ` <20170626225346.12019-4-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-29 12:50       ` Linus Walleij
2017-06-29 12:50         ` Linus Walleij
2017-06-26 22:53   ` Lorenzo Bianconi [this message]
2017-06-26 22:53     ` [PATCH v3 4/4] iio: pressure: st_pressure_spi: add OF capability to st_pressure_spi Lorenzo Bianconi
     [not found]     ` <20170626225346.12019-5-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-06-29 12:51       ` Linus Walleij
2017-06-29 12:51         ` Linus Walleij
     [not found]         ` <CACRpkdaEVNz+0rrq1B9PkNFxoyAMvpeiTiv3qUyT_F-ct0PLiA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-01 12:15           ` Jonathan Cameron
2017-07-01 12:15             ` 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=20170626225346.12019-5-lorenzo.bianconi@st.com \
    --to=lorenzo.bianconi83-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lorenzo.bianconi-qxv4g6HH51o@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.