alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request
@ 2019-11-04 22:09 Yong Zhi
  2019-11-05 14:23 ` 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
  0 siblings, 2 replies; 3+ messages in thread
From: Yong Zhi @ 2019-11-04 22:09 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: kai.vehmanen, ryans.lee, pierre-louis.bossart,
	sathyanarayana.nujella, daniel.baluta, Yong Zhi

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request
  2019-11-04 22:09 [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request Yong Zhi
@ 2019-11-05 14:23 ` 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
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Vehmanen @ 2019-11-05 14:23 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, kai.vehmanen, ryans.lee, pierre-louis.bossart,
	broonie, sathyanarayana.nujella, daniel.baluta

Hi,

On Mon, 4 Nov 2019, Yong Zhi wrote:

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

this is a bugfix still, so maybe reword as:

Fix resource leaks on error paths by using devm_gpio_request().

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

All in all, looks good, move to devm_ is even better!

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [alsa-devel] Applied "ASoC: max98373: replace gpio_request with devm_gpio_request" to the asoc tree
  2019-11-04 22:09 [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request Yong Zhi
  2019-11-05 14:23 ` Kai Vehmanen
@ 2019-11-05 18:55 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2019-11-05 18:55 UTC (permalink / raw)
  To: Yong Zhi
  Cc: alsa-devel, kai.vehmanen, ryans.lee, pierre-louis.bossart,
	Mark Brown, sathyanarayana.nujella, daniel.baluta

The patch

   ASoC: max98373: replace gpio_request with devm_gpio_request

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From e44f3d49f900c645af434a3a1dfdbfb79c4a7851 Mon Sep 17 00:00:00 2001
From: Yong Zhi <yong.zhi@intel.com>
Date: Mon, 4 Nov 2019 16:09:59 -0600
Subject: [PATCH] ASoC: max98373: replace gpio_request with devm_gpio_request

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>
Link: https://lore.kernel.org/r/1572905399-22402-1-git-send-email-yong.zhi@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 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.20.1

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-05 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 22:09 [alsa-devel] [PATCH v2] ASoC: max98373: replace gpio_request with devm_gpio_request Yong Zhi
2019-11-05 14:23 ` 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

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).