From: Daniel Mack <zonque@gmail.com>
To: alsa-devel@alsa-project.org
Cc: broonie@opensource.wolfsonmicro.com,
Alexander Sverdlin <subaparts@yandex.ru>,
Daniel Mack <zonque@gmail.com>
Subject: [PATCH] ALSA: ASoC: cs4271: free allocated GPIO
Date: Wed, 7 Nov 2012 14:15:55 +0100 [thread overview]
Message-ID: <1352294155-6733-1-git-send-email-zonque@gmail.com> (raw)
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 freeing the GPIO in case of errors.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Michael Hirsch <hirsch@teufel.de>
Cc: Alexander Sverdlin <subaparts@yandex.ru>
---
sound/soc/codecs/cs4271.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index e5a7ea4..ea57014 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -505,7 +505,7 @@ static int cs4271_probe(struct snd_soc_codec *codec)
ret = regulator_enable(cs4271->vd_supply);
if (ret < 0) {
dev_err(codec->dev, "unable to enable regulator\n");
- return ret;
+ goto err;
}
}
@@ -548,22 +548,31 @@ static int cs4271_probe(struct snd_soc_codec *codec)
cs4271->bus_type);
if (ret) {
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
- return ret;
+ goto err_free_gpio;
}
ret = snd_soc_update_bits(codec, CS4271_MODE2,
CS4271_MODE2_PDN | CS4271_MODE2_CPEN,
CS4271_MODE2_PDN | CS4271_MODE2_CPEN);
if (ret < 0)
- return ret;
+ goto err_free_gpio;
ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0);
if (ret < 0)
- return ret;
+ goto err_free_gpio;
/* Power-up sequence requires 85 uS */
udelay(85);
return snd_soc_add_codec_controls(codec, cs4271_snd_controls,
ARRAY_SIZE(cs4271_snd_controls));
+
+err_free_gpio:
+ if (gpio_is_valid(cs4271->gpio_nreset))
+ gpio_free(cs4271->gpio_nreset);
+
+ cs4271->gpio_nreset = -EINVAL;
+
+err:
+ return ret;
}
static int cs4271_remove(struct snd_soc_codec *codec)
--
1.7.11.7
next reply other threads:[~2012-11-07 13:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 13:15 Daniel Mack [this message]
2012-11-07 14:07 ` [PATCH] ALSA: ASoC: cs4271: free allocated GPIO Mark Brown
2012-11-10 18:52 ` Daniel Mack
-- strict thread matches above, loose matches on Subject: below --
2012-11-10 18:52 Daniel Mack
2012-11-13 6:47 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352294155-6733-1-git-send-email-zonque@gmail.com \
--to=zonque@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=subaparts@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox