* [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support
@ 2014-07-07 9:48 Linus Walleij
2014-07-07 12:24 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2014-07-07 9:48 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio, Denis CIOCCA; +Cc: Lee Jones, Linus Walleij
The I2C devices that make up the STMicroelectronics MEMS sensors
may be sneakily enabled by cleverly giving the device node the same
name as a string match from the platform device ID table. However
the right method is to use the compatible string.
On detection, the ST sensors use the ID string to probe and
instatiate the right sensor driver, so pass the kernel-internal ID
string in the .data field of the OF match table, and set the I2C
client name to this name when a compatible match is used.
This avoids having misc Linux-specific strings floating around in
the device tree.
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Denis CIOCCA <denis.ciocca@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/iio/accel/st_accel_i2c.c | 49 ++++++++++++++++++++++++++
drivers/iio/common/st_sensors/st_sensors_i2c.c | 29 +++++++++++++++
drivers/iio/gyro/st_gyro_i2c.c | 37 +++++++++++++++++++
drivers/iio/magnetometer/st_magn_i2c.c | 21 +++++++++++
drivers/iio/pressure/st_pressure_i2c.c | 21 +++++++++++
include/linux/iio/common/st_sensors_i2c.h | 11 ++++++
6 files changed, 168 insertions(+)
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index d7bedbdfc81d..67000e507d83 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -18,6 +18,53 @@
#include <linux/iio/common/st_sensors_i2c.h>
#include "st_accel.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_accel_of_match[] = {
+ {
+ .compatible = "st,lsm303dlh-accel",
+ .data = LSM303DLH_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm303dlhc-accel",
+ .data = LSM303DLHC_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lis3dh-accel",
+ .data = LIS3DH_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330d-accel",
+ .data = LSM330D_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330dl-accel",
+ .data = LSM330DL_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330dlc-accel",
+ .data = LSM330DLC_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lis331dlh-accel",
+ .data = LIS331DLH_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm303dl-accel",
+ .data = LSM303DL_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm303dlm-accel",
+ .data = LSM303DLM_ACCEL_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330-accel",
+ .data = LSM330_ACCEL_DEV_NAME,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, st_accel_of_match);
+#endif
+
static int st_accel_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -31,6 +78,7 @@ static int st_accel_i2c_probe(struct i2c_client *client,
adata = iio_priv(indio_dev);
adata->dev = &client->dev;
+ st_sensors_of_i2c_probe(client, st_accel_of_match);
st_sensors_i2c_configure(indio_dev, client, adata);
@@ -67,6 +115,7 @@ static struct i2c_driver st_accel_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "st-accel-i2c",
+ .of_match_table = of_match_ptr(st_accel_of_match),
},
.probe = st_accel_i2c_probe,
.remove = st_accel_i2c_remove,
diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
index 38af9440c103..12246e9529ef 100644
--- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
+++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/iio/iio.h>
+#include <linux/of_device.h>
#include <linux/iio/common/st_sensors_i2c.h>
@@ -76,6 +77,34 @@ 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';
+}
+#endif
+
MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
index 23c12f361b05..a26516aea8cb 100644
--- a/drivers/iio/gyro/st_gyro_i2c.c
+++ b/drivers/iio/gyro/st_gyro_i2c.c
@@ -18,6 +18,41 @@
#include <linux/iio/common/st_sensors_i2c.h>
#include "st_gyro.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_gyro_of_match[] = {
+ {
+ .compatible = "st,l3g4200d-gyro",
+ .data = L3G4200D_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330d-gyro",
+ .data = LSM330D_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330dl-gyro",
+ .data = LSM330DL_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330dlc-gyro",
+ .data = LSM330DLC_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,l3gd20-gyro",
+ .data = L3GD20_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,l3g4is-gyro",
+ .data = L3G4IS_GYRO_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm330-gyro",
+ .data = LSM330_GYRO_DEV_NAME,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, st_gyro_of_match);
+#endif
+
static int st_gyro_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -31,6 +66,7 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
gdata = iio_priv(indio_dev);
gdata->dev = &client->dev;
+ st_sensors_of_i2c_probe(client, st_gyro_of_match);
st_sensors_i2c_configure(indio_dev, client, gdata);
@@ -65,6 +101,7 @@ static struct i2c_driver st_gyro_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "st-gyro-i2c",
+ .of_match_table = of_match_ptr(st_gyro_of_match),
},
.probe = st_gyro_i2c_probe,
.remove = st_gyro_i2c_remove,
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 892e0feeb5c1..486279d1f1e2 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -18,6 +18,25 @@
#include <linux/iio/common/st_sensors_i2c.h>
#include "st_magn.h"
+#ifdef CONFIG_OF
+static const struct of_device_id st_magn_of_match[] = {
+ {
+ .compatible = "st,lsm303dlhc-magn",
+ .data = LSM303DLHC_MAGN_DEV_NAME,
+ },
+ {
+ .compatible = "st,lsm303dlm-magn",
+ .data = LSM303DLM_MAGN_DEV_NAME,
+ },
+ {
+ .compatible = "st,lis3mdl-magn",
+ .data = LIS3MDL_MAGN_DEV_NAME,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, st_magn_of_match);
+#endif
+
static int st_magn_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -31,6 +50,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,
mdata = iio_priv(indio_dev);
mdata->dev = &client->dev;
+ st_sensors_of_i2c_probe(client, st_magn_of_match);
st_sensors_i2c_configure(indio_dev, client, mdata);
@@ -61,6 +81,7 @@ static struct i2c_driver st_magn_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "st-magn-i2c",
+ .of_match_table = of_match_ptr(st_magn_of_match),
},
.probe = st_magn_i2c_probe,
.remove = st_magn_i2c_remove,
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 3cd73e39b840..0ab5a20d7760 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -18,6 +18,25 @@
#include <linux/iio/common/st_sensors_i2c.h>
#include "st_pressure.h"
+#ifdef CONFIG_OF
+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,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, st_press_of_match);
+#endif
+
static int st_press_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -31,6 +50,7 @@ static int st_press_i2c_probe(struct i2c_client *client,
pdata = iio_priv(indio_dev);
pdata->dev = &client->dev;
+ st_sensors_of_i2c_probe(client, st_press_of_match);
st_sensors_i2c_configure(indio_dev, client, pdata);
@@ -60,6 +80,7 @@ static struct i2c_driver st_press_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "st-press-i2c",
+ .of_match_table = of_match_ptr(st_press_of_match),
},
.probe = st_press_i2c_probe,
.remove = st_press_i2c_remove,
diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
index 67d845385ae2..1796af093368 100644
--- a/include/linux/iio/common/st_sensors_i2c.h
+++ b/include/linux/iio/common/st_sensors_i2c.h
@@ -13,8 +13,19 @@
#include <linux/i2c.h>
#include <linux/iio/common/st_sensors.h>
+#include <linux/of.h>
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
+
#endif /* ST_SENSORS_I2C_H */
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support
2014-07-07 9:48 [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support Linus Walleij
@ 2014-07-07 12:24 ` Jonathan Cameron
2014-07-07 13:54 ` Linus Walleij
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2014-07-07 12:24 UTC (permalink / raw)
To: Linus Walleij, linux-iio, Denis CIOCCA; +Cc: Lee Jones
On 07/07/14 10:48, Linus Walleij wrote:
> The I2C devices that make up the STMicroelectronics MEMS sensors
> may be sneakily enabled by cleverly giving the device node the same
> name as a string match from the platform device ID table. However
> the right method is to use the compatible string.
>
> On detection, the ST sensors use the ID string to probe and
> instatiate the right sensor driver, so pass the kernel-internal ID
> string in the .data field of the OF match table, and set the I2C
> client name to this name when a compatible match is used.
>
> This avoids having misc Linux-specific strings floating around in
> the device tree.
>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Denis CIOCCA <denis.ciocca@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
ERROR: "st_sensors_of_i2c_probe" [drivers/iio/pressure/st_pressure_i2c.ko] undefined!
ERROR: "st_sensors_of_i2c_probe" [drivers/iio/magnetometer/st_magn_i2c.ko] undefined!
ERROR: "st_sensors_of_i2c_probe" [drivers/iio/gyro/st_gyro_i2c.ko] undefined!
ERROR: "st_sensors_of_i2c_probe" [drivers/iio/accel/st_accel_i2c.ko] undefined!
scripts/Makefile.modpost:90: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1047: recipe for target 'modules' failed
make: *** [modules] Error 2
When CONFIG_OF not selected.
> ---
> drivers/iio/accel/st_accel_i2c.c | 49 ++++++++++++++++++++++++++
> drivers/iio/common/st_sensors/st_sensors_i2c.c | 29 +++++++++++++++
> drivers/iio/gyro/st_gyro_i2c.c | 37 +++++++++++++++++++
> drivers/iio/magnetometer/st_magn_i2c.c | 21 +++++++++++
> drivers/iio/pressure/st_pressure_i2c.c | 21 +++++++++++
> include/linux/iio/common/st_sensors_i2c.h | 11 ++++++
> 6 files changed, 168 insertions(+)
>
> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
> index d7bedbdfc81d..67000e507d83 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -18,6 +18,53 @@
> #include <linux/iio/common/st_sensors_i2c.h>
> #include "st_accel.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_accel_of_match[] = {
> + {
> + .compatible = "st,lsm303dlh-accel",
> + .data = LSM303DLH_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm303dlhc-accel",
> + .data = LSM303DLHC_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lis3dh-accel",
> + .data = LIS3DH_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330d-accel",
> + .data = LSM330D_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330dl-accel",
> + .data = LSM330DL_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330dlc-accel",
> + .data = LSM330DLC_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lis331dlh-accel",
> + .data = LIS331DLH_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm303dl-accel",
> + .data = LSM303DL_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm303dlm-accel",
> + .data = LSM303DLM_ACCEL_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330-accel",
> + .data = LSM330_ACCEL_DEV_NAME,
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, st_accel_of_match);
> +#endif
> +
> static int st_accel_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -31,6 +78,7 @@ static int st_accel_i2c_probe(struct i2c_client *client,
>
> adata = iio_priv(indio_dev);
> adata->dev = &client->dev;
> + st_sensors_of_i2c_probe(client, st_accel_of_match);
>
> st_sensors_i2c_configure(indio_dev, client, adata);
>
> @@ -67,6 +115,7 @@ static struct i2c_driver st_accel_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "st-accel-i2c",
> + .of_match_table = of_match_ptr(st_accel_of_match),
> },
> .probe = st_accel_i2c_probe,
> .remove = st_accel_i2c_remove,
> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> index 38af9440c103..12246e9529ef 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
> @@ -12,6 +12,7 @@
> #include <linux/module.h>
> #include <linux/slab.h>
> #include <linux/iio/iio.h>
> +#include <linux/of_device.h>
>
> #include <linux/iio/common/st_sensors_i2c.h>
>
> @@ -76,6 +77,34 @@ 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';
> +}
> +#endif
> +
> MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
> MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
> MODULE_LICENSE("GPL v2");
> diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
> index 23c12f361b05..a26516aea8cb 100644
> --- a/drivers/iio/gyro/st_gyro_i2c.c
> +++ b/drivers/iio/gyro/st_gyro_i2c.c
> @@ -18,6 +18,41 @@
> #include <linux/iio/common/st_sensors_i2c.h>
> #include "st_gyro.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_gyro_of_match[] = {
> + {
> + .compatible = "st,l3g4200d-gyro",
> + .data = L3G4200D_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330d-gyro",
> + .data = LSM330D_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330dl-gyro",
> + .data = LSM330DL_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330dlc-gyro",
> + .data = LSM330DLC_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,l3gd20-gyro",
> + .data = L3GD20_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,l3g4is-gyro",
> + .data = L3G4IS_GYRO_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm330-gyro",
> + .data = LSM330_GYRO_DEV_NAME,
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
> +#endif
> +
> static int st_gyro_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -31,6 +66,7 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
>
> gdata = iio_priv(indio_dev);
> gdata->dev = &client->dev;
> + st_sensors_of_i2c_probe(client, st_gyro_of_match);
>
> st_sensors_i2c_configure(indio_dev, client, gdata);
>
> @@ -65,6 +101,7 @@ static struct i2c_driver st_gyro_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "st-gyro-i2c",
> + .of_match_table = of_match_ptr(st_gyro_of_match),
> },
> .probe = st_gyro_i2c_probe,
> .remove = st_gyro_i2c_remove,
> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
> index 892e0feeb5c1..486279d1f1e2 100644
> --- a/drivers/iio/magnetometer/st_magn_i2c.c
> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
> @@ -18,6 +18,25 @@
> #include <linux/iio/common/st_sensors_i2c.h>
> #include "st_magn.h"
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_magn_of_match[] = {
> + {
> + .compatible = "st,lsm303dlhc-magn",
> + .data = LSM303DLHC_MAGN_DEV_NAME,
> + },
> + {
> + .compatible = "st,lsm303dlm-magn",
> + .data = LSM303DLM_MAGN_DEV_NAME,
> + },
> + {
> + .compatible = "st,lis3mdl-magn",
> + .data = LIS3MDL_MAGN_DEV_NAME,
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, st_magn_of_match);
> +#endif
> +
> static int st_magn_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -31,6 +50,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,
>
> mdata = iio_priv(indio_dev);
> mdata->dev = &client->dev;
> + st_sensors_of_i2c_probe(client, st_magn_of_match);
>
> st_sensors_i2c_configure(indio_dev, client, mdata);
>
> @@ -61,6 +81,7 @@ static struct i2c_driver st_magn_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "st-magn-i2c",
> + .of_match_table = of_match_ptr(st_magn_of_match),
> },
> .probe = st_magn_i2c_probe,
> .remove = st_magn_i2c_remove,
> diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
> index 3cd73e39b840..0ab5a20d7760 100644
> --- a/drivers/iio/pressure/st_pressure_i2c.c
> +++ b/drivers/iio/pressure/st_pressure_i2c.c
> @@ -18,6 +18,25 @@
> #include <linux/iio/common/st_sensors_i2c.h>
> #include "st_pressure.h"
>
> +#ifdef CONFIG_OF
> +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,
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, st_press_of_match);
> +#endif
> +
> static int st_press_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -31,6 +50,7 @@ static int st_press_i2c_probe(struct i2c_client *client,
>
> pdata = iio_priv(indio_dev);
> pdata->dev = &client->dev;
> + st_sensors_of_i2c_probe(client, st_press_of_match);
>
> st_sensors_i2c_configure(indio_dev, client, pdata);
>
> @@ -60,6 +80,7 @@ static struct i2c_driver st_press_driver = {
> .driver = {
> .owner = THIS_MODULE,
> .name = "st-press-i2c",
> + .of_match_table = of_match_ptr(st_press_of_match),
> },
> .probe = st_press_i2c_probe,
> .remove = st_press_i2c_remove,
> diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h
> index 67d845385ae2..1796af093368 100644
> --- a/include/linux/iio/common/st_sensors_i2c.h
> +++ b/include/linux/iio/common/st_sensors_i2c.h
> @@ -13,8 +13,19 @@
>
> #include <linux/i2c.h>
> #include <linux/iio/common/st_sensors.h>
> +#include <linux/of.h>
>
> 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
> +
> #endif /* ST_SENSORS_I2C_H */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support
2014-07-07 12:24 ` Jonathan Cameron
@ 2014-07-07 13:54 ` Linus Walleij
2014-07-07 16:17 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2014-07-07 13:54 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio@vger.kernel.org, Denis CIOCCA, Lee Jones
On Mon, Jul 7, 2014 at 2:24 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/pressure/st_pressure_i2c.ko]
> undefined!
> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/magnetometer/st_magn_i2c.ko]
> undefined!
> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/gyro/st_gyro_i2c.ko]
> undefined!
> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/accel/st_accel_i2c.ko]
> undefined!
> scripts/Makefile.modpost:90: recipe for target '__modpost' failed
> make[1]: *** [__modpost] Error 1
> Makefile:1047: recipe for target 'modules' failed
> make: *** [modules] Error 2
>
> When CONFIG_OF not selected.
Um, when CONFIG_OF is *not* selected?
This looks more like it is selected, but the symbol is missing, since
I missed to export that symbol, right?
In the !CONFIG_OF case there is a static inline in
<linux/iio/common/st_sensors_i2c.h> to handle that.
The v2 patch I just sent should fix this issue...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support
2014-07-07 13:54 ` Linus Walleij
@ 2014-07-07 16:17 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2014-07-07 16:17 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-iio@vger.kernel.org, Denis CIOCCA, Lee Jones
On 07/07/14 14:54, Linus Walleij wrote:
> On Mon, Jul 7, 2014 at 2:24 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>
>> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/pressure/st_pressure_i2c.ko]
>> undefined!
>> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/magnetometer/st_magn_i2c.ko]
>> undefined!
>> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/gyro/st_gyro_i2c.ko]
>> undefined!
>> ERROR: "st_sensors_of_i2c_probe" [drivers/iio/accel/st_accel_i2c.ko]
>> undefined!
>> scripts/Makefile.modpost:90: recipe for target '__modpost' failed
>> make[1]: *** [__modpost] Error 1
>> Makefile:1047: recipe for target 'modules' failed
>> make: *** [modules] Error 2
>>
>> When CONFIG_OF not selected.
>
> Um, when CONFIG_OF is *not* selected?
>
> This looks more like it is selected, but the symbol is missing, since
> I missed to export that symbol, right?
*coughs* Yup you are right of course. The build in question did indeed
have CONFIG_OF selected.
>
> In the !CONFIG_OF case there is a static inline in
> <linux/iio/common/st_sensors_i2c.h> to handle that.
>
> The v2 patch I just sent should fix this issue...
Cool.
> Yours,
> Linus Walleij
> --
> 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] 4+ messages in thread
end of thread, other threads:[~2014-07-07 16:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-07 9:48 [RESEND PATCH 3/3] iio: st_sensors: add devicetree probing support Linus Walleij
2014-07-07 12:24 ` Jonathan Cameron
2014-07-07 13:54 ` Linus Walleij
2014-07-07 16:17 ` 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).