All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8731: Disable the regulator when probing fails
@ 2022-04-05 12:10 ` Zheyu Ma
  0 siblings, 0 replies; 8+ messages in thread
From: Zheyu Ma @ 2022-04-05 12:10 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai
  Cc: patches, alsa-devel, linux-kernel, Zheyu Ma

When the driver fails during probing, the driver should disable the
regulator, not just handle it in wm8731_hw_init().

The following log reveals it:

[   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   17.824467] Call Trace:
[   17.824774]  <TASK>
[   17.825040]  regulator_bulk_free+0x82/0xe0
[   17.825514]  devres_release_group+0x319/0x3d0
[   17.825882]  i2c_device_probe+0x766/0x940
[   17.829198]  i2c_register_driver+0xb5/0x130

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 sound/soc/codecs/wm8731.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 5d4949c2ec9b..b14c6d104e6d 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -602,7 +602,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
 	ret = wm8731_reset(wm8731->regmap);
 	if (ret < 0) {
 		dev_err(dev, "Failed to issue reset: %d\n", ret);
-		goto err_regulator_enable;
+		goto err;
 	}
 
 	/* Clear POWEROFF, keep everything else disabled */
@@ -619,10 +619,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
 
 	regcache_mark_dirty(wm8731->regmap);
 
-err_regulator_enable:
-	/* Regulators will be enabled by bias management */
-	regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
+err:
 	return ret;
 }
 
@@ -760,21 +757,27 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
 		ret = PTR_ERR(wm8731->regmap);
 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
 			ret);
-		return ret;
+		goto err_regulator_enable;
 	}
 
 	ret = wm8731_hw_init(&i2c->dev, wm8731);
 	if (ret != 0)
-		return ret;
+		goto err_regulator_enable;
 
 	ret = devm_snd_soc_register_component(&i2c->dev,
 			&soc_component_dev_wm8731, &wm8731_dai, 1);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
-		return ret;
+		goto err_regulator_enable;
 	}
 
 	return 0;
+
+err_regulator_enable:
+	/* Regulators will be enabled by bias management */
+	regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
+
+	return ret;
 }
 
 static const struct i2c_device_id wm8731_i2c_id[] = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] ASoC: wm8731: Disable the regulator when probing fails
@ 2022-04-05 12:10 ` Zheyu Ma
  0 siblings, 0 replies; 8+ messages in thread
From: Zheyu Ma @ 2022-04-05 12:10 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai
  Cc: patches, alsa-devel, Zheyu Ma, linux-kernel

When the driver fails during probing, the driver should disable the
regulator, not just handle it in wm8731_hw_init().

The following log reveals it:

[   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   17.824467] Call Trace:
[   17.824774]  <TASK>
[   17.825040]  regulator_bulk_free+0x82/0xe0
[   17.825514]  devres_release_group+0x319/0x3d0
[   17.825882]  i2c_device_probe+0x766/0x940
[   17.829198]  i2c_register_driver+0xb5/0x130

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 sound/soc/codecs/wm8731.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 5d4949c2ec9b..b14c6d104e6d 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -602,7 +602,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
 	ret = wm8731_reset(wm8731->regmap);
 	if (ret < 0) {
 		dev_err(dev, "Failed to issue reset: %d\n", ret);
-		goto err_regulator_enable;
+		goto err;
 	}
 
 	/* Clear POWEROFF, keep everything else disabled */
@@ -619,10 +619,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731)
 
 	regcache_mark_dirty(wm8731->regmap);
 
-err_regulator_enable:
-	/* Regulators will be enabled by bias management */
-	regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
-
+err:
 	return ret;
 }
 
@@ -760,21 +757,27 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
 		ret = PTR_ERR(wm8731->regmap);
 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
 			ret);
-		return ret;
+		goto err_regulator_enable;
 	}
 
 	ret = wm8731_hw_init(&i2c->dev, wm8731);
 	if (ret != 0)
-		return ret;
+		goto err_regulator_enable;
 
 	ret = devm_snd_soc_register_component(&i2c->dev,
 			&soc_component_dev_wm8731, &wm8731_dai, 1);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
-		return ret;
+		goto err_regulator_enable;
 	}
 
 	return 0;
+
+err_regulator_enable:
+	/* Regulators will be enabled by bias management */
+	regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);
+
+	return ret;
 }
 
 static const struct i2c_device_id wm8731_i2c_id[] = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
  2022-04-05 12:10 ` Zheyu Ma
@ 2022-04-06 10:01   ` Charles Keepax
  -1 siblings, 0 replies; 8+ messages in thread
From: Charles Keepax @ 2022-04-06 10:01 UTC (permalink / raw)
  To: Zheyu Ma; +Cc: alsa-devel, patches, tiwai, lgirdwood, broonie, linux-kernel

On Tue, Apr 05, 2022 at 08:10:38PM +0800, Zheyu Ma wrote:
> When the driver fails during probing, the driver should disable the
> regulator, not just handle it in wm8731_hw_init().
> 
> The following log reveals it:
> 
> [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [   17.824467] Call Trace:
> [   17.824774]  <TASK>
> [   17.825040]  regulator_bulk_free+0x82/0xe0
> [   17.825514]  devres_release_group+0x319/0x3d0
> [   17.825882]  i2c_device_probe+0x766/0x940
> [   17.829198]  i2c_register_driver+0xb5/0x130
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---

Mark just merged a big chain overhauling a lot of this driver, at
the very least this patch is going to require a rebase on top of
that lot.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
@ 2022-04-06 10:01   ` Charles Keepax
  0 siblings, 0 replies; 8+ messages in thread
From: Charles Keepax @ 2022-04-06 10:01 UTC (permalink / raw)
  To: Zheyu Ma
  Cc: lgirdwood, broonie, perex, tiwai, patches, alsa-devel, linux-kernel

On Tue, Apr 05, 2022 at 08:10:38PM +0800, Zheyu Ma wrote:
> When the driver fails during probing, the driver should disable the
> regulator, not just handle it in wm8731_hw_init().
> 
> The following log reveals it:
> 
> [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [   17.824467] Call Trace:
> [   17.824774]  <TASK>
> [   17.825040]  regulator_bulk_free+0x82/0xe0
> [   17.825514]  devres_release_group+0x319/0x3d0
> [   17.825882]  i2c_device_probe+0x766/0x940
> [   17.829198]  i2c_register_driver+0xb5/0x130
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---

Mark just merged a big chain overhauling a lot of this driver, at
the very least this patch is going to require a rebase on top of
that lot.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
  2022-04-06 10:01   ` Charles Keepax
@ 2022-04-06 11:25     ` Zheyu Ma
  -1 siblings, 0 replies; 8+ messages in thread
From: Zheyu Ma @ 2022-04-06 11:25 UTC (permalink / raw)
  To: Charles Keepax
  Cc: lgirdwood, broonie, perex, tiwai, patches, alsa-devel,
	Linux Kernel Mailing List

Hi Charles,

On Wed, Apr 6, 2022 at 6:01 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
>
> On Tue, Apr 05, 2022 at 08:10:38PM +0800, Zheyu Ma wrote:
> > When the driver fails during probing, the driver should disable the
> > regulator, not just handle it in wm8731_hw_init().
> >
> > The following log reveals it:
> >
> > [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> > [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> > [   17.824467] Call Trace:
> > [   17.824774]  <TASK>
> > [   17.825040]  regulator_bulk_free+0x82/0xe0
> > [   17.825514]  devres_release_group+0x319/0x3d0
> > [   17.825882]  i2c_device_probe+0x766/0x940
> > [   17.829198]  i2c_register_driver+0xb5/0x130
> >
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> > ---
>
> Mark just merged a big chain overhauling a lot of this driver, at
> the very least this patch is going to require a rebase on top of
> that lot.

Thanks for your reminder, this bug has been fixed in the latest code.

Regards,
Zheyu Ma

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
@ 2022-04-06 11:25     ` Zheyu Ma
  0 siblings, 0 replies; 8+ messages in thread
From: Zheyu Ma @ 2022-04-06 11:25 UTC (permalink / raw)
  To: Charles Keepax
  Cc: alsa-devel, patches, tiwai, lgirdwood, broonie,
	Linux Kernel Mailing List

Hi Charles,

On Wed, Apr 6, 2022 at 6:01 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
>
> On Tue, Apr 05, 2022 at 08:10:38PM +0800, Zheyu Ma wrote:
> > When the driver fails during probing, the driver should disable the
> > regulator, not just handle it in wm8731_hw_init().
> >
> > The following log reveals it:
> >
> > [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> > [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> > [   17.824467] Call Trace:
> > [   17.824774]  <TASK>
> > [   17.825040]  regulator_bulk_free+0x82/0xe0
> > [   17.825514]  devres_release_group+0x319/0x3d0
> > [   17.825882]  i2c_device_probe+0x766/0x940
> > [   17.829198]  i2c_register_driver+0xb5/0x130
> >
> > Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> > ---
>
> Mark just merged a big chain overhauling a lot of this driver, at
> the very least this patch is going to require a rebase on top of
> that lot.

Thanks for your reminder, this bug has been fixed in the latest code.

Regards,
Zheyu Ma

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
  2022-04-05 12:10 ` Zheyu Ma
@ 2022-04-08 11:24   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-04-08 11:24 UTC (permalink / raw)
  To: perex, zheyuma97, tiwai, lgirdwood; +Cc: patches, linux-kernel, alsa-devel

On Tue, 5 Apr 2022 20:10:38 +0800, Zheyu Ma wrote:
> When the driver fails during probing, the driver should disable the
> regulator, not just handle it in wm8731_hw_init().
> 
> The following log reveals it:
> 
> [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [   17.824467] Call Trace:
> [   17.824774]  <TASK>
> [   17.825040]  regulator_bulk_free+0x82/0xe0
> [   17.825514]  devres_release_group+0x319/0x3d0
> [   17.825882]  i2c_device_probe+0x766/0x940
> [   17.829198]  i2c_register_driver+0xb5/0x130
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: wm8731: Disable the regulator when probing fails
      commit: 92ccbf17eeacf510cf1eed9c252d9332ca24f02d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ASoC: wm8731: Disable the regulator when probing fails
@ 2022-04-08 11:24   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-04-08 11:24 UTC (permalink / raw)
  To: perex, zheyuma97, tiwai, lgirdwood; +Cc: patches, alsa-devel, linux-kernel

On Tue, 5 Apr 2022 20:10:38 +0800, Zheyu Ma wrote:
> When the driver fails during probing, the driver should disable the
> regulator, not just handle it in wm8731_hw_init().
> 
> The following log reveals it:
> 
> [   17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
> [   17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0
> [   17.824467] Call Trace:
> [   17.824774]  <TASK>
> [   17.825040]  regulator_bulk_free+0x82/0xe0
> [   17.825514]  devres_release_group+0x319/0x3d0
> [   17.825882]  i2c_device_probe+0x766/0x940
> [   17.829198]  i2c_register_driver+0xb5/0x130
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: wm8731: Disable the regulator when probing fails
      commit: 92ccbf17eeacf510cf1eed9c252d9332ca24f02d

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-08 11:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05 12:10 [PATCH] ASoC: wm8731: Disable the regulator when probing fails Zheyu Ma
2022-04-05 12:10 ` Zheyu Ma
2022-04-06 10:01 ` Charles Keepax
2022-04-06 10:01   ` Charles Keepax
2022-04-06 11:25   ` Zheyu Ma
2022-04-06 11:25     ` Zheyu Ma
2022-04-08 11:24 ` Mark Brown
2022-04-08 11:24   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.