lkml.org 
[lkml]   [2012]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 4/4] power-supply: smb347-charger: convert to regmap API
    On Mon, Apr 16, 2012 at 11:48:41AM +0300, Mika Westerberg wrote:
    > The smb347-charger driver does a lot of read-modify-write to the device
    > registers. Instead of open-coding everything we can take advantage of regmap
    > API which provides nice functions to do this kind of things.
    >
    > In addition there is no need for custom debugfs file for dumping registers as
    > this is already provided by the regmap API.
    >
    > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    [...]
    > static int smb347_set_temp_limits(struct smb347_charger *smb)
    > @@ -491,22 +468,13 @@ static int smb347_set_temp_limits(struct smb347_charger *smb)
    > val = clamp_val(val, 100, 130) - 100;
    > val /= 10;
    >
    > - ret = smb347_read(smb, CFG_OTG);
    > - if (ret < 0)
    > - return ret;
    > -
    > - ret &= ~CFG_OTG_TEMP_THRESHOLD_MASK;
    > - ret |= val << CFG_OTG_TEMP_THRESHOLD_SHIFT;
    > -
    > - ret = smb347_write(smb, CFG_OTG, ret);
    > + ret = regmap_update_bits(smb->regmap, CFG_OTG,
    > + CFG_OTG_TEMP_THRESHOLD_MASK,
    > + val << CFG_OTG_TEMP_THRESHOLD_SHIFT);
    > if (ret < 0)
    > return ret;
    > }
    >
    > - ret = smb347_read(smb, CFG_TEMP_LIMIT);
    > - if (ret < 0)
    > - return ret;
    > -

    FYI, removing these hunks causes the following warning:

    CC drivers/power/smb347-charger.o
    drivers/power/smb347-charger.c: In function ‘smb347_set_temp_limits’:
    drivers/power/smb347-charger.c:462:6: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized]

    I fixed this by the following change:

    diff --git a/drivers/power/smb347-charger.c b/drivers/power/smb347-charger.c
    index 1f27d21..cf31b31 100644
    --- a/drivers/power/smb347-charger.c
    +++ b/drivers/power/smb347-charger.c
    @@ -459,7 +459,8 @@ static int smb347_set_voltage_limits(struct smb347_charger *smb)
    static int smb347_set_temp_limits(struct smb347_charger *smb)
    {
    bool enable_therm_monitor = false;
    - int ret, val;
    + int ret = 0;
    + int val;

    if (smb->pdata->chip_temp_threshold) {
    val = smb->pdata->chip_temp_threshold;
    Please check if that's all OK.

    Thanks!

    --
    Anton Vorontsov
    Email: cbouatmailru@gmail.com
    --
    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-05-05 15:01    [W:0.024 / U:89.072 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site