diff mbox series

iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on()

Message ID 20220409034849.3717231-2-zheyuma97@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on() | expand

Commit Message

Zheyu Ma April 9, 2022, 3:48 a.m. UTC
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(+)

Comments

Jonathan Cameron April 10, 2022, 4:01 p.m. UTC | #1
On Sat,  9 Apr 2022 11:48:49 +0800
Zheyu Ma <zheyuma97@gmail.com> wrote:

> 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>
This driver doesn't really have a maintainer any more, though Linus W actually
last touched this bit of code. So +CC.

However, it's pretty obviously correct so applied to the fixes-togreg branch of iio.git.

For future reference, please don't send one fix as reply to a fix on a different driver.
Makes a mess of thread handling and tracking in patchwork etc.

Ideally also please provide a fixes tag.  For this one I have applied with out it
because it was a long time back and looks like the bug predates a bunch of refactoring
of this code.  

Applied to the fixes-togreg branch of iio.git and marked for stable.

Jonathan


> ---
>  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;
>  	}
>
Zheyu Ma April 11, 2022, 5:57 a.m. UTC | #2
On Sun, Apr 10, 2022 at 11:53 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sat,  9 Apr 2022 11:48:49 +0800
> Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> > 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>
> This driver doesn't really have a maintainer any more, though Linus W actually
> last touched this bit of code. So +CC.
>
> However, it's pretty obviously correct so applied to the fixes-togreg branch of iio.git.
>
> For future reference, please don't send one fix as reply to a fix on a different driver.
> Makes a mess of thread handling and tracking in patchwork etc.

Sorry for the confusion, I will take care of it next time.

> Ideally also please provide a fixes tag.  For this one I have applied with out it
> because it was a long time back and looks like the bug predates a bunch of refactoring
> of this code.

Thanks for your reminder, I will add the fixes tag in the next submission.

Regards,
Zheyu Ma
diff mbox series

Patch

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;
 	}