Skip to contentSkip to conversation

iio: light: st_uvis25: Drop unneeded header inclusion

PATCH Applied Andy Shevchenko 2 participants 22 messages Dec 16, 2019 – Jan 13, 2020 IIO

lore
Share & tools
lore
#0 lore raw

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
index dacbac6a6662..4889bbeb0c73 100644
@@ -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
#1 lore raw

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
index 50fa0fc32baa..0f4aef5448e7 100644
@@ -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
maintainer Applied
#2 lore raw

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.

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
index 50fa0fc32baa..0f4aef5448e7 100644
@@ -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[] = {
#3 lore raw

PATCH 3/9 iio: pressure: st_press: Drop unnecessary #else branch for ACPI

In reply to Andy Shevchenko

ACPI_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
index 71d2ed6b4948..6203bc9d5c2d 100644
@@ -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
maintainer Applied
#4 lore raw

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.

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
index 71d2ed6b4948..6203bc9d5c2d 100644
@@ -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[] = {
#5 lore raw

PATCH 4/9 iio: gyro: st_gyro: Mark gyro_pdata with __maybe_unused

In reply to 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_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
index 592f6b34e987..fd9171cc3aba 100644
@@ -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
maintainer Applied
#6 lore raw

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_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 = {
| ^~~~~~~~~~
...

Applied

Quoted 19 lines
---
 drivers/iio/gyro/st_gyro.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/st_gyro.h +1 -1
index 592f6b34e987..fd9171cc3aba 100644
@@ -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,
 };
 
#7 lore raw

PATCH 5/9 iio: accel: st_accel: Mark default_accel_pdata with __maybe_unused

In reply to 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_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
index af09943f38c9..5b13e293cade 100644
@@ -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
maintainer Applied
#8 lore raw

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_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 = {
      |                                              ^~~~~~~~~~~~~~~~~~~

...

Applied.

Quoted 19 lines
---
 drivers/iio/accel/st_accel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/st_accel.h +1 -1
index af09943f38c9..5b13e293cade 100644
@@ -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,
 };
 
#9 lore raw

PATCH 6/9 iio: pressure: st_press: Mark default_press_pdata with __maybe_unused

In reply to 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_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
index c2e47a6c3118..5c746ff6087e 100644
@@ -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
maintainer Applied
#10 lore raw

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_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 = {
      |                                              ^~~~~~~~~~~~~~~~~~~

...

Applied.

Quoted 18 lines
---
 drivers/iio/pressure/st_pressure.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/st_pressure.h +1 -1
index c2e47a6c3118..5c746ff6087e 100644
@@ -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,
 };
 
#11 lore raw

PATCH 7/9 iio: st_sensors: Describe function parameters in kernel-doc

In reply to 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.

---
 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
index 4a2efa00f7f2..e817537cdfb5 100644
@@ -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
maintainer Applied
#12 lore raw

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.

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
index 4a2efa00f7f2..e817537cdfb5 100644
@@ -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
#13 lore raw

PATCH 8/9 iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()

In reply to Andy Shevchenko

Since 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
index 8af7027d5598..3e25268638e2 100644
@@ -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
index 4a3064fb6cd9..42a71a50650f 100644
@@ -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
index aa89d54a7c59..286830fb5d35 100644
@@ -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
index 05a1a0874bd5..bc0010835ac0 100644
@@ -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
index b5c624251231..07224d5bf299 100644
@@ -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
index fdba480a12be..bf63777bbc6e 100644
@@ -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
index fbf909bde841..78f846fc120e 100644
@@ -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
index 6203bc9d5c2d..dd1f515ca1f1 100644
@@ -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
index 7c8b70221e70..dd31241bf4b4 100644
@@ -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
index 686be532f4cb..33e939977444 100644
@@ -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
index 01e424e2af4f..5f15cf01036c 100644
@@ -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
maintainer
#14 lore raw

Re: [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_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.

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
index 8af7027d5598..3e25268638e2 100644
@@ -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
index 4a3064fb6cd9..42a71a50650f 100644
@@ -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
index aa89d54a7c59..286830fb5d35 100644
@@ -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
index 05a1a0874bd5..bc0010835ac0 100644
@@ -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
index b5c624251231..07224d5bf299 100644
@@ -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
index fdba480a12be..bf63777bbc6e 100644
@@ -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
index fbf909bde841..78f846fc120e 100644
@@ -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
index 6203bc9d5c2d..dd1f515ca1f1 100644
@@ -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
index 7c8b70221e70..dd31241bf4b4 100644
@@ -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
index 686be532f4cb..33e939977444 100644
@@ -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
index 01e424e2af4f..5f15cf01036c 100644
@@ -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 */
#15 lore raw

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_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.

Quoted 7 lines
Quoted 1 line

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
maintainer
#16 lore raw

Re: [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_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.

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

#17 lore raw

PATCH 9/9 iio: st_sensors: Make use of device properties

In reply to 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.

---
 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
index 0f4aef5448e7..633955d764cc 100644
@@ -18,7 +18,6 @@
 #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[] = {
 	{
 		/* 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
index 3e25268638e2..568ff1bae0ee 100644
@@ -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
index 42a71a50650f..e051edbc43c1 100644
@@ -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
index 2262f81b07c2..1275fb0eda31 100644
@@ -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
index bc0010835ac0..8190966e6ff0 100644
@@ -17,7 +17,6 @@
 #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",
@@ -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
index 07224d5bf299..efb862763ca3 100644
@@ -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
index bf63777bbc6e..c6bb4ce77594 100644
@@ -17,7 +17,6 @@
 #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,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
index 78f846fc120e..3d08d74c367d 100644
@@ -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
index dd1f515ca1f1..09c6903f99b8 100644
@@ -17,7 +17,6 @@
 #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",
@@ -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
index dd31241bf4b4..b5ee3ec2764f 100644
@@ -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
maintainer
#18 lore raw

Re: [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.

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
index 0f4aef5448e7..633955d764cc 100644
@@ -18,7 +18,6 @@
 #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[] = {
 	{
 		/* 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
index 3e25268638e2..568ff1bae0ee 100644
@@ -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
index 42a71a50650f..e051edbc43c1 100644
@@ -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
index 2262f81b07c2..1275fb0eda31 100644
@@ -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
index bc0010835ac0..8190966e6ff0 100644
@@ -17,7 +17,6 @@
 #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",
@@ -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
index 07224d5bf299..efb862763ca3 100644
@@ -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
index bf63777bbc6e..c6bb4ce77594 100644
@@ -17,7 +17,6 @@
 #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,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
index 78f846fc120e..3d08d74c367d 100644
@@ -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
index dd1f515ca1f1..09c6903f99b8 100644
@@ -17,7 +17,6 @@
 #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",
@@ -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
index dd31241bf4b4..b5ee3ec2764f 100644
@@ -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,
#19 lore raw

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.

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
maintainer Applied
#20 lore raw

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.

Also looks fine, but will allow a bit more time for others to take a look.

Gentle ping.

Applied. Thanks for the reminder.

Jonathan

maintainer Applied
#21 lore raw
In reply to Andy Shevchenko
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.

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
index dacbac6a6662..4889bbeb0c73 100644
@@ -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>