public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Add checking set_mode callback in regulator_set_optimum_mode
@ 2012-04-13 10:49 Axel Lin
  2012-04-14  5:00 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-04-13 10:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood

regulator_set_optimum_mode needs set_mode to properly work.
Add checking for set_mode callback in case it may be not implemented.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/core.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1bd71a8..f241671 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2340,6 +2340,11 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
 	 */
 	ret = -EINVAL;
 
+	if (!rdev->desc->ops->set_mode) {
+		rdev_err(rdev, "no set_mode operation\n");
+		goto out;
+	}
+
 	/* get output voltage */
 	output_uV = _regulator_get_voltage(rdev);
 	if (output_uV <= 0) {
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: core: Add checking set_mode callback in regulator_set_optimum_mode
  2012-04-13 10:49 [PATCH] regulator: core: Add checking set_mode callback in regulator_set_optimum_mode Axel Lin
@ 2012-04-14  5:00 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2012-04-14  5:00 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Mark Brown, Liam Girdwood

On 4/13/2012 3:49 AM, Axel Lin wrote:
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 1bd71a8..f241671 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -2340,6 +2340,11 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
>  	 */
>  	ret = -EINVAL;
>  
> +	if (!rdev->desc->ops->set_mode) {
> +		rdev_err(rdev, "no set_mode operation\n");
> +		goto out;
> +	}
> +
>  	/* get output voltage */

regulator_set_mode() just returns an error silently if there isn't a
set_mode() op. Why print an error in this case?

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-14  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-13 10:49 [PATCH] regulator: core: Add checking set_mode callback in regulator_set_optimum_mode Axel Lin
2012-04-14  5:00 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox