mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8960: Fix error handling in probe
@ 2023-09-09 12:02 Guenter Roeck
  2023-09-09 12:33 ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guenter Roeck @ 2023-09-09 12:02 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, patches, alsa-devel,
	linux-kernel, Guenter Roeck, Fabio Estevam, Charles Keepax

Commit 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
added regulator support to the wm8960 driver, but neglected to update
error handling in the probe function. This results in warning backtraces
if the probe function fails.

WARNING: CPU: 0 PID: 1 at drivers/regulator/core.c:2396 _regulator_put.part.0+0x1b4/0x1d8
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G                 N 6.5.0-11075-g92901222f83d #1
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x68/0x90
 dump_stack_lvl from __warn+0x70/0x1a4
 __warn from warn_slowpath_fmt+0xac/0x220
 warn_slowpath_fmt from _regulator_put.part.0+0x1b4/0x1d8
 _regulator_put.part.0 from regulator_bulk_free+0x44/0x64
 regulator_bulk_free from release_nodes+0x50/0x7c
 release_nodes from devres_release_group+0xbc/0x138
 devres_release_group from i2c_device_probe+0x180/0x268
 i2c_device_probe from really_probe+0xc4/0x2e0
 really_probe from __driver_probe_device+0x84/0x1a0
 __driver_probe_device from driver_probe_device+0x2c/0xc4
 driver_probe_device from __driver_attach+0x94/0x144
 __driver_attach from bus_for_each_dev+0x70/0xc4
 bus_for_each_dev from bus_add_driver+0xc4/0x1cc
 bus_add_driver from driver_register+0x7c/0x114
 driver_register from i2c_register_driver+0x3c/0xac
 i2c_register_driver from do_one_initcall+0x68/0x3b0
 do_one_initcall from kernel_init_freeable+0x18c/0x240
 kernel_init_freeable from kernel_init+0x14/0x144
 kernel_init from ret_from_fork+0x14/0x24

Add the missing calls to regulator_bulk_disable().

Cc: Fabio Estevam <festevam@denx.de>
Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
Fixes: 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 sound/soc/codecs/wm8960.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 0a50180750e8..7689fe3cc86d 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -1468,8 +1468,10 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
 	}
 
 	wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap);
-	if (IS_ERR(wm8960->regmap))
-		return PTR_ERR(wm8960->regmap);
+	if (IS_ERR(wm8960->regmap)) {
+		ret = PTR_ERR(wm8960->regmap);
+		goto bulk_disable;
+	}
 
 	if (pdata)
 		memcpy(&wm8960->pdata, pdata, sizeof(struct wm8960_data));
@@ -1479,13 +1481,14 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
 	ret = i2c_master_recv(i2c, &val, sizeof(val));
 	if (ret >= 0) {
 		dev_err(&i2c->dev, "Not wm8960, wm8960 reg can not read by i2c\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto bulk_disable;
 	}
 
 	ret = wm8960_reset(wm8960->regmap);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to issue reset\n");
-		return ret;
+		goto bulk_disable;
 	}
 
 	if (wm8960->pdata.shared_lrclk) {
@@ -1494,7 +1497,7 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
 		if (ret != 0) {
 			dev_err(&i2c->dev, "Failed to enable LRCM: %d\n",
 				ret);
-			return ret;
+			goto bulk_disable;
 		}
 	}
 
@@ -1528,7 +1531,13 @@ static int wm8960_i2c_probe(struct i2c_client *i2c)
 
 	ret = devm_snd_soc_register_component(&i2c->dev,
 			&soc_component_dev_wm8960, &wm8960_dai, 1);
+	if (ret)
+		goto bulk_disable;
 
+	return 0;
+
+bulk_disable:
+	regulator_bulk_disable(ARRAY_SIZE(wm8960->supplies), wm8960->supplies);
 	return ret;
 }
 
-- 
2.39.2


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

* Re: [PATCH] ASoC: wm8960: Fix error handling in probe
  2023-09-09 12:02 [PATCH] ASoC: wm8960: Fix error handling in probe Guenter Roeck
@ 2023-09-09 12:33 ` Fabio Estevam
  2023-09-09 12:42 ` Mark Brown
  2023-09-11 15:07 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2023-09-09 12:33 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	patches, alsa-devel, linux-kernel, Charles Keepax, Guenter Roeck

On 09/09/2023 09:02, Guenter Roeck wrote:
> Commit 422f10adc3eb ("ASoC: wm8960: Add support for the power 
> supplies")
> added regulator support to the wm8960 driver, but neglected to update
> error handling in the probe function. This results in warning 
> backtraces
> if the probe function fails.
> 
> WARNING: CPU: 0 PID: 1 at drivers/regulator/core.c:2396
> _regulator_put.part.0+0x1b4/0x1d8
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Tainted: G                 N
> 6.5.0-11075-g92901222f83d #1
> Hardware name: Freescale i.MX6 Ultralite (Device Tree)
>  unwind_backtrace from show_stack+0x10/0x14
>  show_stack from dump_stack_lvl+0x68/0x90
>  dump_stack_lvl from __warn+0x70/0x1a4
>  __warn from warn_slowpath_fmt+0xac/0x220
>  warn_slowpath_fmt from _regulator_put.part.0+0x1b4/0x1d8
>  _regulator_put.part.0 from regulator_bulk_free+0x44/0x64
>  regulator_bulk_free from release_nodes+0x50/0x7c
>  release_nodes from devres_release_group+0xbc/0x138
>  devres_release_group from i2c_device_probe+0x180/0x268
>  i2c_device_probe from really_probe+0xc4/0x2e0
>  really_probe from __driver_probe_device+0x84/0x1a0
>  __driver_probe_device from driver_probe_device+0x2c/0xc4
>  driver_probe_device from __driver_attach+0x94/0x144
>  __driver_attach from bus_for_each_dev+0x70/0xc4
>  bus_for_each_dev from bus_add_driver+0xc4/0x1cc
>  bus_add_driver from driver_register+0x7c/0x114
>  driver_register from i2c_register_driver+0x3c/0xac
>  i2c_register_driver from do_one_initcall+0x68/0x3b0
>  do_one_initcall from kernel_init_freeable+0x18c/0x240
>  kernel_init_freeable from kernel_init+0x14/0x144
>  kernel_init from ret_from_fork+0x14/0x24
> 
> Add the missing calls to regulator_bulk_disable().
> 
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
> Fixes: 422f10adc3eb ("ASoC: wm8960: Add support for the power 
> supplies")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Thanks for the fix:

Reviewed-by: Fabio Estevam <festevam@denx.de>

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

* Re: [PATCH] ASoC: wm8960: Fix error handling in probe
  2023-09-09 12:02 [PATCH] ASoC: wm8960: Fix error handling in probe Guenter Roeck
  2023-09-09 12:33 ` Fabio Estevam
@ 2023-09-09 12:42 ` Mark Brown
  2023-09-11 15:07 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-09-09 12:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches,
	alsa-devel, linux-kernel, Fabio Estevam, Charles Keepax

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

On Sat, Sep 09, 2023 at 05:02:37AM -0700, Guenter Roeck wrote:
> Commit 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
> added regulator support to the wm8960 driver, but neglected to update
> error handling in the probe function. This results in warning backtraces
> if the probe function fails.
> 
> WARNING: CPU: 0 PID: 1 at drivers/regulator/core.c:2396 _regulator_put.part.0+0x1b4/0x1d8
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Tainted: G                 N 6.5.0-11075-g92901222f83d #1
> Hardware name: Freescale i.MX6 Ultralite (Device Tree)
>  unwind_backtrace from show_stack+0x10/0x14
>  show_stack from dump_stack_lvl+0x68/0x90
>  dump_stack_lvl from __warn+0x70/0x1a4

Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative (it often is
for search engines if nothing else) then it's usually better to pull out
the relevant sections.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: wm8960: Fix error handling in probe
  2023-09-09 12:02 [PATCH] ASoC: wm8960: Fix error handling in probe Guenter Roeck
  2023-09-09 12:33 ` Fabio Estevam
  2023-09-09 12:42 ` Mark Brown
@ 2023-09-11 15:07 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-09-11 15:07 UTC (permalink / raw)
  To: Liam Girdwood, Guenter Roeck
  Cc: Jaroslav Kysela, Takashi Iwai, patches, alsa-devel, linux-kernel,
	Fabio Estevam, Charles Keepax

On Sat, 09 Sep 2023 05:02:37 -0700, Guenter Roeck wrote:
> Commit 422f10adc3eb ("ASoC: wm8960: Add support for the power supplies")
> added regulator support to the wm8960 driver, but neglected to update
> error handling in the probe function. This results in warning backtraces
> if the probe function fails.
> 
> WARNING: CPU: 0 PID: 1 at drivers/regulator/core.c:2396 _regulator_put.part.0+0x1b4/0x1d8
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Tainted: G                 N 6.5.0-11075-g92901222f83d #1
> Hardware name: Freescale i.MX6 Ultralite (Device Tree)
>  unwind_backtrace from show_stack+0x10/0x14
>  show_stack from dump_stack_lvl+0x68/0x90
>  dump_stack_lvl from __warn+0x70/0x1a4
>  __warn from warn_slowpath_fmt+0xac/0x220
>  warn_slowpath_fmt from _regulator_put.part.0+0x1b4/0x1d8
>  _regulator_put.part.0 from regulator_bulk_free+0x44/0x64
>  regulator_bulk_free from release_nodes+0x50/0x7c
>  release_nodes from devres_release_group+0xbc/0x138
>  devres_release_group from i2c_device_probe+0x180/0x268
>  i2c_device_probe from really_probe+0xc4/0x2e0
>  really_probe from __driver_probe_device+0x84/0x1a0
>  __driver_probe_device from driver_probe_device+0x2c/0xc4
>  driver_probe_device from __driver_attach+0x94/0x144
>  __driver_attach from bus_for_each_dev+0x70/0xc4
>  bus_for_each_dev from bus_add_driver+0xc4/0x1cc
>  bus_add_driver from driver_register+0x7c/0x114
>  driver_register from i2c_register_driver+0x3c/0xac
>  i2c_register_driver from do_one_initcall+0x68/0x3b0
>  do_one_initcall from kernel_init_freeable+0x18c/0x240
>  kernel_init_freeable from kernel_init+0x14/0x144
>  kernel_init from ret_from_fork+0x14/0x24
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: wm8960: Fix error handling in probe
      commit: d7e47e32192bb88f5b2dc8e655fa587ecf9d71e0

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] 4+ messages in thread

end of thread, other threads:[~2023-09-11 21:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-09 12:02 [PATCH] ASoC: wm8960: Fix error handling in probe Guenter Roeck
2023-09-09 12:33 ` Fabio Estevam
2023-09-09 12:42 ` Mark Brown
2023-09-11 15:07 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®