Skip to contentSkip to conversation

ALSA: ASoC: cs4271: free allocated GPIO

PATCH Applied Daniel Mack 2 participants 2 messages Nov 10, 2012 – Nov 13, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: ASoC: cs4271: free allocated GPIO

In case of probe deferral, the allocated GPIO line is not freed, which prevents it from being claimed and properly asserted in later attempts.

Fix this by using devm_gpio_request().

---
 sound/soc/codecs/cs4271.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/cs4271.c +3 -8
index f994af3..e3f0a7f 100644
@@ -485,7 +485,7 @@ static int cs4271_probe(struct snd_soc_codec *codec)
 		gpio_nreset = cs4271plat->gpio_nreset;
 
 	if (gpio_nreset >= 0)
-		if (gpio_request(gpio_nreset, "CS4271 Reset"))
+		if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
 			gpio_nreset = -EINVAL;
 	if (gpio_nreset >= 0) {
 		/* Reset codec */
@@ -535,15 +535,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
 static int cs4271_remove(struct snd_soc_codec *codec)
 {
 	struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
-	int gpio_nreset;
 
-	gpio_nreset = cs4271->gpio_nreset;
-
-	if (gpio_is_valid(gpio_nreset)) {
+	if (gpio_is_valid(cs4271->gpio_nreset))
 		/* Set codec to the reset state */
-		gpio_set_value(gpio_nreset, 0);
-		gpio_free(gpio_nreset);
-	}
+		gpio_set_value(cs4271->gpio_nreset, 0);
 
 	return 0;
 };
Signature · 1 line
1.7.11.7
Applied
#1 lore raw
Quoted 2 lines · Daniel Mack

In case of probe deferral, the allocated GPIO line is not freed, which prevents it from being claimed and properly asserted in later attempts.

Applied, thanks.