diff mbox series

iio: gyro: mpu3050: Fix the error handling in mpu3050_power_up()

Message ID 20220510092431.1711284-1-zheyuma97@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: gyro: mpu3050: Fix the error handling in mpu3050_power_up() | expand

Commit Message

Zheyu Ma May 10, 2022, 9:24 a.m. UTC
The driver should disable regulators when fails at regmap_update_bits().

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/iio/gyro/mpu3050-core.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Linus Walleij May 12, 2022, 10:08 p.m. UTC | #1
On Tue, May 10, 2022 at 11:24 AM Zheyu Ma <zheyuma97@gmail.com> wrote:

> The driver should disable regulators when fails at regmap_update_bits().
>
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>

Looks correct!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours.
Linus Walleij
Jonathan Cameron May 14, 2022, 3:58 p.m. UTC | #2
On Fri, 13 May 2022 00:08:37 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:

> On Tue, May 10, 2022 at 11:24 AM Zheyu Ma <zheyuma97@gmail.com> wrote:
> 
> > The driver should disable regulators when fails at regmap_update_bits().
> >
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>  
> 
> Looks correct!
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
I'm not going to rush this one in as

Applied to the fixes-togreg branch of iio.git and marked for stable
(I was a bit borderline in deciding on stable marking but meh, it's safe
enough as fixes go and real issue, even if one we are unlikely to hit)

Thanks,

Jonathan

> 
> Yours.
> Linus Walleij
diff mbox series

Patch

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index 4f19dc7ffe57..5908a96ca8af 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -875,6 +875,7 @@  static int mpu3050_power_up(struct mpu3050 *mpu3050)
 	ret = regmap_update_bits(mpu3050->map, MPU3050_PWR_MGM,
 				 MPU3050_PWR_MGM_SLEEP, 0);
 	if (ret) {
+		regulator_bulk_disable(ARRAY_SIZE(mpu3050->regs), mpu3050->regs);
 		dev_err(mpu3050->dev, "error setting power mode\n");
 		return ret;
 	}