lkml.org 
[lkml]   [2011]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 3/4] REGULATOR: TWL6025: add support to twl-regulator
    On Wed, Apr 27, 2011 at 10:39:50AM +0100, Graeme Gregory wrote:

    > + switch (info->flags) {
    > + case 0:
    > + if (index == 0)
    > + voltage = 0;
    > + else if (index < 58)
    > + voltage = (600000 + (12500 * (index - 1)));
    > + else if (index == 58)
    > + voltage = 1350 * 1000;
    > + else if (index == 59)
    > + voltage = 1500 * 1000;
    > + else if (index == 60)
    > + voltage = 1800 * 1000;
    > + else if (index == 61)
    > + voltage = 1900 * 1000;
    > + else if (index == 62)
    > + voltage = 2100 * 1000;

    This reads like a switch statement with a default: case to me.

    > +static int twl6030dcdc_get_voltage(struct regulator_dev *rdev)
    > +{
    > + struct twlreg_info *info = rdev_get_drvdata(rdev);
    > + int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
    > + VREG_VOLTAGE_DCDC);
    > + int voltage = 0;
    > +
    > + if (vsel < 0)
    > + return vsel;
    > + switch (info->flags) {

    This should just call list_voltage() to do the mapping into a voltage or
    better yet should be converted into a get_voltage_sel() which will mean
    that the core can call list_voltage() for you. Either way you save
    duplicating the code to map from selector to voltage.


    \
     
     \ /
      Last update: 2011-04-27 13:11    [W:0.023 / U:0.908 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site