From cb220d16f91f8d5fa1450c7af17e028e8cb3f0f1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 23 May 2011 20:08:10 +0800 Subject: 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 Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/regulator/core.c') diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9493f6111a3..d3e38790906 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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; } -- cgit v1.2.3-18-g5258