diff mbox series

[v2] ASoC: max98373: replace gpio_request with devm_gpio_request

Message ID 1572905399-22402-1-git-send-email-yong.zhi@intel.com (mailing list archive)
State Accepted
Commit e44f3d49f900c645af434a3a1dfdbfb79c4a7851
Headers show
Series [v2] ASoC: max98373: replace gpio_request with devm_gpio_request | expand

Commit Message

Zhi, Yong Nov. 4, 2019, 10:09 p.m. UTC
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(-)

Comments

Kai Vehmanen Nov. 5, 2019, 2:23 p.m. UTC | #1
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
diff mbox series

Patch

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