lkml.org 
[lkml]   [2011]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH v2] regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
From
Date
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 <axel.lin@gmail.com>
---
v2: remove unneeded goto.

drivers/regulator/core.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9493f61..f11b0ba 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1886,13 +1886,13 @@ 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;
+ }

- return ret - rdev->constraints->uV_offset;
+ return ret < 0 ? ret : ret - rdev->constraints->uV_offset;
}

/**
--
1.7.1




\
 
 \ /
  Last update: 2011-05-20 02:39    [W:0.044 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site