mirror of
https://xff.cz/git/u-boot/
synced 2025-09-08 20:22:10 +02:00
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>
This commit is contained in:
@@ -41,6 +41,13 @@ int regulator_get_value(struct udevice *dev)
|
|||||||
int regulator_set_value(struct udevice *dev, int uV)
|
int regulator_set_value(struct udevice *dev, int uV)
|
||||||
{
|
{
|
||||||
const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
|
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)
|
if (!ops || !ops->set_value)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
Reference in New Issue
Block a user