提交 8a8e3d59 编写于 作者: L Laxman Dewangan 提交者: Mark Brown

regulator: tps62360: use devm_* for gpio request

Use devm_ version of gpio APIs gpio_request_one() for
requesting gpios.
This avoid extra code for freeing gpios.
Signed-off-by: NLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 d5b2e30b
...@@ -428,24 +428,24 @@ static int __devinit tps62360_probe(struct i2c_client *client, ...@@ -428,24 +428,24 @@ static int __devinit tps62360_probe(struct i2c_client *client,
int gpio_flags; int gpio_flags;
gpio_flags = (pdata->vsel0_def_state) ? gpio_flags = (pdata->vsel0_def_state) ?
GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
ret = gpio_request_one(tps->vsel0_gpio, ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio,
gpio_flags, "tps62360-vsel0"); gpio_flags, "tps62360-vsel0");
if (ret) { if (ret) {
dev_err(&client->dev, dev_err(&client->dev,
"%s(): Could not obtain vsel0 GPIO %d: %d\n", "%s(): Could not obtain vsel0 GPIO %d: %d\n",
__func__, tps->vsel0_gpio, ret); __func__, tps->vsel0_gpio, ret);
goto err_gpio0; return ret;
} }
gpio_flags = (pdata->vsel1_def_state) ? gpio_flags = (pdata->vsel1_def_state) ?
GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
ret = gpio_request_one(tps->vsel1_gpio, ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio,
gpio_flags, "tps62360-vsel1"); gpio_flags, "tps62360-vsel1");
if (ret) { if (ret) {
dev_err(&client->dev, dev_err(&client->dev,
"%s(): Could not obtain vsel1 GPIO %d: %d\n", "%s(): Could not obtain vsel1 GPIO %d: %d\n",
__func__, tps->vsel1_gpio, ret); __func__, tps->vsel1_gpio, ret);
goto err_gpio1; return ret;
} }
tps->valid_gpios = true; tps->valid_gpios = true;
...@@ -463,7 +463,7 @@ static int __devinit tps62360_probe(struct i2c_client *client, ...@@ -463,7 +463,7 @@ static int __devinit tps62360_probe(struct i2c_client *client,
if (ret < 0) { if (ret < 0) {
dev_err(tps->dev, "%s(): Init failed with err = %d\n", dev_err(tps->dev, "%s(): Init failed with err = %d\n",
__func__, ret); __func__, ret);
goto err_init; return ret;
} }
config.dev = &client->dev; config.dev = &client->dev;
...@@ -477,21 +477,11 @@ static int __devinit tps62360_probe(struct i2c_client *client, ...@@ -477,21 +477,11 @@ static int __devinit tps62360_probe(struct i2c_client *client,
dev_err(tps->dev, dev_err(tps->dev,
"%s(): regulator register failed with err %s\n", "%s(): regulator register failed with err %s\n",
__func__, id->name); __func__, id->name);
ret = PTR_ERR(rdev); return PTR_ERR(rdev);
goto err_init;
} }
tps->rdev = rdev; tps->rdev = rdev;
return 0; return 0;
err_init:
if (gpio_is_valid(tps->vsel1_gpio))
gpio_free(tps->vsel1_gpio);
err_gpio1:
if (gpio_is_valid(tps->vsel0_gpio))
gpio_free(tps->vsel0_gpio);
err_gpio0:
return ret;
} }
/** /**
...@@ -504,12 +494,6 @@ static int __devexit tps62360_remove(struct i2c_client *client) ...@@ -504,12 +494,6 @@ static int __devexit tps62360_remove(struct i2c_client *client)
{ {
struct tps62360_chip *tps = i2c_get_clientdata(client); struct tps62360_chip *tps = i2c_get_clientdata(client);
if (gpio_is_valid(tps->vsel1_gpio))
gpio_free(tps->vsel1_gpio);
if (gpio_is_valid(tps->vsel0_gpio))
gpio_free(tps->vsel0_gpio);
regulator_unregister(tps->rdev); regulator_unregister(tps->rdev);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册