提交 7383d44b 编写于 作者: S Shrirang Bagul 提交者: Jonathan Cameron

iio: st_pressure: st_accel: Initialise sensor platform data properly

This patch fixes the sensor platform data initialisation for st_pressure
and st_accel device drivers. Without this patch, the driver fails to
register the sensors when the user removes and re-loads the driver.

1. Unload the kernel modules for st_pressure
$ sudo rmmod st_pressure_i2c
$ sudo rmmod st_pressure

2. Re-load the driver
$ sudo insmod st_pressure
$ sudo insmod st_pressure_i2c
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
Acked-by: NLinus Walleij <linus.walleij@linaro.org>
上级 105c3de1
...@@ -710,6 +710,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { ...@@ -710,6 +710,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
int st_accel_common_probe(struct iio_dev *indio_dev) int st_accel_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *adata = iio_priv(indio_dev); struct st_sensor_data *adata = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata =
(struct st_sensors_platform_data *)adata->dev->platform_data;
int irq = adata->get_irq_data_ready(indio_dev); int irq = adata->get_irq_data_ready(indio_dev);
int err; int err;
...@@ -736,9 +738,8 @@ int st_accel_common_probe(struct iio_dev *indio_dev) ...@@ -736,9 +738,8 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
&adata->sensor_settings->fs.fs_avl[0]; &adata->sensor_settings->fs.fs_avl[0];
adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; adata->odr = adata->sensor_settings->odr.odr_avl[0].hz;
if (!adata->dev->platform_data) if (!pdata)
adata->dev->platform_data = pdata = (struct st_sensors_platform_data *)&default_accel_pdata;
(struct st_sensors_platform_data *)&default_accel_pdata;
err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data);
if (err < 0) if (err < 0)
......
...@@ -568,6 +568,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = { ...@@ -568,6 +568,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = {
int st_press_common_probe(struct iio_dev *indio_dev) int st_press_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *press_data = iio_priv(indio_dev); struct st_sensor_data *press_data = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata =
(struct st_sensors_platform_data *)press_data->dev->platform_data;
int irq = press_data->get_irq_data_ready(indio_dev); int irq = press_data->get_irq_data_ready(indio_dev);
int err; int err;
...@@ -603,10 +605,8 @@ int st_press_common_probe(struct iio_dev *indio_dev) ...@@ -603,10 +605,8 @@ int st_press_common_probe(struct iio_dev *indio_dev)
press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz;
/* Some devices don't support a data ready pin. */ /* Some devices don't support a data ready pin. */
if (!press_data->dev->platform_data && if (!pdata && press_data->sensor_settings->drdy_irq.addr)
press_data->sensor_settings->drdy_irq.addr) pdata = (struct st_sensors_platform_data *)&default_press_pdata;
press_data->dev->platform_data =
(struct st_sensors_platform_data *)&default_press_pdata;
err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data);
if (err < 0) if (err < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册