diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-05-23 08:08:10 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-05-27 05:49:30 -0400 |
commit | cb220d16f91f8d5fa1450c7af17e028e8cb3f0f1 (patch) | |
tree | 98af3e7e811980be3608c1c4b7506fb73d74d21c /drivers/regulator | |
parent | 5ccee4ae8eab957ab6d534283db5bd27703dba03 (diff) |
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 <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9493f6111a38..d3e38790906e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1886,12 +1886,14 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) | |||
1886 | if (sel < 0) | 1886 | if (sel < 0) |
1887 | return sel; | 1887 | return sel; |
1888 | ret = rdev->desc->ops->list_voltage(rdev, sel); | 1888 | ret = rdev->desc->ops->list_voltage(rdev, sel); |
1889 | } | 1889 | } else if (rdev->desc->ops->get_voltage) { |
1890 | if (rdev->desc->ops->get_voltage) | ||
1891 | ret = rdev->desc->ops->get_voltage(rdev); | 1890 | ret = rdev->desc->ops->get_voltage(rdev); |
1892 | else | 1891 | } else { |
1893 | return -EINVAL; | 1892 | return -EINVAL; |
1893 | } | ||
1894 | 1894 | ||
1895 | if (ret < 0) | ||
1896 | return ret; | ||
1895 | return ret - rdev->constraints->uV_offset; | 1897 | return ret - rdev->constraints->uV_offset; |
1896 | } | 1898 | } |
1897 | 1899 | ||