Skip to content

Commit

Permalink
ASoC: max98373: replace gpio_request with devm_gpio_request
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yong Zhi authored and Mark Brown committed Nov 5, 2019
1 parent eaf072e commit e44f3d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/soc/codecs/max98373.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e44f3d4

Please sign in to comment.