aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/s5m8767.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-07-05 11:12:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-15 16:49:53 -0400
commit5febb3c9d52c65686a8e473a31f15137852f4b5e (patch)
tree6d291f4989841b875bab4c6004dd7bd32c3870f4 /drivers/regulator/s5m8767.c
parent8fa25eda86b1a149fd19b5ce80d8cf7b6c8fb566 (diff)
regulator: s5m8767: Properly handle gpio_request failure
Convert to devm_gpio_request to save a few error handling code. This patch properly handle the gpio_request failure, we should return error when gpio_request fails rather than just show warning. I think one of the reason we got -EBUSY is because current code does not free gpios in s5m8767_pmic_remove(). So it got -EBUSY when reload the module. Yest another reason is in current code if gpio_request() returns error, the rest of the code still calls gpio_direction_output to config buck_gpios and buck_ds gpios. This looks wrong to me. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/s5m8767.c')
-rw-r--r--drivers/regulator/s5m8767.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 1ad9c3c0da8d..102287fa7ecb 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -620,20 +620,21 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
620 if (gpio_is_valid(pdata->buck_gpios[0]) && 620 if (gpio_is_valid(pdata->buck_gpios[0]) &&
621 gpio_is_valid(pdata->buck_gpios[1]) && 621 gpio_is_valid(pdata->buck_gpios[1]) &&
622 gpio_is_valid(pdata->buck_gpios[2])) { 622 gpio_is_valid(pdata->buck_gpios[2])) {
623 ret = gpio_request(pdata->buck_gpios[0], "S5M8767 SET1"); 623 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[0],
624 if (ret == -EBUSY) 624 "S5M8767 SET1");
625 dev_warn(&pdev->dev, "Duplicated gpio request" 625 if (ret)
626 " for SET1\n"); 626 return ret;
627 627
628 ret = gpio_request(pdata->buck_gpios[1], "S5M8767 SET2"); 628 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[1],
629 if (ret == -EBUSY) 629 "S5M8767 SET2");
630 dev_warn(&pdev->dev, "Duplicated gpio request" 630 if (ret)
631 " for SET2\n"); 631 return ret;
632 632
633 ret = gpio_request(pdata->buck_gpios[2], "S5M8767 SET3"); 633 ret = devm_gpio_request(&pdev->dev, pdata->buck_gpios[2],
634 if (ret == -EBUSY) 634 "S5M8767 SET3");
635 dev_warn(&pdev->dev, "Duplicated gpio request" 635 if (ret)
636 " for SET3\n"); 636 return ret;
637
637 /* SET1 GPIO */ 638 /* SET1 GPIO */
638 gpio_direction_output(pdata->buck_gpios[0], 639 gpio_direction_output(pdata->buck_gpios[0],
639 (s5m8767->buck_gpioindex >> 2) & 0x1); 640 (s5m8767->buck_gpioindex >> 2) & 0x1);
@@ -643,25 +644,23 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
643 /* SET3 GPIO */ 644 /* SET3 GPIO */
644 gpio_direction_output(pdata->buck_gpios[2], 645 gpio_direction_output(pdata->buck_gpios[2],
645 (s5m8767->buck_gpioindex >> 0) & 0x1); 646 (s5m8767->buck_gpioindex >> 0) & 0x1);
646 ret = 0;
647
648 } else { 647 } else {
649 dev_err(&pdev->dev, "GPIO NOT VALID\n"); 648 dev_err(&pdev->dev, "GPIO NOT VALID\n");
650 ret = -EINVAL; 649 ret = -EINVAL;
651 return ret; 650 return ret;
652 } 651 }
653 652
654 ret = gpio_request(pdata->buck_ds[0], "S5M8767 DS2"); 653 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[0], "S5M8767 DS2");
655 if (ret == -EBUSY) 654 if (ret)
656 dev_warn(&pdev->dev, "Duplicated gpio request for DS2\n"); 655 return ret;
657 656
658 ret = gpio_request(pdata->buck_ds[1], "S5M8767 DS3"); 657 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[1], "S5M8767 DS3");
659 if (ret == -EBUSY) 658 if (ret)
660 dev_warn(&pdev->dev, "Duplicated gpio request for DS3\n"); 659 return ret;
661 660
662 ret = gpio_request(pdata->buck_ds[2], "S5M8767 DS4"); 661 ret = devm_gpio_request(&pdev->dev, pdata->buck_ds[2], "S5M8767 DS4");
663 if (ret == -EBUSY) 662 if (ret)
664 dev_warn(&pdev->dev, "Duplicated gpio request for DS4\n"); 663 return ret;
665 664
666 /* DS2 GPIO */ 665 /* DS2 GPIO */
667 gpio_direction_output(pdata->buck_ds[0], 0x0); 666 gpio_direction_output(pdata->buck_ds[0], 0x0);