regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
PATCH v3 1/1 regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
In the case of get_voltage callback is NULL, current implementation in _regulator_get_voltage will return -EINVAL.
Also returns proper error if ret is negative value.
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/core.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/regulator/core.c +5 -3
@@ -1886,12 +1886,14 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)if (sel <0 )return sel; ret = rdev->desc->ops->list_voltage (rdev, sel); - } -if (rdev->desc->ops->get_voltage) + }else if (rdev->desc->ops->get_voltage) { ret = rdev->desc->ops->get_voltage (rdev); -else + }else {return -EINVAL ; + } +if (ret <0 ) +return ret;return ret - rdev->constraints->uV_offset; }
Signature · 1 line
1.7.1
Quoted 6 lines · Axel Lin
In the case of
get_voltagecallback is NULL, current implementation in_regulator_get_voltagewill return-EINVAL.Also returns proper error if ret is negative value.
Signed-off-by Axel Lin <[email protected]>
Acked-by Mark Brown <[email protected]>
Liam Girdwood
AppliedQuoted 9 lines · Mark Brown
Quoted 6 lines · Axel Lin
In the case of
get_voltagecallback is NULL, current implementation in_regulator_get_voltagewill return-EINVAL.Also returns proper error if ret is negative value.
Signed-off-by Axel Lin <[email protected]>Acked-by Mark Brown <[email protected]>
Applied.
Thanks
Liam