alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Yong Zhi <yong.zhi@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: kai.vehmanen@linux.intel.com, ryans.lee@maximintegrated.com,
	pierre-louis.bossart@linux.intel.com,
	sathyanarayana.nujella@intel.com, daniel.baluta@nxp.com,
	Yong Zhi <yong.zhi@intel.com>
Subject: [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request
Date: Mon,  4 Nov 2019 16:09:59 -0600	[thread overview]
Message-ID: <1572905399-22402-1-git-send-email-yong.zhi@intel.com> (raw)

Use devm_gpio_request() to automatic unroll when fails and avoid
resource leaks at error paths.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
---
v2 change:
- use devm_gpio_request to avoid the goto statement based on review comments.

 sound/soc/codecs/max98373.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c
index eb709d528259..cae1def8902d 100644
--- a/sound/soc/codecs/max98373.c
+++ b/sound/soc/codecs/max98373.c
@@ -960,11 +960,11 @@ static int max98373_i2c_probe(struct i2c_client *i2c,
 
 	/* Power on device */
 	if (gpio_is_valid(max98373->reset_gpio)) {
-		ret = gpio_request(max98373->reset_gpio, "MAX98373_RESET");
+		ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio,
+					"MAX98373_RESET");
 		if (ret) {
 			dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
 				__func__, max98373->reset_gpio);
-			gpio_free(max98373->reset_gpio);
 			return -EINVAL;
 		}
 		gpio_direction_output(max98373->reset_gpio, 0);
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

             reply	other threads:[~2019-11-04 22:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 22:09 Yong Zhi [this message]
2019-11-05 14:23 ` [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request Kai Vehmanen
2019-11-05 18:55 ` [alsa-devel] Applied "ASoC: max98373: replace gpio_request with devm_gpio_request" to the asoc tree 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=1572905399-22402-1-git-send-email-yong.zhi@intel.com \
    --to=yong.zhi@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ryans.lee@maximintegrated.com \
    --cc=sathyanarayana.nujella@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).