iio: light: st_uvis25: Drop unneeded header inclusion
PATCH 1/9 iio: light: st_uvis25: Drop unneeded header inclusion
There is no evidence that the driver supports or needs ACPI APIs.
--- drivers/iio/light/st_uvis25_i2c.c | 1 - 1 file changed, 1 deletion(-)
drivers/iio/light/st_uvis25_i2c.c +0 -1
@@ -9,7 +9,6 @@#include <linux/kernel.h> #include <linux/module.h> -#include <linux/acpi.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/regmap.h>
Signature · 1 line
2.24.0
PATCH 2/9 iio: accel: st_accel: Drop unnecessary #else branch for ACPI
ACPI_PTR() takes care of the argument in case of !CONFIG_ACPI. Remove unnecessary #else branch.
--- drivers/iio/accel/st_accel_i2c.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/accel/st_accel_i2c.c +0 -2
@@ -119,8 +119,6 @@ static const struct acpi_device_id st_accel_acpi_match[] = { { }, };MODULE_DEVICE_TABLE (acpi, st_accel_acpi_match); -#else -#define st_accel_acpi_match NULL#endif static const struct i2c_device_id st_accel_id_table[] = {
Signature · 1 line
2.24.0
Re: [PATCH v1 2/9] iio: accel: st_accel: Drop unnecessary #else branch for ACPI
Quoted 4 lines · On Mon, 16 Dec 2019 19:38:46 +0200 Andy Shevchenko…
ACPI_PTR()takes care of the argument in case of !CONFIG_ACPI. Remove unnecessary #else branch.Signed-off-by Andy Shevchenko <[email protected]>
Applied.
Thanks,
J
Quoted 17 lines
--- drivers/iio/accel/st_accel_i2c.c | 2 -- 1 file changed, 2 deletions(-)drivers/iio/accel/st_accel_i2c.c +0
-2@@ -119,8 +119,6 @@ static const struct acpi_device_id st_accel_acpi_match[] = { { }, };MODULE_DEVICE_TABLE (acpi, st_accel_acpi_match); -#else -#define st_accel_acpi_match NULL#endif static const struct i2c_device_id st_accel_id_table[] = {
PATCH 3/9 iio: pressure: st_press: Drop unnecessary #else branch for ACPI
In reply to Andy ShevchenkoACPI_PTR() takes care of the argument in case of !CONFIG_ACPI. Remove unnecessary #else branch.
--- drivers/iio/pressure/st_pressure_i2c.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/pressure/st_pressure_i2c.c +0 -2
@@ -61,8 +61,6 @@ static const struct acpi_device_id st_press_acpi_match[] = { { }, };MODULE_DEVICE_TABLE (acpi, st_press_acpi_match); -#else -#define st_press_acpi_match NULL#endif static const struct i2c_device_id st_press_id_table[] = {
Signature · 1 line
2.24.0
Re: [PATCH v1 3/9] iio: pressure: st_press: Drop unnecessary #else branch for ACPI
Quoted 4 lines · On Mon, 16 Dec 2019 19:38:47 +0200 Andy Shevchenko…
ACPI_PTR()takes care of the argument in case of !CONFIG_ACPI. Remove unnecessary #else branch.Signed-off-by Andy Shevchenko <[email protected]>
Applied.
Thanks,
Quoted 17 lines
--- drivers/iio/pressure/st_pressure_i2c.c | 2 -- 1 file changed, 2 deletions(-)drivers/iio/pressure/st_pressure_i2c.c +0
-2@@ -61,8 +61,6 @@ static const struct acpi_device_id st_press_acpi_match[] = { { }, };MODULE_DEVICE_TABLE (acpi, st_press_acpi_match); -#else -#define st_press_acpi_match NULL#endif static const struct i2c_device_id st_press_id_table[] = {
PATCH 4/9 iio: gyro: st_gyro: Mark gyro_pdata with __maybe_unused
In reply to Andy ShevchenkoSince we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark gyro_pdata with __maybe_unused to calm a compiler down:
In file included from drivers/iio/gyro/st_gyro_i2c.c:18:drivers/iio/gyro/st_gyro.h:31:46: warning: ‘gyro_pdata’ defined but not used [-Wunused-const-variable=]
31 | static const struct st_sensors_platform_data gyro_pdata = {
| ^~~~~~~~~~
...
--- drivers/iio/gyro/st_gyro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/st_gyro.h +1 -1
@@ -28,7 +28,7 @@* struct st_sensors_platform_data - gyro platform data * @drdy_int_pin: DRDY on gyros is available only on INT2 pin. */ -static const struct st_sensors_platform_data gyro_pdata = { +static __maybe_unused const struct st_sensors_platform_data gyro_pdata = { .drdy_int_pin =2 , };
Signature · 1 line
2.24.0
Re: [PATCH v1 4/9] iio: gyro: st_gyro: Mark gyro_pdata with __maybe_unused
Quoted 10 lines · On Mon, 16 Dec 2019 19:38:48 +0200 Andy Shevchenko…
Since we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark
gyro_pdatawith__maybe_unusedto calm a compiler down:In file included from
drivers/iio/gyro/st_gyro_i2c.c:18:drivers/iio/gyro/st_gyro.h:31:46: warning: ‘gyro_pdata’ defined but not used [-Wunused-const-variable=]
31 | static const structst_sensors_platform_datagyro_pdata= {
| ^~~~~~~~~~
...
Applied
Quoted 19 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/iio/gyro/st_gyro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/gyro/st_gyro.h +1
-1@@ -28,7 +28,7 @@* struct st_sensors_platform_data - gyro platform data * @drdy_int_pin: DRDY on gyros is available only on INT2 pin. */ -static const struct st_sensors_platform_data gyro_pdata = { +static __maybe_unused const struct st_sensors_platform_data gyro_pdata = { .drdy_int_pin =2 , };
PATCH 5/9 iio: accel: st_accel: Mark default_accel_pdata with __maybe_unused
In reply to Andy ShevchenkoSince we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark default_accel_pdata with __maybe_unused to calm a compiler down:
In file included from drivers/iio/accel/st_accel_i2c.c:19:drivers/iio/accel/st_accel.h:67:46: warning: ‘default_accel_pdata’ defined but not used [-Wunused-const-variable=]
67 | static const struct st_sensors_platform_data default_accel_pdata = {
| ^~~~~~~~~~~~~~~~~~~...
--- drivers/iio/accel/st_accel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/st_accel.h +1 -1
@@ -64,7 +64,7 @@ enum st_accel_type {* struct st_sensors_platform_data - default accel platform data * @drdy_int_pin: default accel DRDY is available on INT1 pin. */ -static const struct st_sensors_platform_data default_accel_pdata = { +static __maybe_unused const struct st_sensors_platform_data default_accel_pdata = { .drdy_int_pin =1 , };
Signature · 1 line
2.24.0
Re: [PATCH v1 5/9] iio: accel: st_accel: Mark default_accel_pdata with __maybe_unused
Quoted 10 lines · On Mon, 16 Dec 2019 19:38:49 +0200 Andy Shevchenko…
Since we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark
default_accel_pdatawith__maybe_unusedto calm a compiler down:In file included from
drivers/iio/accel/st_accel_i2c.c:19:drivers/iio/accel/st_accel.h:67:46: warning: ‘default_accel_pdata’ defined but not used [-Wunused-const-variable=]67 | static const struct st_sensors_platform_data default_accel_pdata = { | ^~~~~~~~~~~~~~~~~~~...
Applied.
Quoted 19 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/iio/accel/st_accel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/accel/st_accel.h +1
-1@@ -64,7 +64,7 @@ enum st_accel_type {* struct st_sensors_platform_data - default accel platform data * @drdy_int_pin: default accel DRDY is available on INT1 pin. */ -static const struct st_sensors_platform_data default_accel_pdata = { +static __maybe_unused const struct st_sensors_platform_data default_accel_pdata = { .drdy_int_pin =1 , };
PATCH 6/9 iio: pressure: st_press: Mark default_press_pdata with __maybe_unused
In reply to Andy ShevchenkoSince we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark default_press_pdata with __maybe_unused to calm a compiler down:
In file included from drivers/iio/pressure/st_pressure_spi.c:18:drivers/iio/pressure/st_pressure.h:40:46: warning: ‘default_press_pdata’ defined but not used [-Wunused-const-variable=]
40 | static const struct st_sensors_platform_data default_press_pdata = {
| ^~~~~~~~~~~~~~~~~~~...
--- drivers/iio/pressure/st_pressure.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/st_pressure.h +1 -1
@@ -37,7 +37,7 @@ enum st_press_type {* struct st_sensors_platform_data - default press platform data * @drdy_int_pin: default press DRDY is available on INT1 pin. */ -static const struct st_sensors_platform_data default_press_pdata = { +static __maybe_unused const struct st_sensors_platform_data default_press_pdata = { .drdy_int_pin =1 , };
Signature · 1 line
2.24.0
Re: [PATCH v1 6/9] iio: pressure: st_press: Mark default_press_pdata with __maybe_unused
Quoted 11 lines · On Mon, 16 Dec 2019 19:38:50 +0200 Andy Shevchenko…
Since we put static variable to a header file it's copied to each module that includes the header. But not all of them are actually used it.
Mark
default_press_pdatawith__maybe_unusedto calm a compiler down:In file included from
drivers/iio/pressure/st_pressure_spi.c:18:drivers/iio/pressure/st_pressure.h:40:46: warning: ‘default_press_pdata’ defined but not used [-Wunused-const-variable=]40 | static const struct st_sensors_platform_data default_press_pdata = { | ^~~~~~~~~~~~~~~~~~~...
Applied.
Quoted 18 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/iio/pressure/st_pressure.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/pressure/st_pressure.h +1
-1@@ -37,7 +37,7 @@ enum st_press_type {* struct st_sensors_platform_data - default press platform data * @drdy_int_pin: default press DRDY is available on INT1 pin. */ -static const struct st_sensors_platform_data default_press_pdata = { +static __maybe_unused const struct st_sensors_platform_data default_press_pdata = { .drdy_int_pin =1 , };
PATCH 7/9 iio: st_sensors: Describe function parameters in kernel-doc
In reply to Andy ShevchenkoKernel documentation script complains that some of the function parameters are not described:
.../common/st_sensors/st_sensors_trigger.c:29: warning: Function parameter or member 'indio_dev' not described in 'st_sensors_new_samples_available' .../common/st_sensors/st_sensors_trigger.c:29: warning: Function parameter or member 'sdata' not described in 'st_sensors_new_samples_available'
Describe function parameters where it's appropriate.
--- drivers/iio/common/st_sensors/st_sensors_trigger.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/common/st_sensors/st_sensors_trigger.c +3 -0
@@ -19,6 +19,9 @@/** * st_sensors_new_samples_available() - check if more samples came in +* @indio_dev: IIO device reference. +* @sdata: Sensor data. +* * returns: * 0 - no new samples available * 1 - new samples available
Signature · 1 line
2.24.0
Re: [PATCH v1 7/9] iio: st_sensors: Describe function parameters in kernel-doc
Quoted 9 lines · On Mon, 16 Dec 2019 19:38:51 +0200 Andy Shevchenko…
Kernel documentation script complains that some of the function parameters are not described:
.../common/st_sensors/st_sensors_trigger.c:29: warning: Function parameter or member 'indio_dev' not described in 'st_sensors_new_samples_available'.../common/st_sensors/st_sensors_trigger.c:29: warning: Function parameter or member 'sdata' not described in 'st_sensors_new_samples_available'Describe function parameters where it's appropriate.
Signed-off-by Andy Shevchenko <[email protected]>
Applied.
Thanks,
Jonathan
Quoted 18 lines
--- drivers/iio/common/st_sensors/st_sensors_trigger.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/common/st_sensors/st_sensors_trigger.c +3
-0@@ -19,6 +19,9 @@/** * st_sensors_new_samples_available() - check if more samples came in +* @indio_dev: IIO device reference. +* @sdata: Sensor data. +* * returns: * 0 - no new samples available * 1 - new samples available
PATCH 8/9 iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()
In reply to Andy ShevchenkoSince we have access to the struct device_driver and thus to the ID table, there is no need to supply special parameters to st_sensors_of_name_probe().
Besides that we have a common API to get driver match data, there is no need to do matching separately for OF and ACPI.
Taking into consideration above, simplify the ST sensors code.
--- drivers/iio/accel/st_accel_spi.c | 3 +- .../iio/common/st_sensors/st_sensors_core.c | 38 +++++++++---------- .../iio/common/st_sensors/st_sensors_i2c.c | 21 ---------- drivers/iio/gyro/st_gyro_i2c.c | 3 +- drivers/iio/gyro/st_gyro_spi.c | 3 +- drivers/iio/magnetometer/st_magn_i2c.c | 3 +- drivers/iio/magnetometer/st_magn_spi.c | 3 +- drivers/iio/pressure/st_pressure_i2c.c | 14 +------ drivers/iio/pressure/st_pressure_spi.c | 3 +- include/linux/iio/common/st_sensors.h | 12 +----- include/linux/iio/common/st_sensors_i2c.h | 10 ----- 11 files changed, 25 insertions(+), 88 deletions(-)
drivers/iio/accel/st_accel_spi.c +1 -2
@@ -107,8 +107,7 @@ static int st_accel_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_accel_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_accel_get_settings (spi->modalias);if (!settings) {
drivers/iio/common/st_sensors/st_sensors_core.c +17 -21
@@ -12,6 +12,7 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/iio/iio.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/of.h> #include <linux/of_device.h>
@@ -340,42 +341,37 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev, return pdata; } +#else +static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, +struct st_sensors_platform_data *defdata) +{ +return NULL ; +} +#endif /** -* st_sensors_of_name_probe() - device tree probe for ST sensor name +* st_sensors_dev_name_probe() - device 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 +* In effect this function matches an ID 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) +void st_sensors_dev_name_probe (struct device *dev,char *name,int len) { -const struct of_device_id *of_id; +const void *match; - of_id =of_match_device (match, dev); -if (!of_id || !of_id->data) + match =device_get_match_data (dev); +if (!match)return ; -/* The name from the OF match takes precedence if present */ -strlcpy (name, of_id->data, len); +/* The name from the match takes precedence if present */ +strlcpy (name, match, len); } -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) -{ -return NULL ; -} -#endif +EXPORT_SYMBOL (st_sensors_dev_name_probe);int st_sensors_init_sensor (struct iio_dev *indio_dev,struct st_sensors_platform_data *pdata)
drivers/iio/common/st_sensors/st_sensors_i2c.c +0 -21
@@ -11,8 +11,6 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/iio/iio.h> -#include <linux/of_device.h> -#include <linux/acpi.h> #include <linux/regmap.h> #include <linux/iio/common/st_sensors_i2c.h>
@@ -68,25 +66,6 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev, }EXPORT_SYMBOL (st_sensors_i2c_configure); -#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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics ST-sensors i2c driver" );MODULE_LICENSE ("GPL v2" );
drivers/iio/gyro/st_gyro_i2c.c +1 -2
@@ -70,8 +70,7 @@ static int st_gyro_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&client->dev, st_gyro_of_match, - client->name,sizeof (client->name)); +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_gyro_get_settings (client->name);if (!settings) {
drivers/iio/gyro/st_gyro_spi.c +1 -2
@@ -74,8 +74,7 @@ static int st_gyro_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_gyro_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_gyro_get_settings (spi->modalias);if (!settings) {
drivers/iio/magnetometer/st_magn_i2c.c +1 -2
@@ -62,8 +62,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&client->dev, st_magn_of_match, - client->name,sizeof (client->name)); +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_magn_get_settings (client->name);if (!settings) {
drivers/iio/magnetometer/st_magn_spi.c +1 -2
@@ -56,8 +56,7 @@ static int st_magn_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_magn_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_magn_get_settings (spi->modalias);if (!settings) {
drivers/iio/pressure/st_pressure_i2c.c +1 -13
@@ -10,7 +10,6 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/acpi.h> #include <linux/i2c.h> #include <linux/iio/iio.h>
@@ -83,18 +82,7 @@ static int st_press_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int ret; -if (client->dev.of_node) { -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 )) -return -ENODEV ; - -strlcpy (client->name, st_press_id_table[ret].name, -sizeof (client->name)); - }else if (!id) -return -ENODEV ; +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_press_get_settings (client->name);if (!settings) {
drivers/iio/pressure/st_pressure_spi.c +1 -2
@@ -66,8 +66,7 @@ static int st_press_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_press_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_press_get_settings (spi->modalias);if (!settings) {
include/linux/iio/common/st_sensors.h +1 -11
@@ -315,16 +315,6 @@ 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 +void st_sensors_dev_name_probe (struct device *dev,char *name,int len);#endif /* ST_SENSORS_H */
include/linux/iio/common/st_sensors_i2c.h +0 -10
@@ -12,18 +12,8 @@#include <linux/i2c.h> #include <linux/iio/common/st_sensors.h> -#include <linux/of.h> int st_sensors_i2c_configure (struct iio_dev *indio_dev,struct i2c_client *client); -#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 */
Signature · 1 line
2.24.0
Jonathan Cameron
maintainerRe: [PATCH v1 8/9] iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()
Quoted 9 lines · On Mon, 16 Dec 2019 19:38:52 +0200 Andy Shevchenko…
Since we have access to the struct
device_driverand thus to the ID table, there is no need to supply special parameters tost_sensors_of_name_probe().Besides that we have a common API to get driver match data, there is no need to do matching separately for OF and ACPI.
Taking into consideration above, simplify the ST sensors code.
Signed-off-by Andy Shevchenko <[email protected]>
This looks good to me, but its big enough that purely on that basis I'd like to leave it a little longer to let Denis / Lorezo or someone else have time to take a look.
If I seem to have lost it by the end of the first week in January, give me a poke. I may have drunk a few things before then ;)
Thanks,
Jonathan
Quoted 285 lines
--- drivers/iio/accel/st_accel_spi.c | 3 +- .../iio/common/st_sensors/st_sensors_core.c | 38 +++++++++---------- .../iio/common/st_sensors/st_sensors_i2c.c | 21 ---------- drivers/iio/gyro/st_gyro_i2c.c | 3 +- drivers/iio/gyro/st_gyro_spi.c | 3 +- drivers/iio/magnetometer/st_magn_i2c.c | 3 +- drivers/iio/magnetometer/st_magn_spi.c | 3 +- drivers/iio/pressure/st_pressure_i2c.c | 14 +------ drivers/iio/pressure/st_pressure_spi.c | 3 +- include/linux/iio/common/st_sensors.h | 12 +----- include/linux/iio/common/st_sensors_i2c.h | 10 ----- 11 files changed, 25 insertions(+), 88 deletions(-)drivers/iio/accel/st_accel_spi.c +1
-2@@ -107,8 +107,7 @@ static int st_accel_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_accel_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_accel_get_settings (spi->modalias);if (!settings) {drivers/iio/common/st_sensors/st_sensors_core.c +17
-21@@ -12,6 +12,7 @@#include <linux/slab.h> #include <linux/delay.h> #include <linux/iio/iio.h> +#include <linux/property.h> #include <linux/regulator/consumer.h> #include <linux/of.h> #include <linux/of_device.h> @@ -340,42 +341,37 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev, return pdata; } +#else +static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, +struct st_sensors_platform_data *defdata) +{ +return NULL ; +} +#endif /** -* st_sensors_of_name_probe() - device tree probe for ST sensor name +* st_sensors_dev_name_probe() - device 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 +* In effect this function matches an ID 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) +void st_sensors_dev_name_probe (struct device *dev,char *name,int len) { -const struct of_device_id *of_id; +const void *match; - of_id =of_match_device (match, dev); -if (!of_id || !of_id->data) + match =device_get_match_data (dev); +if (!match)return ; -/* The name from the OF match takes precedence if present */ -strlcpy (name, of_id->data, len); +/* The name from the match takes precedence if present */ +strlcpy (name, match, len); } -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) -{ -return NULL ; -} -#endif +EXPORT_SYMBOL (st_sensors_dev_name_probe);int st_sensors_init_sensor (struct iio_dev *indio_dev,struct st_sensors_platform_data *pdata)drivers/iio/common/st_sensors/st_sensors_i2c.c +0
-21@@ -11,8 +11,6 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/iio/iio.h> -#include <linux/of_device.h> -#include <linux/acpi.h> #include <linux/regmap.h> #include <linux/iio/common/st_sensors_i2c.h> @@ -68,25 +66,6 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev, }EXPORT_SYMBOL (st_sensors_i2c_configure); -#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 <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics ST-sensors i2c driver" );MODULE_LICENSE ("GPL v2" );drivers/iio/gyro/st_gyro_i2c.c +1
-2@@ -70,8 +70,7 @@ static int st_gyro_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&client->dev, st_gyro_of_match, - client->name,sizeof (client->name)); +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_gyro_get_settings (client->name);if (!settings) {drivers/iio/gyro/st_gyro_spi.c +1
-2@@ -74,8 +74,7 @@ static int st_gyro_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_gyro_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_gyro_get_settings (spi->modalias);if (!settings) {drivers/iio/magnetometer/st_magn_i2c.c +1
-2@@ -62,8 +62,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&client->dev, st_magn_of_match, - client->name,sizeof (client->name)); +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_magn_get_settings (client->name);if (!settings) {drivers/iio/magnetometer/st_magn_spi.c +1
-2@@ -56,8 +56,7 @@ static int st_magn_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_magn_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_magn_get_settings (spi->modalias);if (!settings) {drivers/iio/pressure/st_pressure_i2c.c +1
-13@@ -10,7 +10,6 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/acpi.h> #include <linux/i2c.h> #include <linux/iio/iio.h> @@ -83,18 +82,7 @@ static int st_press_i2c_probe(struct i2c_client *client,struct iio_dev *indio_dev;int ret; -if (client->dev.of_node) { -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 )) -return -ENODEV ; - -strlcpy (client->name, st_press_id_table[ret].name, -sizeof (client->name)); - }else if (!id) -return -ENODEV ; +st_sensors_dev_name_probe (&client->dev, client->name,sizeof (client->name)); settings =st_press_get_settings (client->name);if (!settings) {drivers/iio/pressure/st_pressure_spi.c +1
-2@@ -66,8 +66,7 @@ static int st_press_spi_probe(struct spi_device *spi)struct iio_dev *indio_dev;int err; -st_sensors_of_name_probe (&spi->dev, st_press_of_match, - spi->modalias,sizeof (spi->modalias)); +st_sensors_dev_name_probe (&spi->dev, spi->modalias,sizeof (spi->modalias)); settings =st_press_get_settings (spi->modalias);if (!settings) {include/linux/iio/common/st_sensors.h +1
-11@@ -315,16 +315,6 @@ 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 +void st_sensors_dev_name_probe (struct device *dev,char *name,int len);#endif /* ST_SENSORS_H */ include/linux/iio/common/st_sensors_i2c.h +0
-10@@ -12,18 +12,8 @@#include <linux/i2c.h> #include <linux/iio/common/st_sensors.h> -#include <linux/of.h> int st_sensors_i2c_configure (struct iio_dev *indio_dev,struct i2c_client *client); -#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 */
Re: [PATCH v1 8/9] iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()
Quoted 11 lines · Jonathan Cameron
Quoted 8 lines · On Mon, 16 Dec 2019 19:38:52 +0200 Andy Shevchenko…
Since we have access to the struct
device_driverand thus to the ID table, there is no need to supply special parameters tost_sensors_of_name_probe().Besides that we have a common API to get driver match data, there is no need to do matching separately for OF and ACPI.
Taking into consideration above, simplify the ST sensors code.
Quoted 7 lines
Quoted 1 line
Signed-off-by Andy Shevchenko <[email protected]>This looks good to me, but its big enough that purely on that basis I'd like to leave it a little longer to let Denis / Lorezo or someone else have time to take a look.
If I seem to have lost it by the end of the first week in January, give me a poke. I may have drunk a few things before then ;)
Gentle ping.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v1 8/9] iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()
Quoted 13 lines · On Mon, 13 Jan 2020 15:58:10 +0200 Andy Shevchenko…
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Mon, 16 Dec 2019 19:38:52 +0200 Andy Shevchenko…
Since we have access to the struct
device_driverand thus to the ID table, there is no need to supply special parameters tost_sensors_of_name_probe().Besides that we have a common API to get driver match data, there is no need to do matching separately for OF and ACPI.
Taking into consideration above, simplify the ST sensors code.
Signed-off-by Andy Shevchenko <[email protected]>
Quoted 9 lines
Quoted 6 lines
This looks good to me, but its big enough that purely on that basis I'd like to leave it a little longer to let Denis / Lorezo or someone else have time to take a look.
If I seem to have lost it by the end of the first week in January, give me a poke. I may have drunk a few things before then ;)
Gentle ping.
Thanks. Applied to the togreg branch of iio.git and pushed out as testing.
Jonathan
PATCH 9/9 iio: st_sensors: Make use of device properties
In reply to Andy ShevchenkoDevice property API allows to gather device resources from different sources, such as ACPI. Convert the drivers to unleash the power of device property API.
--- drivers/iio/accel/st_accel_i2c.c | 6 +----- drivers/iio/accel/st_accel_spi.c | 6 +----- .../iio/common/st_sensors/st_sensors_core.c | 21 +++++-------------- .../iio/common/st_sensors/st_sensors_spi.c | 12 ++++++----- drivers/iio/gyro/st_gyro_i2c.c | 6 +----- drivers/iio/gyro/st_gyro_spi.c | 6 +----- drivers/iio/magnetometer/st_magn_i2c.c | 6 +----- drivers/iio/magnetometer/st_magn_spi.c | 6 +----- drivers/iio/pressure/st_pressure_i2c.c | 6 +----- drivers/iio/pressure/st_pressure_spi.c | 6 +----- 10 files changed, 20 insertions(+), 61 deletions(-)
drivers/iio/accel/st_accel_i2c.c +1 -5
@@ -18,7 +18,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_accel.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_accel_of_match[] = { {/* An older compatible */
@@ -108,9 +107,6 @@ static const struct of_device_id st_accel_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_accel_of_match); -#else -#define st_accel_of_match NULL -#endif #ifdef CONFIG_ACPI static const struct acpi_device_id st_accel_acpi_match[] = {
@@ -193,7 +189,7 @@ static int st_accel_i2c_remove(struct i2c_client *client)static struct i2c_driver st_accel_driver = { .driver = { .name ="st-accel-i2c" , - .of_match_table =of_match_ptr (st_accel_of_match), + .of_match_table = st_accel_of_match, .acpi_match_table =ACPI_PTR (st_accel_acpi_match), }, .probe_new = st_accel_i2c_probe,
drivers/iio/accel/st_accel_spi.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_accel.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-accel to maintain
@@ -96,9 +95,6 @@ static const struct of_device_id st_accel_of_match[] = { {} };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) {
@@ -165,7 +161,7 @@ MODULE_DEVICE_TABLE(spi, st_accel_id_table);static struct spi_driver st_accel_driver = { .driver = { .name ="st-accel-spi" , - .of_match_table =of_match_ptr (st_accel_of_match), + .of_match_table = st_accel_of_match, }, .probe = st_accel_spi_probe, .remove = st_accel_spi_remove,
drivers/iio/common/st_sensors/st_sensors_core.c +5 -16
@@ -14,8 +14,6 @@#include <linux/iio/iio.h> #include <linux/property.h> #include <linux/regulator/consumer.h> -#include <linux/of.h> -#include <linux/of_device.h> #include <linux/regmap.h> #include <asm/unaligned.h> #include <linux/iio/common/st_sensors.h>
@@ -320,34 +318,25 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,return 0 ; } -#ifdef CONFIG_OF -static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, +static struct st_sensors_platform_data *st_sensors_dev_probe (struct device *dev,struct st_sensors_platform_data *defdata) {struct st_sensors_platform_data *pdata; -struct device_node *np = dev->of_node;u32 val; -if (!np) +if (!dev_fwnode (dev))return NULL ; pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL ); -if (!of_property_read_u32 (np,"st,drdy-int-pin" , &val) && (val <=2 )) +if (!device_property_read_u32 (dev,"st,drdy-int-pin" , &val) && (val <=2 )) pdata->drdy_int_pin = (u8 ) val;else pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin :0 ; - pdata->open_drain =of_property_read_bool (np,"drive-open-drain" ); + pdata->open_drain =device_property_read_bool (dev,"drive-open-drain" );return pdata; } -#else -static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, -struct st_sensors_platform_data *defdata) -{ -return NULL ; -} -#endif /** * st_sensors_dev_name_probe() - device probe for ST sensor name
@@ -381,7 +370,7 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,int err =0 ;/* If OF/DT pdata exists, it will take precedence of anything else */ - of_pdata =st_sensors_of_probe (indio_dev->dev.parent, pdata); + of_pdata =st_sensors_dev_probe (indio_dev->dev.parent, pdata);if (of_pdata) pdata = of_pdata;
drivers/iio/common/st_sensors/st_sensors_spi.c +7 -5
@@ -11,6 +11,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/iio/iio.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/iio/common/st_sensors_spi.h>
@@ -37,14 +38,15 @@ static const struct regmap_config st_sensors_spi_regmap_multiread_bit_config = {*/ static bool st_sensors_is_spi_3_wire (struct spi_device *spi) { -struct device_node *np = spi->dev.of_node;struct st_sensors_platform_data *pdata; +struct device *dev = &spi->dev; - pdata = (struct st_sensors_platform_data *)spi->dev.platform_data; -if ((np &&of_property_read_bool (np,"spi-3wire" )) || - (pdata && pdata->spi_3wire)) { +if (device_property_read_bool (dev,"spi-3wire" )) +return true; + + pdata = (struct st_sensors_platform_data *)dev->platform_data; +if (pdata && pdata->spi_3wire)return true; - }return false; }
drivers/iio/gyro/st_gyro_i2c.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_gyro.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_gyro_of_match[] = { { .compatible ="st,l3g4200d-gyro" ,
@@ -58,9 +57,6 @@ static const struct of_device_id st_gyro_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_gyro_of_match); -#else -#define st_gyro_of_match NULL -#endif static int st_gyro_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -121,7 +117,7 @@ MODULE_DEVICE_TABLE(i2c, st_gyro_id_table);static struct i2c_driver st_gyro_driver = { .driver = { .name ="st-gyro-i2c" , - .of_match_table =of_match_ptr (st_gyro_of_match), + .of_match_table = st_gyro_of_match, }, .probe = st_gyro_i2c_probe, .remove = st_gyro_i2c_remove,
drivers/iio/gyro/st_gyro_spi.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_gyro.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-gyro to maintain
@@ -63,9 +62,6 @@ static const struct of_device_id st_gyro_of_match[] = { {}, };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) {
@@ -125,7 +121,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), + .of_match_table = st_gyro_of_match, }, .probe = st_gyro_spi_probe, .remove = st_gyro_spi_remove,
drivers/iio/magnetometer/st_magn_i2c.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_magn.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_magn_of_match[] = { { .compatible ="st,lsm303dlh-magn" ,
@@ -50,9 +49,6 @@ static const struct of_device_id st_magn_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_magn_of_match); -#else -#define st_magn_of_match NULL -#endif static int st_magn_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -112,7 +108,7 @@ MODULE_DEVICE_TABLE(i2c, st_magn_id_table);static struct i2c_driver st_magn_driver = { .driver = { .name ="st-magn-i2c" , - .of_match_table =of_match_ptr (st_magn_of_match), + .of_match_table = st_magn_of_match, }, .probe = st_magn_i2c_probe, .remove = st_magn_i2c_remove,
drivers/iio/magnetometer/st_magn_spi.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_magn.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-magn to maintain
@@ -45,9 +44,6 @@ static const struct of_device_id st_magn_of_match[] = { {} };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) {
@@ -103,7 +99,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), + .of_match_table = st_magn_of_match, }, .probe = st_magn_spi_probe, .remove = st_magn_spi_remove,
drivers/iio/pressure/st_pressure_i2c.c +1 -5
@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_pressure.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_press_of_match[] = { { .compatible ="st,lps001wp-press" ,
@@ -50,9 +49,6 @@ static const struct of_device_id st_press_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_press_of_match); -#else -#define st_press_of_match NULL -#endif #ifdef CONFIG_ACPI static const struct acpi_device_id st_press_acpi_match[] = {
@@ -119,7 +115,7 @@ static int st_press_i2c_remove(struct i2c_client *client)static struct i2c_driver st_press_driver = { .driver = { .name ="st-press-i2c" , - .of_match_table =of_match_ptr (st_press_of_match), + .of_match_table = st_press_of_match, .acpi_match_table =ACPI_PTR (st_press_acpi_match), }, .probe = st_press_i2c_probe,
drivers/iio/pressure/st_pressure_spi.c +1 -5
@@ -17,7 +17,6 @@#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
@@ -55,9 +54,6 @@ static const struct of_device_id st_press_of_match[] = { {}, };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) {
@@ -115,7 +111,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), + .of_match_table = st_press_of_match, }, .probe = st_press_spi_probe, .remove = st_press_spi_remove,
Signature · 1 line
2.24.0
Jonathan Cameron
maintainerRe: [PATCH v1 9/9] iio: st_sensors: Make use of device properties
Quoted 4 lines · On Mon, 16 Dec 2019 19:38:53 +0200 Andy Shevchenko…
Device property API allows to gather device resources from different sources, such as ACPI. Convert the drivers to unleash the power of device property API.
Signed-off-by Andy Shevchenko <[email protected]>
Also looks fine, but will allow a bit more time for others to take a look.
Thanks,
Jonathna
Quoted 355 lines
--- drivers/iio/accel/st_accel_i2c.c | 6 +----- drivers/iio/accel/st_accel_spi.c | 6 +----- .../iio/common/st_sensors/st_sensors_core.c | 21 +++++-------------- .../iio/common/st_sensors/st_sensors_spi.c | 12 ++++++----- drivers/iio/gyro/st_gyro_i2c.c | 6 +----- drivers/iio/gyro/st_gyro_spi.c | 6 +----- drivers/iio/magnetometer/st_magn_i2c.c | 6 +----- drivers/iio/magnetometer/st_magn_spi.c | 6 +----- drivers/iio/pressure/st_pressure_i2c.c | 6 +----- drivers/iio/pressure/st_pressure_spi.c | 6 +----- 10 files changed, 20 insertions(+), 61 deletions(-)drivers/iio/accel/st_accel_i2c.c +1
-5@@ -18,7 +18,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_accel.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_accel_of_match[] = { {/* An older compatible */ @@ -108,9 +107,6 @@ static const struct of_device_id st_accel_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_accel_of_match); -#else -#define st_accel_of_match NULL -#endif #ifdef CONFIG_ACPI static const struct acpi_device_id st_accel_acpi_match[] = {@@ -193,7 +189,7 @@ static int st_accel_i2c_remove(struct i2c_client *client)static struct i2c_driver st_accel_driver = { .driver = { .name ="st-accel-i2c" , - .of_match_table =of_match_ptr (st_accel_of_match), + .of_match_table = st_accel_of_match, .acpi_match_table =ACPI_PTR (st_accel_acpi_match), }, .probe_new = st_accel_i2c_probe,drivers/iio/accel/st_accel_spi.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_accel.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-accel to maintain @@ -96,9 +95,6 @@ static const struct of_device_id st_accel_of_match[] = { {} };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) {@@ -165,7 +161,7 @@ MODULE_DEVICE_TABLE(spi, st_accel_id_table);static struct spi_driver st_accel_driver = { .driver = { .name ="st-accel-spi" , - .of_match_table =of_match_ptr (st_accel_of_match), + .of_match_table = st_accel_of_match, }, .probe = st_accel_spi_probe, .remove = st_accel_spi_remove,drivers/iio/common/st_sensors/st_sensors_core.c +5
-16@@ -14,8 +14,6 @@#include <linux/iio/iio.h> #include <linux/property.h> #include <linux/regulator/consumer.h> -#include <linux/of.h> -#include <linux/of_device.h> #include <linux/regmap.h> #include <asm/unaligned.h> #include <linux/iio/common/st_sensors.h> @@ -320,34 +318,25 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,return 0 ; } -#ifdef CONFIG_OF -static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, +static struct st_sensors_platform_data *st_sensors_dev_probe (struct device *dev,struct st_sensors_platform_data *defdata) {struct st_sensors_platform_data *pdata; -struct device_node *np = dev->of_node;u32 val; -if (!np) +if (!dev_fwnode (dev))return NULL ; pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL ); -if (!of_property_read_u32 (np,"st,drdy-int-pin" , &val) && (val <=2 )) +if (!device_property_read_u32 (dev,"st,drdy-int-pin" , &val) && (val <=2 )) pdata->drdy_int_pin = (u8 ) val;else pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin :0 ; - pdata->open_drain =of_property_read_bool (np,"drive-open-drain" ); + pdata->open_drain =device_property_read_bool (dev,"drive-open-drain" );return pdata; } -#else -static struct st_sensors_platform_data *st_sensors_of_probe (struct device *dev, -struct st_sensors_platform_data *defdata) -{ -return NULL ; -} -#endif /** * st_sensors_dev_name_probe() - device probe for ST sensor name @@ -381,7 +370,7 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,int err =0 ;/* If OF/DT pdata exists, it will take precedence of anything else */ - of_pdata =st_sensors_of_probe (indio_dev->dev.parent, pdata); + of_pdata =st_sensors_dev_probe (indio_dev->dev.parent, pdata);if (of_pdata) pdata = of_pdata;drivers/iio/common/st_sensors/st_sensors_spi.c +7
-5@@ -11,6 +11,7 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/iio/iio.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/iio/common/st_sensors_spi.h> @@ -37,14 +38,15 @@ static const struct regmap_config st_sensors_spi_regmap_multiread_bit_config = {*/ static bool st_sensors_is_spi_3_wire (struct spi_device *spi) { -struct device_node *np = spi->dev.of_node;struct st_sensors_platform_data *pdata; +struct device *dev = &spi->dev; - pdata = (struct st_sensors_platform_data *)spi->dev.platform_data; -if ((np &&of_property_read_bool (np,"spi-3wire" )) || - (pdata && pdata->spi_3wire)) { +if (device_property_read_bool (dev,"spi-3wire" )) +return true; + + pdata = (struct st_sensors_platform_data *)dev->platform_data; +if (pdata && pdata->spi_3wire)return true; - }return false; }drivers/iio/gyro/st_gyro_i2c.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_gyro.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_gyro_of_match[] = { { .compatible ="st,l3g4200d-gyro" ,@@ -58,9 +57,6 @@ static const struct of_device_id st_gyro_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_gyro_of_match); -#else -#define st_gyro_of_match NULL -#endif static int st_gyro_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)@@ -121,7 +117,7 @@ MODULE_DEVICE_TABLE(i2c, st_gyro_id_table);static struct i2c_driver st_gyro_driver = { .driver = { .name ="st-gyro-i2c" , - .of_match_table =of_match_ptr (st_gyro_of_match), + .of_match_table = st_gyro_of_match, }, .probe = st_gyro_i2c_probe, .remove = st_gyro_i2c_remove,drivers/iio/gyro/st_gyro_spi.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_gyro.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-gyro to maintain @@ -63,9 +62,6 @@ static const struct of_device_id st_gyro_of_match[] = { {}, };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) {@@ -125,7 +121,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), + .of_match_table = st_gyro_of_match, }, .probe = st_gyro_spi_probe, .remove = st_gyro_spi_remove,drivers/iio/magnetometer/st_magn_i2c.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_magn.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_magn_of_match[] = { { .compatible ="st,lsm303dlh-magn" ,@@ -50,9 +49,6 @@ static const struct of_device_id st_magn_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_magn_of_match); -#else -#define st_magn_of_match NULL -#endif static int st_magn_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)@@ -112,7 +108,7 @@ MODULE_DEVICE_TABLE(i2c, st_magn_id_table);static struct i2c_driver st_magn_driver = { .driver = { .name ="st-magn-i2c" , - .of_match_table =of_match_ptr (st_magn_of_match), + .of_match_table = st_magn_of_match, }, .probe = st_magn_i2c_probe, .remove = st_magn_i2c_remove,drivers/iio/magnetometer/st_magn_spi.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_spi.h> #include "st_magn.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use <device_name> as compatible string. * For old single-chip devices keep <device_name>-magn to maintain @@ -45,9 +44,6 @@ static const struct of_device_id st_magn_of_match[] = { {} };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) {@@ -103,7 +99,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), + .of_match_table = st_magn_of_match, }, .probe = st_magn_spi_probe, .remove = st_magn_spi_remove,drivers/iio/pressure/st_pressure_i2c.c +1
-5@@ -17,7 +17,6 @@#include <linux/iio/common/st_sensors_i2c.h> #include "st_pressure.h" -#ifdef CONFIG_OFstatic const struct of_device_id st_press_of_match[] = { { .compatible ="st,lps001wp-press" ,@@ -50,9 +49,6 @@ static const struct of_device_id st_press_of_match[] = { {}, };MODULE_DEVICE_TABLE (of, st_press_of_match); -#else -#define st_press_of_match NULL -#endif #ifdef CONFIG_ACPI static const struct acpi_device_id st_press_acpi_match[] = {@@ -119,7 +115,7 @@ static int st_press_i2c_remove(struct i2c_client *client)static struct i2c_driver st_press_driver = { .driver = { .name ="st-press-i2c" , - .of_match_table =of_match_ptr (st_press_of_match), + .of_match_table = st_press_of_match, .acpi_match_table =ACPI_PTR (st_press_acpi_match), }, .probe = st_press_i2c_probe,drivers/iio/pressure/st_pressure_spi.c +1
-5@@ -17,7 +17,6 @@#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 @@ -55,9 +54,6 @@ static const struct of_device_id st_press_of_match[] = { {}, };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) {@@ -115,7 +111,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), + .of_match_table = st_press_of_match, }, .probe = st_press_spi_probe, .remove = st_press_spi_remove,
Re: [PATCH v1 9/9] iio: st_sensors: Make use of device properties
Quoted 8 lines · Jonathan Cameron
Quoted 4 lines · On Mon, 16 Dec 2019 19:38:53 +0200 Andy Shevchenko…
Device property API allows to gather device resources from different sources, such as ACPI. Convert the drivers to unleash the power of device property API.
Signed-off-by Andy Shevchenko <[email protected]>Also looks fine, but will allow a bit more time for others to take a look.
Gentle ping.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 9/9] iio: st_sensors: Make use of device properties
Quoted 4 lines · On Mon, 13 Jan 2020 15:58:32 +0200 Andy Shevchenko…
Quoted 3 lines · Jonathan Cameron
On Mon, 16 Dec 2019 19:38:53 +0200
Andy Shevchenko <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Device property API allows to gather device resources from different sources, such as ACPI. Convert the drivers to unleash the power of device property API.
Signed-off-by Andy Shevchenko <[email protected]>Also looks fine, but will allow a bit more time for others to take a look.
Gentle ping.
Applied. Thanks for the reminder.
Jonathan
Quoted 3 lines · On Mon, 16 Dec 2019 19:38:45 +0200 Andy Shevchenko…
There is no evidence that the driver supports or needs ACPI APIs.
Signed-off-by Andy Shevchenko <[email protected]>
Applied.
Quoted 16 lines
--- drivers/iio/light/st_uvis25_i2c.c | 1 - 1 file changed, 1 deletion(-)drivers/iio/light/st_uvis25_i2c.c +0
-1@@ -9,7 +9,6 @@#include <linux/kernel.h> #include <linux/module.h> -#include <linux/acpi.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/regmap.h>