aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@sonymobile.com>2015-04-06 19:34:00 -0400
committerMark Brown <broonie@kernel.org>2015-04-08 07:22:55 -0400
commitce8ae17c5d86db92cecd8291ad6a137dc19031ad (patch)
treedfd58a63dc629ebd38eacf14b3104485d8753e1c /drivers/regulator
parent087a1b5cdd555970feb8a340dc008b6914f05128 (diff)
regulator: qcom: Tidy up probe()
Tidy up error reporting and move rpm reference retrieval out of the for loop for improved readability. Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/qcom_rpm-regulator.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 40cf6ff0d1ff..e254272585b2 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -884,19 +884,26 @@ static int rpm_reg_probe(struct platform_device *pdev)
884 struct regulator_config config = { }; 884 struct regulator_config config = { };
885 struct regulator_dev *rdev; 885 struct regulator_dev *rdev;
886 struct qcom_rpm_reg *vreg; 886 struct qcom_rpm_reg *vreg;
887 struct qcom_rpm *rpm;
888
889 rpm = dev_get_drvdata(pdev->dev.parent);
890 if (!rpm) {
891 dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
892 return -ENODEV;
893 }
887 894
888 match = of_match_device(rpm_of_match, &pdev->dev); 895 match = of_match_device(rpm_of_match, &pdev->dev);
889 for (reg = match->data; reg->name; reg++) { 896 for (reg = match->data; reg->name; reg++) {
890 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 897 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
891 if (!vreg) { 898 if (!vreg)
892 dev_err(&pdev->dev, "failed to allocate vreg\n");
893 return -ENOMEM; 899 return -ENOMEM;
894 } 900
895 memcpy(vreg, reg->template, sizeof(*vreg)); 901 memcpy(vreg, reg->template, sizeof(*vreg));
896 mutex_init(&vreg->lock); 902 mutex_init(&vreg->lock);
897 903
898 vreg->dev = &pdev->dev; 904 vreg->dev = &pdev->dev;
899 vreg->resource = reg->resource; 905 vreg->resource = reg->resource;
906 vreg->rpm = rpm;
900 907
901 vreg->desc.id = -1; 908 vreg->desc.id = -1;
902 vreg->desc.owner = THIS_MODULE; 909 vreg->desc.owner = THIS_MODULE;
@@ -906,17 +913,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
906 vreg->desc.of_match = reg->name; 913 vreg->desc.of_match = reg->name;
907 vreg->desc.of_parse_cb = rpm_reg_of_parse; 914 vreg->desc.of_parse_cb = rpm_reg_of_parse;
908 915
909 vreg->rpm = dev_get_drvdata(pdev->dev.parent);
910 if (!vreg->rpm) {
911 dev_err(&pdev->dev, "unable to retrieve handle to rpm\n");
912 return -ENODEV;
913 }
914
915 config.dev = &pdev->dev; 916 config.dev = &pdev->dev;
916 config.driver_data = vreg; 917 config.driver_data = vreg;
917 rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config); 918 rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config);
918 if (IS_ERR(rdev)) { 919 if (IS_ERR(rdev)) {
919 dev_err(&pdev->dev, "can't register regulator\n"); 920 dev_err(&pdev->dev, "failed to register %s\n", reg->name);
920 return PTR_ERR(rdev); 921 return PTR_ERR(rdev);
921 } 922 }
922 } 923 }