summaryrefslogtreecommitdiff
path: root/drivers/iio/accel/st_accel_spi.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-04-14 22:54:51 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-05-17 15:54:22 +0300
commit7db4f2cacbede1c6d95552c0d10e77398665a733 (patch)
tree94383e724d0c97850380c3475c864a19361188d0 /drivers/iio/accel/st_accel_spi.c
parent38934daf7b5c1b35a01748cb7d4272282cc3a890 (diff)
downloadlinux-7db4f2cacbede1c6d95552c0d10e77398665a733.tar.xz
iio: st_sensors: Call st_sensors_power_enable() from bus drivers
In case we would initialize two IIO devices from one physical device, we shouldn't have a clash on regulators. That's why move st_sensors_power_enable() call from core to bus drivers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20210414195454.84183-4-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/accel/st_accel_spi.c')
-rw-r--r--drivers/iio/accel/st_accel_spi.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 568ff1bae0ee..83d3308ce5cc 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -123,16 +123,29 @@ static int st_accel_spi_probe(struct spi_device *spi)
if (err < 0)
return err;
+ err = st_sensors_power_enable(indio_dev);
+ if (err)
+ return err;
+
err = st_accel_common_probe(indio_dev);
if (err < 0)
- return err;
+ goto st_accel_power_off;
return 0;
+
+st_accel_power_off:
+ st_sensors_power_disable(indio_dev);
+
+ return err;
}
static int st_accel_spi_remove(struct spi_device *spi)
{
- st_accel_common_remove(spi_get_drvdata(spi));
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
+
+ st_sensors_power_disable(indio_dev);
+
+ st_accel_common_remove(indio_dev);
return 0;
}