diff mbox

[U-Boot,2/3] power: regulator: Add limits checking while setting voltage

Message ID 1477469552-10510-2-git-send-email-j-keerthy@ti.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

J, KEERTHY Oct. 26, 2016, 8:12 a.m. UTC
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>
---
 drivers/power/regulator/regulator-uclass.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass Oct. 26, 2016, 4:31 p.m. UTC | #1
On 26 October 2016 at 01:12, Keerthy <j-keerthy@ti.com> wrote:
> 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>
> ---
>  drivers/power/regulator/regulator-uclass.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Nov. 25, 2016, 7:38 p.m. UTC | #2
On 26 October 2016 at 10:31, Simon Glass <sjg@chromium.org> wrote:
> On 26 October 2016 at 01:12, Keerthy <j-keerthy@ti.com> wrote:
>> 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>
>> ---
>>  drivers/power/regulator/regulator-uclass.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-rockchip, thanks!
diff mbox

Patch

diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index d644009..34087c8 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -41,6 +41,11 @@  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 (uV < uc_pdata->min_uV || uV > uc_pdata->max_uV)
+		return -EINVAL;
 
 	if (!ops || !ops->set_value)
 		return -ENOSYS;