aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-07-02 06:05:48 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-15 16:49:52 -0400
commit8a8e3d5915b3b40a64a5e7dc5aeb208594917a15 (patch)
tree3fc5fb57dc14d7c69dc1ee6319489e17a999d99d /drivers/regulator
parentd5b2e30bdc695a1735b3c970e1f9738e9ca3dbf0 (diff)
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: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps62360-regulator.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c
index 103bb62aaef8..68729a7c8709 100644
--- a/drivers/regulator/tps62360-regulator.c
+++ b/drivers/regulator/tps62360-regulator.c
@@ -428,24 +428,24 @@ static int __devinit tps62360_probe(struct i2c_client *client,
428 int gpio_flags; 428 int gpio_flags;
429 gpio_flags = (pdata->vsel0_def_state) ? 429 gpio_flags = (pdata->vsel0_def_state) ?
430 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 430 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
431 ret = gpio_request_one(tps->vsel0_gpio, 431 ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio,
432 gpio_flags, "tps62360-vsel0"); 432 gpio_flags, "tps62360-vsel0");
433 if (ret) { 433 if (ret) {
434 dev_err(&client->dev, 434 dev_err(&client->dev,
435 "%s(): Could not obtain vsel0 GPIO %d: %d\n", 435 "%s(): Could not obtain vsel0 GPIO %d: %d\n",
436 __func__, tps->vsel0_gpio, ret); 436 __func__, tps->vsel0_gpio, ret);
437 goto err_gpio0; 437 return ret;
438 } 438 }
439 439
440 gpio_flags = (pdata->vsel1_def_state) ? 440 gpio_flags = (pdata->vsel1_def_state) ?
441 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 441 GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
442 ret = gpio_request_one(tps->vsel1_gpio, 442 ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio,
443 gpio_flags, "tps62360-vsel1"); 443 gpio_flags, "tps62360-vsel1");
444 if (ret) { 444 if (ret) {
445 dev_err(&client->dev, 445 dev_err(&client->dev,
446 "%s(): Could not obtain vsel1 GPIO %d: %d\n", 446 "%s(): Could not obtain vsel1 GPIO %d: %d\n",
447 __func__, tps->vsel1_gpio, ret); 447 __func__, tps->vsel1_gpio, ret);
448 goto err_gpio1; 448 return ret;
449 } 449 }
450 tps->valid_gpios = true; 450 tps->valid_gpios = true;
451 451
@@ -463,7 +463,7 @@ static int __devinit tps62360_probe(struct i2c_client *client,
463 if (ret < 0) { 463 if (ret < 0) {
464 dev_err(tps->dev, "%s(): Init failed with err = %d\n", 464 dev_err(tps->dev, "%s(): Init failed with err = %d\n",
465 __func__, ret); 465 __func__, ret);
466 goto err_init; 466 return ret;
467 } 467 }
468 468
469 config.dev = &client->dev; 469 config.dev = &client->dev;
@@ -477,21 +477,11 @@ static int __devinit tps62360_probe(struct i2c_client *client,
477 dev_err(tps->dev, 477 dev_err(tps->dev,
478 "%s(): regulator register failed with err %s\n", 478 "%s(): regulator register failed with err %s\n",
479 __func__, id->name); 479 __func__, id->name);
480 ret = PTR_ERR(rdev); 480 return PTR_ERR(rdev);
481 goto err_init;
482 } 481 }
483 482
484 tps->rdev = rdev; 483 tps->rdev = rdev;
485 return 0; 484 return 0;
486
487err_init:
488 if (gpio_is_valid(tps->vsel1_gpio))
489 gpio_free(tps->vsel1_gpio);
490err_gpio1:
491 if (gpio_is_valid(tps->vsel0_gpio))
492 gpio_free(tps->vsel0_gpio);
493err_gpio0:
494 return ret;
495} 485}
496 486
497/** 487/**
@@ -504,12 +494,6 @@ static int __devexit tps62360_remove(struct i2c_client *client)
504{ 494{
505 struct tps62360_chip *tps = i2c_get_clientdata(client); 495 struct tps62360_chip *tps = i2c_get_clientdata(client);
506 496
507 if (gpio_is_valid(tps->vsel1_gpio))
508 gpio_free(tps->vsel1_gpio);
509
510 if (gpio_is_valid(tps->vsel0_gpio))
511 gpio_free(tps->vsel0_gpio);
512
513 regulator_unregister(tps->rdev); 497 regulator_unregister(tps->rdev);
514 return 0; 498 return 0;
515} 499}