regulator: Remove redundant set_mode call in drms_uA_update

The regulator framework checks if the current mode is the same as the
one being requested inside of regulator_set_mode. However, when
DRMS changing is allowed, regulator_enable calls drms_uA_update.
This function does not check the value of get_mode before calling
set_mode.

Modify drms_uA_update so that set_mode is only called if the requested
mode is different from the current mode returned by get_mode.

Change-Id: Ifb4f3069cf946e8474565ee82508c1ff45b36543
Signed-off-by: David Collins <collinsd@codeaurora.org>
[adharmap: resolved merge conflicts]
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
David Collins 2010-10-26 16:22:06 -07:00 committed by Rohit Vaswani
parent 001d62d43e
commit 16fbe2a1d3

View file

@ -684,7 +684,7 @@ static int drms_uA_update(struct regulator_dev *rdev)
{ {
struct regulator *sibling; struct regulator *sibling;
int current_uA = 0, output_uV, input_uV, err; int current_uA = 0, output_uV, input_uV, err;
unsigned int mode; unsigned int regulator_curr_mode, mode;
lockdep_assert_held_once(&rdev->mutex); lockdep_assert_held_once(&rdev->mutex);
@ -745,6 +745,14 @@ static int drms_uA_update(struct regulator_dev *rdev)
current_uA, input_uV, output_uV); current_uA, input_uV, output_uV);
return err; return err;
} }
/* return if the same mode is requested */
if (rdev->desc->ops->get_mode) {
regulator_curr_mode = rdev->desc->ops->get_mode(rdev);
if (regulator_curr_mode == mode)
return 0;
} else {
return 0;
}
err = rdev->desc->ops->set_mode(rdev, mode); err = rdev->desc->ops->set_mode(rdev, mode);
if (err < 0) if (err < 0)