From 4cf01d6d4eea2e3841aeaa4cb977e73ab5efab10 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 2 Dec 2019 09:53:50 +0100 Subject: iio: ssp_sensors: Convert to use GPIO descriptors These three GPIO lines used by the Samsung sensor hub is pretty straight-forward to convert to use GPIO descriptors. Cc: Karol Wrona Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/ssp_sensors/ssp.h | 14 +++++++------- drivers/iio/common/ssp_sensors/ssp_dev.c | 29 +++++++++-------------------- drivers/iio/common/ssp_sensors/ssp_spi.c | 8 ++++---- 3 files changed, 20 insertions(+), 31 deletions(-) (limited to 'drivers/iio/common') diff --git a/drivers/iio/common/ssp_sensors/ssp.h b/drivers/iio/common/ssp_sensors/ssp.h index 0a381bb1ae6f..abb832795619 100644 --- a/drivers/iio/common/ssp_sensors/ssp.h +++ b/drivers/iio/common/ssp_sensors/ssp.h @@ -7,7 +7,7 @@ #define __SSP_SENSORHUB_H__ #include -#include +#include #include #include #include @@ -168,9 +168,9 @@ struct ssp_sensorhub_info { * @fw_dl_state: firmware download state * @comm_lock: lock protecting the handshake * @pending_lock: lock protecting pending list and completion - * @mcu_reset_gpio: mcu reset line - * @ap_mcu_gpio: ap to mcu gpio line - * @mcu_ap_gpio: mcu to ap gpio line + * @mcu_reset_gpiod: mcu reset line + * @ap_mcu_gpiod: ap to mcu gpio line + * @mcu_ap_gpiod: mcu to ap gpio line * @pending_list: pending list for messages queued to be sent/read * @sensor_devs: registered IIO devices table * @enable_refcount: enable reference count for wdt (watchdog timer) @@ -212,9 +212,9 @@ struct ssp_data { struct mutex comm_lock; struct mutex pending_lock; - int mcu_reset_gpio; - int ap_mcu_gpio; - int mcu_ap_gpio; + struct gpio_desc *mcu_reset_gpiod; + struct gpio_desc *ap_mcu_gpiod; + struct gpio_desc *mcu_ap_gpiod; struct list_head pending_list; diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c index 9c70553994c6..a94dbcf491ce 100644 --- a/drivers/iio/common/ssp_sensors/ssp_dev.c +++ b/drivers/iio/common/ssp_sensors/ssp_dev.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "ssp.h" @@ -61,9 +60,9 @@ static const struct mfd_cell sensorhub_sensor_devs[] = { static void ssp_toggle_mcu_reset_gpio(struct ssp_data *data) { - gpio_set_value(data->mcu_reset_gpio, 0); + gpiod_set_value(data->mcu_reset_gpiod, 0); usleep_range(1000, 1200); - gpio_set_value(data->mcu_reset_gpio, 1); + gpiod_set_value(data->mcu_reset_gpiod, 1); msleep(50); } @@ -441,7 +440,6 @@ MODULE_DEVICE_TABLE(of, ssp_of_match); static struct ssp_data *ssp_parse_dt(struct device *dev) { - int ret; struct ssp_data *data; struct device_node *node = dev->of_node; const struct of_device_id *match; @@ -450,26 +448,17 @@ static struct ssp_data *ssp_parse_dt(struct device *dev) if (!data) return NULL; - data->mcu_ap_gpio = of_get_named_gpio(node, "mcu-ap-gpios", 0); - if (data->mcu_ap_gpio < 0) - return NULL; - - data->ap_mcu_gpio = of_get_named_gpio(node, "ap-mcu-gpios", 0); - if (data->ap_mcu_gpio < 0) - return NULL; - - data->mcu_reset_gpio = of_get_named_gpio(node, "mcu-reset-gpios", 0); - if (data->mcu_reset_gpio < 0) + data->mcu_ap_gpiod = devm_gpiod_get(dev, "mcu-ap", GPIOD_IN); + if (IS_ERR(data->mcu_ap_gpiod)) return NULL; - ret = devm_gpio_request_one(dev, data->ap_mcu_gpio, GPIOF_OUT_INIT_HIGH, - "ap-mcu-gpios"); - if (ret) + data->ap_mcu_gpiod = devm_gpiod_get(dev, "ap-mcu", GPIOD_OUT_HIGH); + if (IS_ERR(data->ap_mcu_gpiod)) return NULL; - ret = devm_gpio_request_one(dev, data->mcu_reset_gpio, - GPIOF_OUT_INIT_HIGH, "mcu-reset-gpios"); - if (ret) + data->mcu_reset_gpiod = devm_gpiod_get(dev, "mcu-reset", + GPIOD_OUT_HIGH); + if (IS_ERR(data->mcu_reset_gpiod)) return NULL; match = of_match_node(ssp_of_match, node); diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c index 7db3d5886e3e..4864c38b8d1c 100644 --- a/drivers/iio/common/ssp_sensors/ssp_spi.c +++ b/drivers/iio/common/ssp_sensors/ssp_spi.c @@ -155,9 +155,9 @@ static int ssp_check_lines(struct ssp_data *data, bool state) { int delay_cnt = 0; - gpio_set_value_cansleep(data->ap_mcu_gpio, state); + gpiod_set_value_cansleep(data->ap_mcu_gpiod, state); - while (gpio_get_value_cansleep(data->mcu_ap_gpio) != state) { + while (gpiod_get_value_cansleep(data->mcu_ap_gpiod) != state) { usleep_range(3000, 3500); if (data->shut_down || delay_cnt++ > 500) { @@ -165,7 +165,7 @@ static int ssp_check_lines(struct ssp_data *data, bool state) __func__, state); if (!state) - gpio_set_value_cansleep(data->ap_mcu_gpio, 1); + gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1); return -ETIMEDOUT; } @@ -197,7 +197,7 @@ static int ssp_do_transfer(struct ssp_data *data, struct ssp_msg *msg, status = spi_write(data->spi, msg->buffer, SSP_HEADER_SIZE); if (status < 0) { - gpio_set_value_cansleep(data->ap_mcu_gpio, 1); + gpiod_set_value_cansleep(data->ap_mcu_gpiod, 1); dev_err(SSP_DEV, "%s spi_write fail\n", __func__); goto _error_locked; } -- cgit v1.2.3 From de54fff151335d0c24f53ff843c67a1364f70f42 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 16 Dec 2019 19:38:51 +0200 Subject: iio: st_sensors: Describe function parameters in kernel-doc 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 Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_trigger.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/iio/common') diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index 4a2efa00f7f2..e817537cdfb5 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c @@ -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 -- cgit v1.2.3 From efc78983d21aeaf692006d42b92a006cdce3ed4d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 16 Dec 2019 19:38:52 +0200 Subject: iio: st_sensors: Drop redundant parameter from st_sensors_of_name_probe() 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 Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_spi.c | 3 +- drivers/iio/common/st_sensors/st_sensors_core.c | 38 +++++++++++-------------- drivers/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(-) (limited to 'drivers/iio/common') diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 8af7027d5598..3e25268638e2 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -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) { diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 4a3064fb6cd9..42a71a50650f 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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) diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index aa89d54a7c59..286830fb5d35 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include @@ -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 "); MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 05a1a0874bd5..bc0010835ac0 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -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) { diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index b5c624251231..07224d5bf299 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -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) { diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index fdba480a12be..bf63777bbc6e 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -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) { diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index fbf909bde841..78f846fc120e 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -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) { diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 6203bc9d5c2d..dd1f515ca1f1 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -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) { diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 7c8b70221e70..dd31241bf4b4 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -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) { diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 686be532f4cb..33e939977444 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -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 */ diff --git a/include/linux/iio/common/st_sensors_i2c.h b/include/linux/iio/common/st_sensors_i2c.h index 01e424e2af4f..5f15cf01036c 100644 --- a/include/linux/iio/common/st_sensors_i2c.h +++ b/include/linux/iio/common/st_sensors_i2c.h @@ -12,18 +12,8 @@ #include #include -#include 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 */ -- cgit v1.2.3 From ecb27c5e430785018199dd42e566711022d32523 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 16 Dec 2019 19:38:53 +0200 Subject: iio: st_sensors: Make use of device properties 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 Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_i2c.c | 6 +----- drivers/iio/accel/st_accel_spi.c | 6 +----- drivers/iio/common/st_sensors/st_sensors_core.c | 21 +++++---------------- drivers/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(-) (limited to 'drivers/iio/common') diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 0f4aef5448e7..633955d764cc 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -18,7 +18,6 @@ #include #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, diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 3e25268638e2..568ff1bae0ee 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -17,7 +17,6 @@ #include #include "st_accel.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use as compatible string. * For old single-chip devices keep -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, diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 42a71a50650f..e051edbc43c1 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include #include @@ -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; diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c index 2262f81b07c2..1275fb0eda31 100644 --- a/drivers/iio/common/st_sensors/st_sensors_spi.c +++ b/drivers/iio/common/st_sensors/st_sensors_spi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -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; } diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index bc0010835ac0..8190966e6ff0 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -17,7 +17,6 @@ #include #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, diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index 07224d5bf299..efb862763ca3 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -17,7 +17,6 @@ #include #include "st_gyro.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use as compatible string. * For old single-chip devices keep -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, diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index bf63777bbc6e..c6bb4ce77594 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -17,7 +17,6 @@ #include #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, diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 78f846fc120e..3d08d74c367d 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -17,7 +17,6 @@ #include #include "st_magn.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use as compatible string. * For old single-chip devices keep -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, diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index dd1f515ca1f1..09c6903f99b8 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -17,7 +17,6 @@ #include #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, diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index dd31241bf4b4..b5ee3ec2764f 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -17,7 +17,6 @@ #include #include "st_pressure.h" -#ifdef CONFIG_OF /* * For new single-chip sensors use as compatible string. * For old single-chip devices keep -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, -- cgit v1.2.3