diff options
author | Sundar R Iyer <sundar.iyer@stericsson.com> | 2010-05-17 21:24:48 +0530 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-05-25 10:16:02 +0100 |
commit | 500b4ac90d1103a7c302d5bb16c53f4ffc45d057 (patch) | |
tree | b6e134661375564fc654b424fbdaa240c0a2a230 /drivers/regulator/core.c | |
parent | 64714354a45a58a072cfc926db0a078611a63d43 (diff) | |
download | linux-500b4ac90d1103a7c302d5bb16c53f4ffc45d057.tar.gz linux-500b4ac90d1103a7c302d5bb16c53f4ffc45d057.tar.bz2 linux-500b4ac90d1103a7c302d5bb16c53f4ffc45d057.zip |
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 <sundar.iyer@stericsson.com>
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 <lrg@slimlogic.co.uk>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Sundar R Iyer <sundar.iyer@stericsson.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 98e5d14f94f3..2248087b9be2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1745,6 +1745,7 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) { struct regulator_dev *rdev = regulator->rdev; int ret; + int regulator_curr_mode; mutex_lock(&rdev->mutex); @@ -1754,6 +1755,15 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) goto out; } + /* 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) { + ret = 0; + goto out; + } + } + /* constraints check */ ret = regulator_check_mode(rdev, mode); if (ret < 0) |