aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8998.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 01:38:02 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:41 -0400
commit8d491bf42e01e8cc7597ee55cdeab20dbc75ec97 (patch)
tree3e54660aec0788a3312ebf3cfebb0e93ea5fcaed /drivers/regulator/max8998.c
parent4177f95b8433f809228ab485e3303ae4708c98ca (diff)
regulator: max8998: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r--drivers/regulator/max8998.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index a4c53b2d1aaf..ae3f0656feb0 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -790,16 +790,14 @@ static int max8998_pmic_probe(struct platform_device *pdev)
790 dev_err(&pdev->dev, 790 dev_err(&pdev->dev,
791 "MAX8998 SET1 GPIO defined as 0 !\n"); 791 "MAX8998 SET1 GPIO defined as 0 !\n");
792 WARN_ON(!pdata->buck1_set1); 792 WARN_ON(!pdata->buck1_set1);
793 ret = -EIO; 793 return -EIO;
794 goto err_out;
795 } 794 }
796 /* Check if SET2 is not equal to 0 */ 795 /* Check if SET2 is not equal to 0 */
797 if (!pdata->buck1_set2) { 796 if (!pdata->buck1_set2) {
798 dev_err(&pdev->dev, 797 dev_err(&pdev->dev,
799 "MAX8998 SET2 GPIO defined as 0 !\n"); 798 "MAX8998 SET2 GPIO defined as 0 !\n");
800 WARN_ON(!pdata->buck1_set2); 799 WARN_ON(!pdata->buck1_set2);
801 ret = -EIO; 800 return -EIO;
802 goto err_out;
803 } 801 }
804 802
805 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); 803 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
@@ -823,7 +821,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
823 ret = max8998_write_reg(i2c, 821 ret = max8998_write_reg(i2c,
824 MAX8998_REG_BUCK1_VOLTAGE1 + v, i); 822 MAX8998_REG_BUCK1_VOLTAGE1 + v, i);
825 if (ret) 823 if (ret)
826 goto err_out; 824 return ret;
827 } 825 }
828 } 826 }
829 827
@@ -833,8 +831,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
833 dev_err(&pdev->dev, 831 dev_err(&pdev->dev,
834 "MAX8998 SET3 GPIO defined as 0 !\n"); 832 "MAX8998 SET3 GPIO defined as 0 !\n");
835 WARN_ON(!pdata->buck2_set3); 833 WARN_ON(!pdata->buck2_set3);
836 ret = -EIO; 834 return -EIO;
837 goto err_out;
838 } 835 }
839 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); 836 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
840 gpio_direction_output(pdata->buck2_set3, 837 gpio_direction_output(pdata->buck2_set3,
@@ -852,7 +849,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
852 ret = max8998_write_reg(i2c, 849 ret = max8998_write_reg(i2c,
853 MAX8998_REG_BUCK2_VOLTAGE1 + v, i); 850 MAX8998_REG_BUCK2_VOLTAGE1 + v, i);
854 if (ret) 851 if (ret)
855 goto err_out; 852 return ret;
856 } 853 }
857 } 854 }
858 855
@@ -875,34 +872,19 @@ static int max8998_pmic_probe(struct platform_device *pdev)
875 config.init_data = pdata->regulators[i].initdata; 872 config.init_data = pdata->regulators[i].initdata;
876 config.driver_data = max8998; 873 config.driver_data = max8998;
877 874
878 rdev[i] = regulator_register(&regulators[index], &config); 875 rdev[i] = devm_regulator_register(&pdev->dev,
876 &regulators[index], &config);
879 if (IS_ERR(rdev[i])) { 877 if (IS_ERR(rdev[i])) {
880 ret = PTR_ERR(rdev[i]); 878 ret = PTR_ERR(rdev[i]);
881 dev_err(max8998->dev, "regulator %s init failed (%d)\n", 879 dev_err(max8998->dev, "regulator %s init failed (%d)\n",
882 regulators[index].name, ret); 880 regulators[index].name, ret);
883 rdev[i] = NULL; 881 rdev[i] = NULL;
884 goto err; 882 return ret;
885 } 883 }
886 } 884 }
887 885
888 886
889 return 0; 887 return 0;
890err:
891 while (--i >= 0)
892 regulator_unregister(rdev[i]);
893err_out:
894 return ret;
895}
896
897static int max8998_pmic_remove(struct platform_device *pdev)
898{
899 struct max8998_data *max8998 = platform_get_drvdata(pdev);
900 struct regulator_dev **rdev = max8998->rdev;
901 int i;
902
903 for (i = 0; i < max8998->num_regulators; i++)
904 regulator_unregister(rdev[i]);
905 return 0;
906} 888}
907 889
908static const struct platform_device_id max8998_pmic_id[] = { 890static const struct platform_device_id max8998_pmic_id[] = {
@@ -918,7 +900,6 @@ static struct platform_driver max8998_pmic_driver = {
918 .owner = THIS_MODULE, 900 .owner = THIS_MODULE,
919 }, 901 },
920 .probe = max8998_pmic_probe, 902 .probe = max8998_pmic_probe,
921 .remove = max8998_pmic_remove,
922 .id_table = max8998_pmic_id, 903 .id_table = max8998_pmic_id,
923}; 904};
924 905