summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-12-26 13:59:03 +0100
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>2018-01-08 18:38:57 +0100
commitbbafa111caa06339a1ca50a7230c56dea0dffbde (patch)
treebea3fa91a6d1251c2203ed53c538940a1b8d8a16 /drivers/power
parenta9904aa82806143641a04521f6d296a13f636834 (diff)
power: supply: axp288_charger: Use regmap_update_bits to set the input limits
Use regmap_update_bits in axp288_charger_set_vbus_inlmt, instead of DIY code. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/axp288_charger.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
index 03f502e012c3..7b48afca1a1f 100644
--- a/drivers/power/supply/axp288_charger.c
+++ b/drivers/power/supply/axp288_charger.c
@@ -222,14 +222,8 @@ static inline int axp288_charger_set_vbus_inlmt(struct axp288_chrg_info *info,
int inlmt)
{
int ret;
- unsigned int val;
u8 reg_val;
- /* Read in limit register */
- ret = regmap_read(info->regmap, AXP20X_CHRG_BAK_CTRL, &val);
- if (ret < 0)
- goto set_inlmt_fail;
-
if (inlmt <= ILIM_100MA) {
reg_val = CHRG_VBUS_ILIM_100MA;
inlmt = ILIM_100MA;
@@ -253,15 +247,15 @@ static inline int axp288_charger_set_vbus_inlmt(struct axp288_chrg_info *info,
inlmt = ILIM_3000MA;
}
- reg_val = (val & ~CHRG_VBUS_ILIM_MASK)
- | (reg_val << CHRG_VBUS_ILIM_BIT_POS);
- ret = regmap_write(info->regmap, AXP20X_CHRG_BAK_CTRL, reg_val);
+ reg_val = reg_val << CHRG_VBUS_ILIM_BIT_POS;
+
+ ret = regmap_update_bits(info->regmap, AXP20X_CHRG_BAK_CTRL,
+ CHRG_VBUS_ILIM_MASK, reg_val);
if (ret >= 0)
info->inlmt = inlmt;
else
dev_err(&info->pdev->dev, "charger BAK control %d\n", ret);
-set_inlmt_fail:
return ret;
}