lkml.org 
[lkml]   [2012]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: drivers/regulator/core.c: Fixes mapping inside regulator_mode_to_status() and makes it returning -EINVAL on invalid input.
From
On Mon, Jan 9, 2012 at 4:14 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Mon, Jan 09, 2012 at 12:12:20PM +0000, Krystian Garbaciak wrote:
>> Minor fix that makes the function working correctly with
>> REGULATOR_MODE_STANDBY as parameter.
>> Also, on invalid input (bad mode), it is better to return -EINVAL,
>> instead of meaningless 0 value (which actually is interpreted as
>> REGULATOR_STATUS_OFF).
>>
>> ---
>
>>       default:
>> -             return 0;
>> +             return -EINVAL;
>
> This behaviour is deliberate.

For this moment, the only usage is in one file in
wm831x_aldo_get_status() and wm831x_gp_ldo_get_status():
ret = wm831x_aldo_get_mode(rdev);
if (ret < 0)
return ret;
else
return regulator_mode_to_status(ret);

The usage mistreats the signed value 'ret' as wm831x_aldo_get_mode()
always returns 0 on communication error. It effects in response as if
the regulator was off.

If that behaviour is deliberate, I would suggest to make it explicit:
default:
- return 0;
+ return REGULATOR_STATUS_OFF;
--
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: 2012-01-09 20:23    [W:0.031 / U:3.080 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site