summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorKeerthy <j-keerthy@ti.com>2016-10-26 13:42:31 +0530
committerSimon Glass <sjg@chromium.org>2016-11-25 17:58:09 -0700
commiteaadcf38ddfe23aee9c3a85a96d4103f5398fc5e (patch)
treefe435e35b1fc14668290aecd8166cf0af538a25c /drivers/power
parent2f5d532f3b8a7697dc1b5700000b1e350323d50c (diff)
downloadu-boot-imx-eaadcf38ddfe23aee9c3a85a96d4103f5398fc5e.zip
u-boot-imx-eaadcf38ddfe23aee9c3a85a96d4103f5398fc5e.tar.gz
u-boot-imx-eaadcf38ddfe23aee9c3a85a96d4103f5398fc5e.tar.bz2
power: regulator: Add limits checking while setting voltage
Currently the specific set ops functions are directly called without any check for voltage limits for a regulator. Check for them and proceed. Signed-off-by: Keerthy <j-keerthy@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Fixed checking of voltate limits: Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/regulator/regulator-uclass.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index d644009..e48d213 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -41,6 +41,13 @@ int regulator_get_value(struct udevice *dev)
int regulator_set_value(struct udevice *dev, int uV)
{
const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
+ struct dm_regulator_uclass_platdata *uc_pdata;
+
+ uc_pdata = dev_get_uclass_platdata(dev);
+ if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV)
+ return -EINVAL;
+ if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV)
+ return -EINVAL;
if (!ops || !ops->set_value)
return -ENOSYS;