summaryrefslogtreecommitdiff
path: root/drivers/iio/magnetometer/st_magn_spi.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-04-14 22:54:51 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-18 16:04:13 +0300
commitbfedc817769dc2361ac7c1a473ce5e3e7f789da5 (patch)
treef9728ed7659e5b5c0bb4e15c4857c222d42c29d3 /drivers/iio/magnetometer/st_magn_spi.c
parentf84c7a03d1ea9082e5ddd8d7d5605f35a4c7cb83 (diff)
downloadlinux-bfedc817769dc2361ac7c1a473ce5e3e7f789da5.tar.xz
iio: st_sensors: Call st_sensors_power_enable() from bus drivers
[ Upstream commit 7db4f2cacbede1c6d95552c0d10e77398665a733 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/iio/magnetometer/st_magn_spi.c')
-rw-r--r--drivers/iio/magnetometer/st_magn_spi.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
index 3d08d74c367d..ee352f083c02 100644
--- a/drivers/iio/magnetometer/st_magn_spi.c
+++ b/drivers/iio/magnetometer/st_magn_spi.c
@@ -72,16 +72,28 @@ static int st_magn_spi_probe(struct spi_device *spi)
if (err < 0)
return err;
+ err = st_sensors_power_enable(indio_dev);
+ if (err)
+ return err;
+
err = st_magn_common_probe(indio_dev);
if (err < 0)
- return err;
+ goto st_magn_power_off;
return 0;
+
+st_magn_power_off:
+ st_sensors_power_disable(indio_dev);
+
+ return err;
}
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);
return 0;