Skip to content

Commit 5574f77

Browse files
zonquebroonie
authored andcommitted
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(). 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>
1 parent 77b6706 commit 5574f77

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

sound/soc/codecs/cs4271.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static int cs4271_probe(struct snd_soc_codec *codec)
485485
gpio_nreset = cs4271plat->gpio_nreset;
486486

487487
if (gpio_nreset >= 0)
488-
if (gpio_request(gpio_nreset, "CS4271 Reset"))
488+
if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
489489
gpio_nreset = -EINVAL;
490490
if (gpio_nreset >= 0) {
491491
/* Reset codec */
@@ -535,15 +535,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
535535
static int cs4271_remove(struct snd_soc_codec *codec)
536536
{
537537
struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
538-
int gpio_nreset;
539538

540-
gpio_nreset = cs4271->gpio_nreset;
541-
542-
if (gpio_is_valid(gpio_nreset)) {
539+
if (gpio_is_valid(cs4271->gpio_nreset))
543540
/* Set codec to the reset state */
544-
gpio_set_value(gpio_nreset, 0);
545-
gpio_free(gpio_nreset);
546-
}
541+
gpio_set_value(cs4271->gpio_nreset, 0);
547542

548543
return 0;
549544
};

0 commit comments

Comments
 (0)