mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2026-03-14 21:10:27 +01:00
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>
This commit is contained in:
parent
eaadcf38dd
commit
5483456e91
1 changed files with 7 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue