diff options
| author | Petre Rodan | 2025-10-05 16:12:14 +0300 |
|---|---|---|
| committer | Jonathan Cameron | 2025-10-19 11:59:19 +0100 |
| commit | a9865410f4deec4db752941b87c8b387152aa103 (patch) | |
| tree | 286fef9e704ab85f609f43e382e9399949f14d27 /drivers/iio/accel | |
| parent | 5dbac275dcb909b281b9f68727aace0e350e3ab3 (diff) | |
iio: accel: bma220: move bma220_power function
Move bma220_power() before bma220_init() as a precursor to a
patch that removes code duplication.
Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/accel')
| -rw-r--r-- | drivers/iio/accel/bma220_spi.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index a5d2906321ae..45ac0d7ee27d 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -199,6 +199,31 @@ static const struct iio_info bma220_info = { .read_avail = bma220_read_avail, }; +static int bma220_power(struct spi_device *spi, bool up) +{ + int ret; + unsigned int i; + + /* + * The chip can be suspended/woken up by a simple register read. + * So, we need up to 2 register reads of the suspend register + * to make sure that the device is in the desired state. + */ + for (i = 0; i < 2; i++) { + ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret < 0) + return ret; + + if (up && ret == BMA220_SUSPEND_SLEEP) + return 0; + + if (!up && ret == BMA220_SUSPEND_WAKE) + return 0; + } + + return -EBUSY; +} + static int bma220_init(struct spi_device *spi) { int ret; @@ -224,30 +249,6 @@ static int bma220_init(struct spi_device *spi) return 0; } -static int bma220_power(struct spi_device *spi, bool up) -{ - int i, ret; - - /* - * The chip can be suspended/woken up by a simple register read. - * So, we need up to 2 register reads of the suspend register - * to make sure that the device is in the desired state. - */ - for (i = 0; i < 2; i++) { - ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); - if (ret < 0) - return ret; - - if (up && ret == BMA220_SUSPEND_SLEEP) - return 0; - - if (!up && ret == BMA220_SUSPEND_WAKE) - return 0; - } - - return -EBUSY; -} - static void bma220_deinit(void *spi) { bma220_power(spi, false); |
