From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH v2] regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
Date: Fri, 20 May 2011 08:36:06 +0800 [thread overview]
Message-ID: <1305851766.2244.2.camel@phoenix> (raw)
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
next reply other threads:[~2011-05-20 0:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-20 0:36 Axel Lin [this message]
2011-05-20 10:23 ` [PATCH v2] regulator: Fix _regulator_get_voltage if get_voltage callback is NULL Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1305851766.2244.2.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox