Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8993: Fix unbalanced regulator disables on remove
@ 2026-11-30 22:57 Arina Kharlamova via B4 Relay
  2026-12-02 10:44 ` Charles Keepax
  0 siblings, 1 reply; 2+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-11-30 22:57 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: Mark Brown, patches, linux-sound, Arina Kharlamova

From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>

The supplies are enabled during probe only to identify and reset the
device, and disabled again before the component is registered. After
that they are owned by wm8993_set_bias_level(), which enables them on
the OFF to STANDBY transition and disables them again in OFF.

wm8993_i2c_remove() still calls regulator_bulk_disable() on top of
this. With no card bound the supplies are already off, so the regulator
core warns about unbalanced disables on every unbind. With a card bound
and the codec in STANDBY it cuts the supplies while the component is
still registered, and the later OFF transition, run when devres
unregisters the component, then warns. The error path after a failed
component registration disables them a second time in the same way.

Drop the disable from remove() and from that error path.

Fixes: bfea3abb804f ("ASoC: Move WM8993 resource acquisition and device reset to bus probe")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
Found by checks derived from the spec2patch kernel API specifications,
with the help of an AI coding assistant (Claude); I reviewed the
analysis and the fix.
---
 sound/soc/codecs/wm8993.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index fbadbb33b607..f84736bb5d26 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -1729,14 +1729,13 @@ static int wm8993_i2c_probe(struct i2c_client *i2c)
 			&soc_component_dev_wm8993, &wm8993_dai, 1);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
-		goto err_irq;
+		if (i2c->irq)
+			free_irq(i2c->irq, wm8993);
+		return ret;
 	}
 
 	return 0;
 
-err_irq:
-	if (i2c->irq)
-		free_irq(i2c->irq, wm8993);
 err_enable:
 	regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
 	return ret;
@@ -1748,7 +1747,6 @@ static void wm8993_i2c_remove(struct i2c_client *i2c)
 
 	if (i2c->irq)
 		free_irq(i2c->irq, wm8993);
-	regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
 }
 
 static const struct i2c_device_id wm8993_i2c_id[] = {

---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-d101-968b7ecb9315

Best regards,
--  
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>



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

end of thread, other threads:[~2026-12-02 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:57 [PATCH] ASoC: wm8993: Fix unbalanced regulator disables on remove Arina Kharlamova via B4 Relay
2026-12-02 10:44 ` Charles Keepax

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