Skip to content

Commit 500b4ac

Browse files
Sundar R IyerLiam Girdwood
authored andcommitted
regulator: return set_mode is same mode is requested
On Mon, 2010-05-17 at 17:34 +0200, Mark Brown wrote: > This doesn't seem like the right error handling - if the driver has a > set_mode() you'd *expect* it to have a get_mode() but there's no need > for it to be a strict requirement. True. In such a case, even a valid request would be lost! So now in the updated patch: - check if get_mode is present to avoid oops; - if get_mode is not present, proceed anyways for the request. Here is the updated patch: >From bad0d5eb51ef84be5b100e3dd0f5a590ea0529b6 Mon Sep 17 00:00:00 2001 From: Sundar R Iyer <[email protected]> Date: Fri, 14 May 2010 15:14:17 +0530 Subject: [PATCH 1/1] regulator: return set_mode when same mode is requested save I/O costs by returning when the same mode is requested for the regulator Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Sundar R Iyer <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
1 parent 6471435 commit 500b4ac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/regulator/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,7 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode)
17451745
{
17461746
struct regulator_dev *rdev = regulator->rdev;
17471747
int ret;
1748+
int regulator_curr_mode;
17481749

17491750
mutex_lock(&rdev->mutex);
17501751

@@ -1754,6 +1755,15 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode)
17541755
goto out;
17551756
}
17561757

1758+
/* return if the same mode is requested */
1759+
if (rdev->desc->ops->get_mode) {
1760+
regulator_curr_mode = rdev->desc->ops->get_mode(rdev);
1761+
if (regulator_curr_mode == mode) {
1762+
ret = 0;
1763+
goto out;
1764+
}
1765+
}
1766+
17571767
/* constraints check */
17581768
ret = regulator_check_mode(rdev, mode);
17591769
if (ret < 0)

0 commit comments

Comments
 (0)