Linux IIO development
 help / color / mirror / Atom feed
From: Zheyu Ma <zheyuma97@gmail.com>
To: jic23@kernel.org, lars@metafoo.de
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zheyu Ma <zheyuma97@gmail.com>
Subject: [PATCH] iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on()
Date: Sat,  9 Apr 2022 11:48:49 +0800	[thread overview]
Message-ID: <20220409034849.3717231-2-zheyuma97@gmail.com> (raw)
In-Reply-To: <20220409034849.3717231-1-zheyuma97@gmail.com>

When the driver fails to enable the regulator 'vid', we will get the
following splat:

[   79.955610] WARNING: CPU: 5 PID: 441 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   79.959641] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   79.967570] Call Trace:
[   79.967773]  <TASK>
[   79.967951]  regulator_put+0x1f/0x30
[   79.968254]  devres_release_group+0x319/0x3d0
[   79.968608]  i2c_device_probe+0x766/0x940

Fix this by disabling the 'vdd' regulator when failing to enable 'vid'
regulator.

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

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 088f748b683e..2432e697150c 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -416,6 +416,7 @@ static int ak8975_power_on(const struct ak8975_data *data)
 	if (ret) {
 		dev_warn(&data->client->dev,
 			 "Failed to enable specified Vid supply\n");
+		regulator_disable(data->vdd);
 		return ret;
 	}
 
-- 
2.25.1


  reply	other threads:[~2022-04-09  3:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09  3:48 [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe() Zheyu Ma
2022-04-09  3:48 ` Zheyu Ma [this message]
2022-04-10 16:01   ` [PATCH] iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on() Jonathan Cameron
2022-04-11  5:57     ` Zheyu Ma
2022-04-10 15:54 ` [PATCH] iio: magnetometer: ak8974: Fix the error handling of ak8974_probe() Jonathan Cameron
2022-04-20 23:14   ` Linus Walleij
2022-04-21 14:07     ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220409034849.3717231-2-zheyuma97@gmail.com \
    --to=zheyuma97@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox