]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 16 Dec 2019 17:38:52 +0000 (19:38 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 13 Jan 2020 21:51:52 +0000 (21:51 +0000)
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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/st_accel_spi.c
drivers/iio/common/st_sensors/st_sensors_core.c
drivers/iio/common/st_sensors/st_sensors_i2c.c
drivers/iio/gyro/st_gyro_i2c.c
drivers/iio/gyro/st_gyro_spi.c
drivers/iio/magnetometer/st_magn_i2c.c
drivers/iio/magnetometer/st_magn_spi.c
drivers/iio/pressure/st_pressure_i2c.c
drivers/iio/pressure/st_pressure_spi.c
include/linux/iio/common/st_sensors.h
include/linux/iio/common/st_sensors_i2c.h

index 8af7027d5598fe2dacb4ce7bd9ba737a8e9df256..3e25268638e2fc72ead27305d4f36136091d4339 100644 (file)
@@ -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) {
index 4a3064fb6cd9c350bc7ce25d113b14d72433ea9f..42a71a50650f6d4d232c208214c703faf4f1b7c5 100644 (file)
@@ -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)
index aa89d54a7c595f87b15a1b5948651983c929cddc..286830fb5d357523c54b63a5eaf8d33036a7624d 100644 (file)
@@ -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 <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
 MODULE_LICENSE("GPL v2");
index 05a1a0874bd5e291c4c4c4beca4e7dedc601ce35..bc0010835ac0df9d140c0897a2dddd21ffe267c2 100644 (file)
@@ -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) {
index b5c6242512312fa9707618b7d2cce2100d527c79..07224d5bf2996d96d9734de1592bf79207e7b6c4 100644 (file)
@@ -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) {
index fdba480a12becb913c1aae10177bb3bb3edc327d..bf63777bbc6e2f3708b97fa61fb0e830fb8b8ea7 100644 (file)
@@ -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) {
index fbf909bde8417009ded29187d24290121d791d71..78f846fc120e113cebba38d67cfaf34fa2807829 100644 (file)
@@ -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) {
index 6203bc9d5c2dcb43fe33d5d755590f661afd6ef8..dd1f515ca1f1b6f03623f5d104777487e76da03a 100644 (file)
@@ -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) {
index 7c8b70221e705f38aa6dbf6a3fcd50decc75a6f6..dd31241bf4b4d43feecaf33381dc82f7f16e6adc 100644 (file)
@@ -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) {
index 686be532f4cb7ced48981f4f7dbe0482aea516e2..33e939977444bfe04b1eb40f1d6c5b24f2cc334d 100644 (file)
@@ -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 */
index 01e424e2af4f000cfad14abb83d1147d3bd86b7c..5f15cf01036cbc184e19413ffd8a293641e65c13 100644 (file)
 
 #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 */