diff options
author | Keerthy <j-keerthy@ti.com> | 2016-10-26 13:42:32 +0530 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-11-25 17:59:26 -0700 |
commit | 5483456e919f08e51914d296e8720eaa0a288b68 (patch) | |
tree | a44b9eef8d302db36988f6b76c14e7519cdcb07e /drivers/power | |
parent | eaadcf38ddfe23aee9c3a85a96d4103f5398fc5e (diff) | |
download | u-boot-imx-5483456e919f08e51914d296e8720eaa0a288b68.zip u-boot-imx-5483456e919f08e51914d296e8720eaa0a288b68.tar.gz u-boot-imx-5483456e919f08e51914d296e8720eaa0a288b68.tar.bz2 |
power: regulator: Add limits checking while setting current
Currently the specific set ops functions are directly
called without any check for min/max current limits for a regulator.
Check for them and proceed.
Signed-off-by: Keerthy <j-keerthy@ti.com>
Fixed checking of current limits:
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/regulator/regulator-uclass.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index e48d213..52a1070 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -82,6 +82,13 @@ int regulator_get_current(struct udevice *dev) int regulator_set_current(struct udevice *dev, int uA) { 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_uA != -ENODATA && uA < uc_pdata->min_uA) + return -EINVAL; + if (uc_pdata->max_uA != -ENODATA && uA > uc_pdata->max_uA) + return -EINVAL; if (!ops || !ops->set_current) return -ENOSYS; |