iio: st_pressure: st_accel: pass correct platform data to init
authorMichael Nosthoff <committed@heine.so>
Fri, 9 Mar 2018 09:02:45 +0000 (10:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Mar 2018 16:39:19 +0000 (18:39 +0200)
commit 8b438686a001db64c21782d04ef68111e53c45d9 upstream.

Commit 7383d44b added a pointer pdata which get set to the default
platform_data when non was defined in the device. But it did not
pass this pointer to the st_sensors_init_sensor call but still
used the maybe uninitialized platform_data from dev.

This breaks initialization when no platform_data is given and
the optional st,drdy-int-pin devicetree option is not set.

This commit fixes this.

Cc: stable@vger.kernel.org
Fixes: 7383d44b ("iio: st_pressure: st_accel: Initialise sensor platform data properly")
Signed-off-by: Michael Nosthoff <committed@heine.so>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/accel/st_accel_core.c
drivers/iio/pressure/st_pressure_core.c

index fe94415a0bc7b95a2e05beef13ced01d7d951f78..32cd64c2ee0673c427efca09de3ee2451bda849e 100644 (file)
@@ -858,7 +858,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
        if (!pdata)
                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, pdata);
        if (err < 0)
                goto st_accel_power_off;
 
index bec60299b6ec6b7d8895228643a61784452b7ab6..3458418d88bc4aa5942029d70168c3d4a41f7ad3 100644 (file)
@@ -678,7 +678,7 @@ int st_press_common_probe(struct iio_dev *indio_dev)
        if (!pdata && press_data->sensor_settings->drdy_irq.addr)
                pdata = (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, pdata);
        if (err < 0)
                goto st_press_power_off;