[lkml]   [2012]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: drivers/regulator/core.c: Fixes mapping inside regulator_mode_to_status() and makes it returning -EINVAL on invalid input.
    On Tue, Jan 10, 2012 at 12:14 AM, Mark Brown
    <> wrote:
    > On Tue, Jan 10, 2012 at 12:11:33AM +0000, dd diasemi wrote:
    >> Making regulator_mode_to_status() returning an error allows to
    >> simplify its usage:
    >>       ret = regulator_mode_to_status(regulator_get_mode(rdev));
    >>       if (ret < 0)
    >>               ret = -EIO;
    > That code would definitely be less than ideal - if we got an error back
    > from the attempt to read the mode we ought to be returning that error
    > not squashing it down to a single value.

    Yes, indeed.

    >> If that behaviour is deliberate, I would suggest to make it explicit:
    >> default:
    >> - return 0;
    >> + return REGULATOR_STATUS_OFF;
    > That's not the deliberate behaviour, the deliberate behaviour is to
    > return no mode if we didn't find one.

    The behaviour is exactly the same in both cases, because

    From linux/regulator/driver.h:
    enum regulator_status {
    /* fast/normal/idle/standby are flavors of "on" */

    So the only difference is that, the code:
    return 0;
    is not obvious but still it will be interpreted as:
    by the caller of regulator_mode_to_status() when incorrect mode is passed.
    Is it correct way to hide this behaviour rather than to make it explicit ?

    And to set things up, should regulator_get_status() return negative
    error code or REGULATOR_STATUS_OFF (0) on communication failure?
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2012-01-10 18:13    [W:0.021 / U:97.580 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site