Skip to content

Commit

Permalink
ASoC: cs4271: free allocated GPIO
Browse files Browse the repository at this point in the history
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().

Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Michael Hirsch <hirsch@teufel.de>
Cc: Alexander Sverdlin <subaparts@yandex.ru>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Daniel Mack authored and Mark Brown committed Nov 13, 2012
1 parent 77b6706 commit 5574f77
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions sound/soc/codecs/cs4271.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit 5574f77

Please sign in to comment.