lkml.org 
[lkml]   [2011]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [RFC][PATCH] regulator: Fix _regulator_get_voltage if get_voltage callback is NULL
2011/5/19 Axel Lin <axel.lin@gmail.com>:
> 2011/5/19 Mark Brown <broonie@opensource.wolfsonmicro.com>:
>> On Wed, May 18, 2011 at 09:01:58PM +0800, Axel Lin wrote:
>>
>>> @@ -1886,13 +1886,15 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
>>>               if (sel < 0)
>>>                       return sel;
>>>               ret = rdev->desc->ops->list_voltage(rdev, sel);
>>> +             goto out;
>>>       }
>>
>> Why are you adding this goto?  It's not going to change anything...
>>
> no matter what ret value returns from rdev->desc->ops->list_voltage(rdev, sel);
>
> In the case of rdev->desc->ops->get_voltage is NULL,
> current implementation will always return -EINVAL;
>
hi Mark,
I'm thinking maybe you prefer changes like below:
How do you think?

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9493f61..2a2e927 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1887,12 +1887,12 @@ static int _regulator_get_voltage(struct
regulator_dev *rdev)
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
return -EINVAL;

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

/**

Regards,
Axel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-05-19 12:01    [W:0.047 / U:0.980 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site