aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoonwoo Park <joonwoop@codeaurora.org>2016-09-19 17:46:54 -0400
committerMark Brown <broonie@kernel.org>2016-09-24 14:36:41 -0400
commit577766175c40d4f425be47b9e70d80238e53f996 (patch)
tree27085b73567bfb76e2e2ff56299b6ba44766a2ae
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
regulator: core: don't return error with inadequate reason
drms_uA_update() always returns failure when it cannot find regulator's input voltage. But if hardware supports load configuration with ops->set_load() and the input regulator isn't specified with valid reason such as the input regulator is battery, not finding input voltage is normal so such case should not return with an error. Avoid such inadequate error return by checking input/output voltages only when drms_uA_update() is about to configure load with enum based ops->set_mode(). Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index db320e8fa865..bafcdff42872 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -679,24 +679,6 @@ static int drms_uA_update(struct regulator_dev *rdev)
679 !rdev->desc->ops->set_load) 679 !rdev->desc->ops->set_load)
680 return -EINVAL; 680 return -EINVAL;
681 681
682 /* get output voltage */
683 output_uV = _regulator_get_voltage(rdev);
684 if (output_uV <= 0) {
685 rdev_err(rdev, "invalid output voltage found\n");
686 return -EINVAL;
687 }
688
689 /* get input voltage */
690 input_uV = 0;
691 if (rdev->supply)
692 input_uV = regulator_get_voltage(rdev->supply);
693 if (input_uV <= 0)
694 input_uV = rdev->constraints->input_uV;
695 if (input_uV <= 0) {
696 rdev_err(rdev, "invalid input voltage found\n");
697 return -EINVAL;
698 }
699
700 /* calc total requested load */ 682 /* calc total requested load */
701 list_for_each_entry(sibling, &rdev->consumer_list, list) 683 list_for_each_entry(sibling, &rdev->consumer_list, list)
702 current_uA += sibling->uA_load; 684 current_uA += sibling->uA_load;
@@ -709,6 +691,24 @@ static int drms_uA_update(struct regulator_dev *rdev)
709 if (err < 0) 691 if (err < 0)
710 rdev_err(rdev, "failed to set load %d\n", current_uA); 692 rdev_err(rdev, "failed to set load %d\n", current_uA);
711 } else { 693 } else {
694 /* get output voltage */
695 output_uV = _regulator_get_voltage(rdev);
696 if (output_uV <= 0) {
697 rdev_err(rdev, "invalid output voltage found\n");
698 return -EINVAL;
699 }
700
701 /* get input voltage */
702 input_uV = 0;
703 if (rdev->supply)
704 input_uV = regulator_get_voltage(rdev->supply);
705 if (input_uV <= 0)
706 input_uV = rdev->constraints->input_uV;
707 if (input_uV <= 0) {
708 rdev_err(rdev, "invalid input voltage found\n");
709 return -EINVAL;
710 }
711
712 /* now get the optimum mode for our new total regulator load */ 712 /* now get the optimum mode for our new total regulator load */
713 mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV, 713 mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,
714 output_uV, current_uA); 714 output_uV, current_uA);