* [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices
@ 2017-06-20 19:52 Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code Lorenzo Bianconi
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
Lorenzo Bianconi (5):
iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code
iio: accel: st_accel_spi: rename of_device_id table in
st_accel_of_match
iio: accel: st_accel_spi: add OF capability to st_accel_spi
iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi
iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
drivers/iio/accel/st_accel_i2c.c | 3 ++-
drivers/iio/accel/st_accel_spi.c | 28 +++++++++++++++-------
drivers/iio/common/st_sensors/st_sensors_core.c | 31 +++++++++++++++++++++++++
drivers/iio/common/st_sensors/st_sensors_i2c.c | 29 -----------------------
drivers/iio/gyro/st_gyro_i2c.c | 3 ++-
drivers/iio/gyro/st_gyro_spi.c | 16 +++++++++++++
drivers/iio/magnetometer/st_magn_i2c.c | 3 ++-
drivers/iio/magnetometer/st_magn_spi.c | 16 +++++++++++++
drivers/iio/pressure/st_pressure_i2c.c | 3 ++-
include/linux/iio/common/st_sensors.h | 12 ++++++++++
include/linux/iio/common/st_sensors_i2c.h | 10 --------
11 files changed, 102 insertions(+), 52 deletions(-)
--
2.13.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
@ 2017-06-20 19:52 ` Lorenzo Bianconi
2017-06-21 19:54 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match Lorenzo Bianconi
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
Move st_sensors_of_i2c_probe() in st_sensors_core and rename it in
st_sensors_of_name_probe(). That change is necessary to add device-tree
support in spi code otherwise the rest of the autodetection will fail
since spi->modalias (and indio_dev->name) will be set using compatible
string value that differs from standard sensor name
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
drivers/iio/accel/st_accel_i2c.c | 3 ++-
drivers/iio/common/st_sensors/st_sensors_core.c | 31 +++++++++++++++++++++++++
drivers/iio/common/st_sensors/st_sensors_i2c.c | 29 -----------------------
drivers/iio/gyro/st_gyro_i2c.c | 3 ++-
drivers/iio/magnetometer/st_magn_i2c.c | 3 ++-
drivers/iio/pressure/st_pressure_i2c.c | 3 ++-
include/linux/iio/common/st_sensors.h | 12 ++++++++++
include/linux/iio/common/st_sensors_i2c.h | 10 --------
8 files changed, 51 insertions(+), 43 deletions(-)
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index 543f0ad7fd7e..ac67826135be 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -144,7 +144,8 @@ static int st_accel_i2c_probe(struct i2c_client *client,
adata = iio_priv(indio_dev);
if (client->dev.of_node) {
- st_sensors_of_i2c_probe(client, st_accel_of_match);
+ st_sensors_of_name_probe(&client->dev, st_accel_of_match,
+ client->name, sizeof(client->name));
} else if (ACPI_HANDLE(&client->dev)) {
ret = st_sensors_match_acpi_device(&client->dev);
if ((ret < 0) || (ret >= ST_ACCEL_MAX))
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 79c8c7cd70d5..274868100fd0 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -15,6 +15,7 @@
#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <asm/unaligned.h>
#include <linux/iio/common/st_sensors.h>
@@ -345,6 +346,36 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
return pdata;
}
+
+/**
+ * st_sensors_of_name_probe() - device tree probe for ST sensor name
+ * @dev: driver model representation of the device.
+ * @match: the OF match table for the device, containing compatible strings
+ * but also a .data field with the corresponding internal kernel name
+ * used by this sensor.
+ * @name: device name buffer reference.
+ * @len: device name buffer length.
+ *
+ * In effect this function matches a compatible string to an internal kernel
+ * name for a certain sensor device, so that the rest of the autodetection can
+ * rely on that name from this point on. I2C/SPI devices will be renamed
+ * to match the internal kernel convention.
+ */
+void st_sensors_of_name_probe(struct device *dev,
+ const struct of_device_id *match,
+ char *name, int len)
+{
+ const struct of_device_id *of_id;
+
+ of_id = of_match_device(match, dev);
+ if (!of_id || !of_id->data)
+ return;
+
+ /* The name from the OF match takes precedence if present */
+ strncpy(name, of_id->data, len);
+ name[len - 1] = '\0';
+}
+EXPORT_SYMBOL(st_sensors_of_name_probe);
#else
static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
struct st_sensors_platform_data *defdata)
diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
index c83df4dbfcd7..b81e48e9f27e 100644
--- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
+++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
@@ -79,35 +79,6 @@ void st_sensors_i2c_configure(struct iio_dev *indio_dev,
}
EXPORT_SYMBOL(st_sensors_i2c_configure);
-#ifdef CONFIG_OF
-/**
- * st_sensors_of_i2c_probe() - device tree probe for ST I2C sensors
- * @client: the I2C client device for the sensor
- * @match: the OF match table for the device, containing compatible strings
- * but also a .data field with the corresponding internal kernel name
- * used by this sensor.
- *
- * In effect this function matches a compatible string to an internal kernel
- * name for a certain sensor device, so that the rest of the autodetection can
- * rely on that name from this point on. I2C client devices will be renamed
- * to match the internal kernel convention.
- */
-void st_sensors_of_i2c_probe(struct i2c_client *client,
- const struct of_device_id *match)
-{
- const struct of_device_id *of_id;
-
- of_id = of_match_device(match, &client->dev);
- if (!of_id)
- return;
-
- /* The name from the OF match takes precedence if present */
- strncpy(client->name, of_id->data, sizeof(client->name));
- client->name[sizeof(client->name) - 1] = '\0';
-}
-EXPORT_SYMBOL(st_sensors_of_i2c_probe);
-#endif
-
#ifdef CONFIG_ACPI
int st_sensors_match_acpi_device(struct device *dev)
{
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
index 3f628746cb93..b405b82b9177 100644
--- a/drivers/iio/gyro/st_gyro_i2c.c
+++ b/drivers/iio/gyro/st_gyro_i2c.c
@@ -75,7 +75,8 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
return -ENOMEM;
gdata = iio_priv(indio_dev);
- st_sensors_of_i2c_probe(client, st_gyro_of_match);
+ st_sensors_of_name_probe(&client->dev, st_gyro_of_match,
+ client->name, sizeof(client->name));
st_sensors_i2c_configure(indio_dev, client, gdata);
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 8aa37af306ed..6a6c8121ac2c 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -59,7 +59,8 @@ static int st_magn_i2c_probe(struct i2c_client *client,
return -ENOMEM;
mdata = iio_priv(indio_dev);
- st_sensors_of_i2c_probe(client, st_magn_of_match);
+ st_sensors_of_name_probe(&client->dev, st_magn_of_match,
+ client->name, sizeof(client->name));
st_sensors_i2c_configure(indio_dev, client, mdata);
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 17417a4d5a5f..7f15e927fa2b 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -77,7 +77,8 @@ static int st_press_i2c_probe(struct i2c_client *client,
press_data = iio_priv(indio_dev);
if (client->dev.of_node) {
- st_sensors_of_i2c_probe(client, st_press_of_match);
+ st_sensors_of_name_probe(&client->dev, st_press_of_match,
+ client->name, sizeof(client->name));
} else if (ACPI_HANDLE(&client->dev)) {
ret = st_sensors_match_acpi_device(&client->dev);
if ((ret < 0) || (ret >= ST_PRESS_MAX))
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 497f2b3a5a62..1f8211b6438b 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -325,4 +325,16 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
struct device_attribute *attr, char *buf);
+#ifdef CONFIG_OF
+void st_sensors_of_name_probe(struct device *dev,
+ const struct of_device_id *match,
+ char *name, int len);
+#else
+static inline void st_sensors_of_name_probe(struct device *dev,
+ const struct of_device_id *match,
+ char *name, int len)
+{
+}
+#endif
+
#endif /* ST_SENSORS_H */
diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
index 254de3c7dde8..0a2c25e06d1f 100644
--- a/include/linux/iio/common/st_sensors_i2c.h
+++ b/include/linux/iio/common/st_sensors_i2c.h
@@ -18,16 +18,6 @@
void st_sensors_i2c_configure(struct iio_dev *indio_dev,
struct i2c_client *client, struct st_sensor_data *sdata);
-#ifdef CONFIG_OF
-void st_sensors_of_i2c_probe(struct i2c_client *client,
- const struct of_device_id *match);
-#else
-static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
- const struct of_device_id *match)
-{
-}
-#endif
-
#ifdef CONFIG_ACPI
int st_sensors_match_acpi_device(struct device *dev);
#else
--
2.13.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code Lorenzo Bianconi
@ 2017-06-20 19:52 ` Lorenzo Bianconi
2017-06-21 19:56 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi Lorenzo Bianconi
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
In order to add proper device tree support give a more general name
to of_device_id table
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
drivers/iio/accel/st_accel_spi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 1a867f5563a4..d13742edee0e 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -62,17 +62,17 @@ static const struct spi_device_id st_accel_id_table[] = {
MODULE_DEVICE_TABLE(spi, st_accel_id_table);
#ifdef CONFIG_OF
-static const struct of_device_id lis302dl_spi_dt_ids[] = {
+static const struct of_device_id st_accel_of_match[] = {
{ .compatible = "st,lis302dl-spi" },
{}
};
-MODULE_DEVICE_TABLE(of, lis302dl_spi_dt_ids);
+MODULE_DEVICE_TABLE(of, st_accel_of_match);
#endif
static struct spi_driver st_accel_driver = {
.driver = {
.name = "st-accel-spi",
- .of_match_table = of_match_ptr(lis302dl_spi_dt_ids),
+ .of_match_table = of_match_ptr(st_accel_of_match),
},
.probe = st_accel_spi_probe,
.remove = st_accel_spi_remove,
--
2.13.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match Lorenzo Bianconi
@ 2017-06-20 19:52 ` Lorenzo Bianconi
2017-06-21 19:58 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi Lorenzo Bianconi
4 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
Add device tree support for LIS3DH accel sensor.
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
drivers/iio/accel/st_accel_spi.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index d13742edee0e..b7252a8ab494 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -18,6 +18,22 @@
#include <linux/iio/common/st_sensors_spi.h>
#include "st_accel.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_accel_of_match[] = {
+ {
+ .compatible = "st,lis302dl-spi"
+ },
+ {
+ .compatible = "st,lis3dh-accel",
+ .data = LIS3DH_ACCEL_DEV_NAME,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, st_accel_of_match);
+#else
+#define st_accel_of_match NULL
+#endif
+
static int st_accel_spi_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -30,6 +46,8 @@ static int st_accel_spi_probe(struct spi_device *spi)
adata = iio_priv(indio_dev);
+ st_sensors_of_name_probe(&spi->dev, st_accel_of_match,
+ spi->modalias, sizeof(spi->modalias));
st_sensors_spi_configure(indio_dev, spi, adata);
err = st_accel_common_probe(indio_dev);
@@ -61,14 +79,6 @@ static const struct spi_device_id st_accel_id_table[] = {
};
MODULE_DEVICE_TABLE(spi, st_accel_id_table);
-#ifdef CONFIG_OF
-static const struct of_device_id st_accel_of_match[] = {
- { .compatible = "st,lis302dl-spi" },
- {}
-};
-MODULE_DEVICE_TABLE(of, st_accel_of_match);
-#endif
-
static struct spi_driver st_accel_driver = {
.driver = {
.name = "st-accel-spi",
--
2.13.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
` (2 preceding siblings ...)
2017-06-20 19:52 ` [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi Lorenzo Bianconi
@ 2017-06-20 19:52 ` Lorenzo Bianconi
2017-06-24 20:39 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi Lorenzo Bianconi
4 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
Add device tree support for LIS3MDL magnetometer sensor
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
drivers/iio/magnetometer/st_magn_spi.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
index f3cb4dc05391..4847375f2c0d 100644
--- a/drivers/iio/magnetometer/st_magn_spi.c
+++ b/drivers/iio/magnetometer/st_magn_spi.c
@@ -18,6 +18,19 @@
#include <linux/iio/common/st_sensors_spi.h>
#include "st_magn.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_magn_of_match[] = {
+ {
+ .compatible = "st,lis3mdl-magn",
+ .data = LIS3MDL_MAGN_DEV_NAME,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, st_magn_of_match);
+#else
+#define st_magn_of_match NULL
+#endif
+
static int st_magn_spi_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -30,6 +43,8 @@ static int st_magn_spi_probe(struct spi_device *spi)
mdata = iio_priv(indio_dev);
+ st_sensors_of_name_probe(&spi->dev, st_magn_of_match,
+ spi->modalias, sizeof(spi->modalias));
st_sensors_spi_configure(indio_dev, spi, mdata);
err = st_magn_common_probe(indio_dev);
@@ -57,6 +72,7 @@ MODULE_DEVICE_TABLE(spi, st_magn_id_table);
static struct spi_driver st_magn_driver = {
.driver = {
.name = "st-magn-spi",
+ .of_match_table = of_match_ptr(st_magn_of_match),
},
.probe = st_magn_spi_probe,
.remove = st_magn_spi_remove,
--
2.13.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
` (3 preceding siblings ...)
2017-06-20 19:52 ` [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi Lorenzo Bianconi
@ 2017-06-20 19:52 ` Lorenzo Bianconi
2017-06-24 20:41 ` Jonathan Cameron
4 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-20 19:52 UTC (permalink / raw)
To: jic23; +Cc: linux-iio
Add device tree support for L3GD20H gyroscope sensor
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
index fa14d8f2170d..e49dd2c923ab 100644
--- a/drivers/iio/gyro/st_gyro_spi.c
+++ b/drivers/iio/gyro/st_gyro_spi.c
@@ -18,6 +18,19 @@
#include <linux/iio/common/st_sensors_spi.h>
#include "st_gyro.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_gyro_of_match[] = {
+ {
+ .compatible = "st,l3gd20h-gyro",
+ .data = L3GD20H_GYRO_DEV_NAME,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, st_gyro_of_match);
+#else
+#define st_gyro_of_match NULL
+#endif
+
static int st_gyro_spi_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
gdata = iio_priv(indio_dev);
+ st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
+ spi->modalias, sizeof(spi->modalias));
st_sensors_spi_configure(indio_dev, spi, gdata);
err = st_gyro_common_probe(indio_dev);
@@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
static struct spi_driver st_gyro_driver = {
.driver = {
.name = "st-gyro-spi",
+ .of_match_table = of_match_ptr(st_gyro_of_match),
},
.probe = st_gyro_spi_probe,
.remove = st_gyro_spi_remove,
--
2.13.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code
2017-06-20 19:52 ` [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code Lorenzo Bianconi
@ 2017-06-21 19:54 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-21 19:54 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Tue, 20 Jun 2017 21:52:08 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> Move st_sensors_of_i2c_probe() in st_sensors_core and rename it in
> st_sensors_of_name_probe(). That change is necessary to add device-tree
> support in spi code otherwise the rest of the autodetection will fail
> since spi->modalias (and indio_dev->name) will be set using compatible
> string value that differs from standard sensor name
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Sensible bit of refactoring and future proofing. Hence I've taken
this now. Applied to the togreg branch of iio.git - pushed out
as testing for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/accel/st_accel_i2c.c | 3 ++-
> drivers/iio/common/st_sensors/st_sensors_core.c | 31 +++++++++++++++++++++++++
> drivers/iio/common/st_sensors/st_sensors_i2c.c | 29 -----------------------
> drivers/iio/gyro/st_gyro_i2c.c | 3 ++-
> drivers/iio/magnetometer/st_magn_i2c.c | 3 ++-
> drivers/iio/pressure/st_pressure_i2c.c | 3 ++-
> include/linux/iio/common/st_sensors.h | 12 ++++++++++
> include/linux/iio/common/st_sensors_i2c.h | 10 --------
> 8 files changed, 51 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
> index 543f0ad7fd7e..ac67826135be 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -144,7 +144,8 @@ static int st_accel_i2c_probe(struct i2c_client *client,
> adata = iio_priv(indio_dev);
>
> if (client->dev.of_node) {
> - st_sensors_of_i2c_probe(client, st_accel_of_match);
> + st_sensors_of_name_probe(&client->dev, st_accel_of_match,
> + client->name, sizeof(client->name));
> } else if (ACPI_HANDLE(&client->dev)) {
> ret = st_sensors_match_acpi_device(&client->dev);
> if ((ret < 0) || (ret >= ST_ACCEL_MAX))
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 79c8c7cd70d5..274868100fd0 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -15,6 +15,7 @@
> #include <linux/iio/iio.h>
> #include <linux/regulator/consumer.h>
> #include <linux/of.h>
> +#include <linux/of_device.h>
> #include <asm/unaligned.h>
> #include <linux/iio/common/st_sensors.h>
>
> @@ -345,6 +346,36 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
>
> return pdata;
> }
> +
> +/**
> + * st_sensors_of_name_probe() - device tree probe for ST sensor name
> + * @dev: driver model representation of the device.
> + * @match: the OF match table for the device, containing compatible strings
> + * but also a .data field with the corresponding internal kernel name
> + * used by this sensor.
> + * @name: device name buffer reference.
> + * @len: device name buffer length.
> + *
> + * In effect this function matches a compatible string to an internal kernel
> + * name for a certain sensor device, so that the rest of the autodetection can
> + * rely on that name from this point on. I2C/SPI devices will be renamed
> + * to match the internal kernel convention.
> + */
> +void st_sensors_of_name_probe(struct device *dev,
> + const struct of_device_id *match,
> + char *name, int len)
> +{
> + const struct of_device_id *of_id;
> +
> + of_id = of_match_device(match, dev);
> + if (!of_id || !of_id->data)
> + return;
> +
> + /* The name from the OF match takes precedence if present */
> + strncpy(name, of_id->data, len);
> + name[len - 1] = '\0';
> +}
> +EXPORT_SYMBOL(st_sensors_of_name_probe);
> #else
> static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
> struct st_sensors_platform_data *defdata)
> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> index c83df4dbfcd7..b81e48e9f27e 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> @@ -79,35 +79,6 @@ void st_sensors_i2c_configure(struct iio_dev *indio_dev,
> }
> EXPORT_SYMBOL(st_sensors_i2c_configure);
>
> -#ifdef CONFIG_OF
> -/**
> - * st_sensors_of_i2c_probe() - device tree probe for ST I2C sensors
> - * @client: the I2C client device for the sensor
> - * @match: the OF match table for the device, containing compatible strings
> - * but also a .data field with the corresponding internal kernel name
> - * used by this sensor.
> - *
> - * In effect this function matches a compatible string to an internal kernel
> - * name for a certain sensor device, so that the rest of the autodetection can
> - * rely on that name from this point on. I2C client devices will be renamed
> - * to match the internal kernel convention.
> - */
> -void st_sensors_of_i2c_probe(struct i2c_client *client,
> - const struct of_device_id *match)
> -{
> - const struct of_device_id *of_id;
> -
> - of_id = of_match_device(match, &client->dev);
> - if (!of_id)
> - return;
> -
> - /* The name from the OF match takes precedence if present */
> - strncpy(client->name, of_id->data, sizeof(client->name));
> - client->name[sizeof(client->name) - 1] = '\0';
> -}
> -EXPORT_SYMBOL(st_sensors_of_i2c_probe);
> -#endif
> -
> #ifdef CONFIG_ACPI
> int st_sensors_match_acpi_device(struct device *dev)
> {
> diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
> index 3f628746cb93..b405b82b9177 100644
> --- a/drivers/iio/gyro/st_gyro_i2c.c
> +++ b/drivers/iio/gyro/st_gyro_i2c.c
> @@ -75,7 +75,8 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
> return -ENOMEM;
>
> gdata = iio_priv(indio_dev);
> - st_sensors_of_i2c_probe(client, st_gyro_of_match);
> + st_sensors_of_name_probe(&client->dev, st_gyro_of_match,
> + client->name, sizeof(client->name));
>
> st_sensors_i2c_configure(indio_dev, client, gdata);
>
> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
> index 8aa37af306ed..6a6c8121ac2c 100644
> --- a/drivers/iio/magnetometer/st_magn_i2c.c
> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
> @@ -59,7 +59,8 @@ static int st_magn_i2c_probe(struct i2c_client *client,
> return -ENOMEM;
>
> mdata = iio_priv(indio_dev);
> - st_sensors_of_i2c_probe(client, st_magn_of_match);
> + st_sensors_of_name_probe(&client->dev, st_magn_of_match,
> + client->name, sizeof(client->name));
>
> st_sensors_i2c_configure(indio_dev, client, mdata);
>
> diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
> index 17417a4d5a5f..7f15e927fa2b 100644
> --- a/drivers/iio/pressure/st_pressure_i2c.c
> +++ b/drivers/iio/pressure/st_pressure_i2c.c
> @@ -77,7 +77,8 @@ static int st_press_i2c_probe(struct i2c_client *client,
> press_data = iio_priv(indio_dev);
>
> if (client->dev.of_node) {
> - st_sensors_of_i2c_probe(client, st_press_of_match);
> + st_sensors_of_name_probe(&client->dev, st_press_of_match,
> + client->name, sizeof(client->name));
> } else if (ACPI_HANDLE(&client->dev)) {
> ret = st_sensors_match_acpi_device(&client->dev);
> if ((ret < 0) || (ret >= ST_PRESS_MAX))
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index 497f2b3a5a62..1f8211b6438b 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -325,4 +325,16 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
> ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
> struct device_attribute *attr, char *buf);
>
> +#ifdef CONFIG_OF
> +void st_sensors_of_name_probe(struct device *dev,
> + const struct of_device_id *match,
> + char *name, int len);
> +#else
> +static inline void st_sensors_of_name_probe(struct device *dev,
> + const struct of_device_id *match,
> + char *name, int len)
> +{
> +}
> +#endif
> +
> #endif /* ST_SENSORS_H */
> diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
> index 254de3c7dde8..0a2c25e06d1f 100644
> --- a/include/linux/iio/common/st_sensors_i2c.h
> +++ b/include/linux/iio/common/st_sensors_i2c.h
> @@ -18,16 +18,6 @@
> void st_sensors_i2c_configure(struct iio_dev *indio_dev,
> struct i2c_client *client, struct st_sensor_data *sdata);
>
> -#ifdef CONFIG_OF
> -void st_sensors_of_i2c_probe(struct i2c_client *client,
> - const struct of_device_id *match);
> -#else
> -static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
> - const struct of_device_id *match)
> -{
> -}
> -#endif
> -
> #ifdef CONFIG_ACPI
> int st_sensors_match_acpi_device(struct device *dev);
> #else
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match
2017-06-20 19:52 ` [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match Lorenzo Bianconi
@ 2017-06-21 19:56 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-21 19:56 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Tue, 20 Jun 2017 21:52:09 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> In order to add proper device tree support give a more general name
> to of_device_id table
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/accel/st_accel_spi.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index 1a867f5563a4..d13742edee0e 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -62,17 +62,17 @@ static const struct spi_device_id st_accel_id_table[] = {
> MODULE_DEVICE_TABLE(spi, st_accel_id_table);
>
> #ifdef CONFIG_OF
> -static const struct of_device_id lis302dl_spi_dt_ids[] = {
> +static const struct of_device_id st_accel_of_match[] = {
> { .compatible = "st,lis302dl-spi" },
> {}
> };
> -MODULE_DEVICE_TABLE(of, lis302dl_spi_dt_ids);
> +MODULE_DEVICE_TABLE(of, st_accel_of_match);
> #endif
>
> static struct spi_driver st_accel_driver = {
> .driver = {
> .name = "st-accel-spi",
> - .of_match_table = of_match_ptr(lis302dl_spi_dt_ids),
> + .of_match_table = of_match_ptr(st_accel_of_match),
> },
> .probe = st_accel_spi_probe,
> .remove = st_accel_spi_remove,
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi
2017-06-20 19:52 ` [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi Lorenzo Bianconi
@ 2017-06-21 19:58 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-21 19:58 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio, Rob Herring
On Tue, 20 Jun 2017 21:52:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> Add device tree support for LIS3DH accel sensor.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
I'm going to hold this one for a little while as I have an open question to Rob on
how to support package in package devices.
I suspect his answer will have a baring on this as well.
> ---
> drivers/iio/accel/st_accel_spi.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index d13742edee0e..b7252a8ab494 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -18,6 +18,22 @@
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_accel.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_accel_of_match[] = {
> + {
> + .compatible = "st,lis302dl-spi"
> + },
> + {
> + .compatible = "st,lis3dh-accel",
> + .data = LIS3DH_ACCEL_DEV_NAME,
> + },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, st_accel_of_match);
> +#else
> +#define st_accel_of_match NULL
> +#endif
> +
> static int st_accel_spi_probe(struct spi_device *spi)
> {
> struct iio_dev *indio_dev;
> @@ -30,6 +46,8 @@ static int st_accel_spi_probe(struct spi_device *spi)
>
> adata = iio_priv(indio_dev);
>
> + st_sensors_of_name_probe(&spi->dev, st_accel_of_match,
> + spi->modalias, sizeof(spi->modalias));
> st_sensors_spi_configure(indio_dev, spi, adata);
>
> err = st_accel_common_probe(indio_dev);
> @@ -61,14 +79,6 @@ static const struct spi_device_id st_accel_id_table[] = {
> };
> MODULE_DEVICE_TABLE(spi, st_accel_id_table);
>
> -#ifdef CONFIG_OF
> -static const struct of_device_id st_accel_of_match[] = {
> - { .compatible = "st,lis302dl-spi" },
> - {}
> -};
> -MODULE_DEVICE_TABLE(of, st_accel_of_match);
> -#endif
> -
> static struct spi_driver st_accel_driver = {
> .driver = {
> .name = "st-accel-spi",
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi
2017-06-20 19:52 ` [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi Lorenzo Bianconi
@ 2017-06-24 20:39 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-24 20:39 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Tue, 20 Jun 2017 21:52:11 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> Add device tree support for LIS3MDL magnetometer sensor
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
> drivers/iio/magnetometer/st_magn_spi.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
> index f3cb4dc05391..4847375f2c0d 100644
> --- a/drivers/iio/magnetometer/st_magn_spi.c
> +++ b/drivers/iio/magnetometer/st_magn_spi.c
> @@ -18,6 +18,19 @@
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_magn.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_magn_of_match[] = {
> + {
> + .compatible = "st,lis3mdl-magn",
Ideally we should drop the magn as that is all this part is...
> + .data = LIS3MDL_MAGN_DEV_NAME,
> + },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, st_magn_of_match);
> +#else
> +#define st_magn_of_match NULL
> +#endif
> +
> static int st_magn_spi_probe(struct spi_device *spi)
> {
> struct iio_dev *indio_dev;
> @@ -30,6 +43,8 @@ static int st_magn_spi_probe(struct spi_device *spi)
>
> mdata = iio_priv(indio_dev);
>
> + st_sensors_of_name_probe(&spi->dev, st_magn_of_match,
> + spi->modalias, sizeof(spi->modalias));
> st_sensors_spi_configure(indio_dev, spi, mdata);
>
> err = st_magn_common_probe(indio_dev);
> @@ -57,6 +72,7 @@ MODULE_DEVICE_TABLE(spi, st_magn_id_table);
> static struct spi_driver st_magn_driver = {
> .driver = {
> .name = "st-magn-spi",
> + .of_match_table = of_match_ptr(st_magn_of_match),
> },
> .probe = st_magn_spi_probe,
> .remove = st_magn_spi_remove,
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
2017-06-20 19:52 ` [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi Lorenzo Bianconi
@ 2017-06-24 20:41 ` Jonathan Cameron
2017-06-24 20:43 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-24 20:41 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Tue, 20 Jun 2017 21:52:12 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> Add device tree support for L3GD20H gyroscope sensor
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
> drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> index fa14d8f2170d..e49dd2c923ab 100644
> --- a/drivers/iio/gyro/st_gyro_spi.c
> +++ b/drivers/iio/gyro/st_gyro_spi.c
> @@ -18,6 +18,19 @@
> #include <linux/iio/common/st_sensors_spi.h>
> #include "st_gyro.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_gyro_of_match[] = {
> + {
> + .compatible = "st,l3gd20h-gyro",
Firstly, I think we need to drop the -gyro from any that
aren't effectively multiple chips in the same package.
Secondly why are we adding only a compatible for one of
the supported parts? They should all be here I think...
> + .data = L3GD20H_GYRO_DEV_NAME,
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
> +#else
> +#define st_gyro_of_match NULL
> +#endif
> +
> static int st_gyro_spi_probe(struct spi_device *spi)
> {
> struct iio_dev *indio_dev;
> @@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
>
> gdata = iio_priv(indio_dev);
>
> + st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
> + spi->modalias, sizeof(spi->modalias));
> st_sensors_spi_configure(indio_dev, spi, gdata);
>
> err = st_gyro_common_probe(indio_dev);
> @@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
> static struct spi_driver st_gyro_driver = {
> .driver = {
> .name = "st-gyro-spi",
> + .of_match_table = of_match_ptr(st_gyro_of_match),
> },
> .probe = st_gyro_spi_probe,
> .remove = st_gyro_spi_remove,
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
2017-06-24 20:41 ` Jonathan Cameron
@ 2017-06-24 20:43 ` Jonathan Cameron
2017-06-25 8:24 ` Lorenzo Bianconi
0 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-24 20:43 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Sat, 24 Jun 2017 21:41:13 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Tue, 20 Jun 2017 21:52:12 +0200
> Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
>
> > Add device tree support for L3GD20H gyroscope sensor
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> > ---
> > drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
> > 1 file changed, 16 insertions(+)
> >
> > diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> > index fa14d8f2170d..e49dd2c923ab 100644
> > --- a/drivers/iio/gyro/st_gyro_spi.c
> > +++ b/drivers/iio/gyro/st_gyro_spi.c
> > @@ -18,6 +18,19 @@
> > #include <linux/iio/common/st_sensors_spi.h>
> > #include "st_gyro.h"
> >
> > +#ifdef CONFIG_OF
> > +static const struct of_device_id st_gyro_of_match[] = {
> > + {
> > + .compatible = "st,l3gd20h-gyro",
> Firstly, I think we need to drop the -gyro from any that
> aren't effectively multiple chips in the same package.
>
> Secondly why are we adding only a compatible for one of
> the supported parts? They should all be here I think...
Hohum. Rob acked a patch with the -gyro, presumably because
we are now stuck with that in the names.
Lets keep that, but I do want to see all the supported parts
in these lists.
> > + .data = L3GD20H_GYRO_DEV_NAME,
> > + },
> > + {},
> > +};
> > +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
> > +#else
> > +#define st_gyro_of_match NULL
> > +#endif
> > +
> > static int st_gyro_spi_probe(struct spi_device *spi)
> > {
> > struct iio_dev *indio_dev;
> > @@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
> >
> > gdata = iio_priv(indio_dev);
> >
> > + st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
> > + spi->modalias, sizeof(spi->modalias));
> > st_sensors_spi_configure(indio_dev, spi, gdata);
> >
> > err = st_gyro_common_probe(indio_dev);
> > @@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
> > static struct spi_driver st_gyro_driver = {
> > .driver = {
> > .name = "st-gyro-spi",
> > + .of_match_table = of_match_ptr(st_gyro_of_match),
> > },
> > .probe = st_gyro_spi_probe,
> > .remove = st_gyro_spi_remove,
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
2017-06-24 20:43 ` Jonathan Cameron
@ 2017-06-25 8:24 ` Lorenzo Bianconi
2017-06-25 16:05 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Bianconi @ 2017-06-25 8:24 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
> On Sat, 24 Jun 2017 21:41:13 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
>
>> On Tue, 20 Jun 2017 21:52:12 +0200
>> Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
>>
>> > Add device tree support for L3GD20H gyroscope sensor
>> >
>> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
>> > ---
>> > drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
>> > 1 file changed, 16 insertions(+)
>> >
>> > diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
>> > index fa14d8f2170d..e49dd2c923ab 100644
>> > --- a/drivers/iio/gyro/st_gyro_spi.c
>> > +++ b/drivers/iio/gyro/st_gyro_spi.c
>> > @@ -18,6 +18,19 @@
>> > #include <linux/iio/common/st_sensors_spi.h>
>> > #include "st_gyro.h"
>> >
>> > +#ifdef CONFIG_OF
>> > +static const struct of_device_id st_gyro_of_match[] = {
>> > + {
>> > + .compatible = "st,l3gd20h-gyro",
>> Firstly, I think we need to drop the -gyro from any that
>> aren't effectively multiple chips in the same package.
>>
>> Secondly why are we adding only a compatible for one of
>> the supported parts? They should all be here I think...
> Hohum. Rob acked a patch with the -gyro, presumably because
> we are now stuck with that in the names.
>
Hi Jonathan,
I added '-gyro' in compatible string to maintain compatibility with
i2c counterpart otherwise
we will have two different compatible string for spi and i2c
interfaces. I will add a comment to not
use that convention for newer devices, do you agree?
Moreover I added just the device where I tested the solution. In v2 I
will add all supported devices
since the discovery code is in common with i2c and it is well tested.
I guess these arguments will apply on accel/magn/pressure counterparts as well.
Regards,
Lorenzo
> Lets keep that, but I do want to see all the supported parts
> in these lists.
>> > + .data = L3GD20H_GYRO_DEV_NAME,
>> > + },
>> > + {},
>> > +};
>> > +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
>> > +#else
>> > +#define st_gyro_of_match NULL
>> > +#endif
>> > +
>> > static int st_gyro_spi_probe(struct spi_device *spi)
>> > {
>> > struct iio_dev *indio_dev;
>> > @@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
>> >
>> > gdata = iio_priv(indio_dev);
>> >
>> > + st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
>> > + spi->modalias, sizeof(spi->modalias));
>> > st_sensors_spi_configure(indio_dev, spi, gdata);
>> >
>> > err = st_gyro_common_probe(indio_dev);
>> > @@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
>> > static struct spi_driver st_gyro_driver = {
>> > .driver = {
>> > .name = "st-gyro-spi",
>> > + .of_match_table = of_match_ptr(st_gyro_of_match),
>> > },
>> > .probe = st_gyro_spi_probe,
>> > .remove = st_gyro_spi_remove,
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi
2017-06-25 8:24 ` Lorenzo Bianconi
@ 2017-06-25 16:05 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2017-06-25 16:05 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio
On Sun, 25 Jun 2017 10:24:09 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> > On Sat, 24 Jun 2017 21:41:13 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >
> >> On Tue, 20 Jun 2017 21:52:12 +0200
> >> Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:
> >>
> >> > Add device tree support for L3GD20H gyroscope sensor
> >> >
> >> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> >> > ---
> >> > drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
> >> > 1 file changed, 16 insertions(+)
> >> >
> >> > diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> >> > index fa14d8f2170d..e49dd2c923ab 100644
> >> > --- a/drivers/iio/gyro/st_gyro_spi.c
> >> > +++ b/drivers/iio/gyro/st_gyro_spi.c
> >> > @@ -18,6 +18,19 @@
> >> > #include <linux/iio/common/st_sensors_spi.h>
> >> > #include "st_gyro.h"
> >> >
> >> > +#ifdef CONFIG_OF
> >> > +static const struct of_device_id st_gyro_of_match[] = {
> >> > + {
> >> > + .compatible = "st,l3gd20h-gyro",
> >> Firstly, I think we need to drop the -gyro from any that
> >> aren't effectively multiple chips in the same package.
> >>
> >> Secondly why are we adding only a compatible for one of
> >> the supported parts? They should all be here I think...
> > Hohum. Rob acked a patch with the -gyro, presumably because
> > we are now stuck with that in the names.
> >
>
> Hi Jonathan,
>
> I added '-gyro' in compatible string to maintain compatibility with
> i2c counterpart otherwise
> we will have two different compatible string for spi and i2c
> interfaces. I will add a comment to not
> use that convention for newer devices, do you agree?
That works for me. Not much we can do about the past.
The only possible extension would be to support the 'clean' versions
of existing parts as well as additional compatible entries.
Worth doing to avoid confusion in future?
> Moreover I added just the device where I tested the solution. In v2 I
> will add all supported devices
> since the discovery code is in common with i2c and it is well tested.
> I guess these arguments will apply on accel/magn/pressure counterparts as well.
>
> Regards,
> Lorenzo
>
> > Lets keep that, but I do want to see all the supported parts
> > in these lists.
> >> > + .data = L3GD20H_GYRO_DEV_NAME,
> >> > + },
> >> > + {},
> >> > +};
> >> > +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
> >> > +#else
> >> > +#define st_gyro_of_match NULL
> >> > +#endif
> >> > +
> >> > static int st_gyro_spi_probe(struct spi_device *spi)
> >> > {
> >> > struct iio_dev *indio_dev;
> >> > @@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
> >> >
> >> > gdata = iio_priv(indio_dev);
> >> >
> >> > + st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
> >> > + spi->modalias, sizeof(spi->modalias));
> >> > st_sensors_spi_configure(indio_dev, spi, gdata);
> >> >
> >> > err = st_gyro_common_probe(indio_dev);
> >> > @@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
> >> > static struct spi_driver st_gyro_driver = {
> >> > .driver = {
> >> > .name = "st-gyro-spi",
> >> > + .of_match_table = of_match_ptr(st_gyro_of_match),
> >> > },
> >> > .probe = st_gyro_spi_probe,
> >> > .remove = st_gyro_spi_remove,
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-06-25 16:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 19:52 [PATCH 0/5] Add OF support in spi code for accel/magn/gyro ST devices Lorenzo Bianconi
2017-06-20 19:52 ` [PATCH 1/5] iio: common: st_sensors: move st_sensors_of_i2c_probe() in common code Lorenzo Bianconi
2017-06-21 19:54 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 2/5] iio: accel: st_accel_spi: rename of_device_id table in st_accel_of_match Lorenzo Bianconi
2017-06-21 19:56 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 3/5] iio: accel: st_accel_spi: add OF capability to st_accel_spi Lorenzo Bianconi
2017-06-21 19:58 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 4/5] iio: magnetometer: st_magn_spi: add OF capability to st_magn_spi Lorenzo Bianconi
2017-06-24 20:39 ` Jonathan Cameron
2017-06-20 19:52 ` [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi Lorenzo Bianconi
2017-06-24 20:41 ` Jonathan Cameron
2017-06-24 20:43 ` Jonathan Cameron
2017-06-25 8:24 ` Lorenzo Bianconi
2017-06-25 16:05 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).