]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: st_sensors: disable regulators after device unregistration
authorAlexandru Ardelean <aardelean@deviqon.com>
Mon, 23 Aug 2021 11:22:00 +0000 (14:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Nov 2021 10:04:20 +0000 (11:04 +0100)
[ Upstream commit 9f0b3e0cc0c88618aa9e5cecef747b1337ae0a5d ]

Up until commit ea7e586bdd331 ("iio: st_sensors: move regulator retrieveal
to core") only the ST pressure driver seems to have had any regulator
disable. After that commit, the regulator handling was moved into the
common st_sensors logic.

In all instances of this regulator handling, the regulators were disabled
before unregistering the IIO device.
This can cause issues where the device would be powered down and still be
available to userspace, allowing it to send invalid/garbage data.

This change moves the st_sensors_power_disable() after the common probe
functions. These common probe functions also handle unregistering the IIO
device.

Fixes: 774487611c949 ("iio: pressure-core: st: Provide support for the Vdd power supply")
Fixes: ea7e586bdd331 ("iio: st_sensors: move regulator retrieveal to core")
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Denis CIOCCA <denis.ciocca@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210823112204.243255-2-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/accel/st_accel_i2c.c
drivers/iio/accel/st_accel_spi.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

index 95e305b88d5edb4b4c22326cdcafec08ab39da08..02c823b93ecd498d3f6a17022735cf6466558bbb 100644 (file)
@@ -194,10 +194,10 @@ static int st_accel_i2c_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-       st_sensors_power_disable(indio_dev);
-
        st_accel_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index 83d3308ce5ccc395e61f3ee89d6b8d3924928473..386ae18d5f2692e74d20703bd447047101963527 100644 (file)
@@ -143,10 +143,10 @@ static int st_accel_spi_remove(struct spi_device *spi)
 {
        struct iio_dev *indio_dev = spi_get_drvdata(spi);
 
-       st_sensors_power_disable(indio_dev);
-
        st_accel_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index a25cc0379e16313cf24790cefcc6614f5b1f3974..3ed577977946528b9abba233eed01c5d6f56ec36 100644 (file)
@@ -106,10 +106,10 @@ static int st_gyro_i2c_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-       st_sensors_power_disable(indio_dev);
-
        st_gyro_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index 18d6a2aeda45a6d0868d62f4f32dfdb05f9cf0c1..c04bcf2518c1188ab89020022b90ad2c97004346 100644 (file)
@@ -110,10 +110,10 @@ static int st_gyro_spi_remove(struct spi_device *spi)
 {
        struct iio_dev *indio_dev = spi_get_drvdata(spi);
 
-       st_sensors_power_disable(indio_dev);
-
        st_gyro_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index 3e23c117de8e1ef4cc342b1274dbed872af6707f..6c93df6926a30a15cb2a5f07e0f617e2e09649d5 100644 (file)
@@ -102,10 +102,10 @@ static int st_magn_i2c_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-       st_sensors_power_disable(indio_dev);
-
        st_magn_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index 03c0a737aba6e72c7311a4ffeb6815f861baa3d6..4f52c3a21e3c27ebca7323e6bf565f0777da4a7f 100644 (file)
@@ -96,10 +96,10 @@ static int st_magn_spi_remove(struct spi_device *spi)
 {
        struct iio_dev *indio_dev = spi_get_drvdata(spi);
 
-       st_sensors_power_disable(indio_dev);
-
        st_magn_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index f0a5af314ceb8e49bb7485220ec895c7ebd9f656..8c26ff61e56addfff6fa891ab8cce1a113d50a8e 100644 (file)
@@ -118,10 +118,10 @@ static int st_press_i2c_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-       st_sensors_power_disable(indio_dev);
-
        st_press_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }
 
index b48cf7d01cd74bef16f603ba4ea618d27b3750ba..8cf8cd3b4554a06e963b46be618ac74f34bdf743 100644 (file)
@@ -102,10 +102,10 @@ static int st_press_spi_remove(struct spi_device *spi)
 {
        struct iio_dev *indio_dev = spi_get_drvdata(spi);
 
-       st_sensors_power_disable(indio_dev);
-
        st_press_common_remove(indio_dev);
 
+       st_sensors_power_disable(indio_dev);
+
        return 0;
 }