1
0
Fork 0

max77818-charger: drop max77818_charger_init_dev and max77818_charger_exit_dev

These two functions now only enable/disable charger and are called by
max77818_do_irq().  Let's simplify the code a little bit by drop the
functions and call max77818_charger_set_enable() from max77818_do_irq()
directly.

While at it, flip the order of dev_info() message output and
max77818_charger_set_enable() call, as it's more natural to print the
event message and then take action on the event.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
pull/10/head
Shawn Guo 2019-08-16 15:40:58 +02:00 committed by Steinar Bakkemo
parent 2d50391fec
commit d9ac174917
1 changed files with 6 additions and 42 deletions

View File

@ -666,32 +666,6 @@ static int max77818_charger_property_is_writeable(struct power_supply *psy,
}
}
static int max77818_charger_exit_dev(struct max77818_charger *chg)
{
int ret;
ret = max77818_charger_set_enable(chg, false);
if (ret) {
dev_err(chg->dev, "failed to disable charger: %d\n", ret);
return ret;
}
return 0;
}
static int max77818_charger_init_dev(struct max77818_charger *chg)
{
int ret;
ret = max77818_charger_set_enable(chg, true);
if (ret) {
dev_err(chg->dev, "failed to enable charger: %d\n", ret);
return ret;
}
return 0;
}
static void max77818_do_irq(struct max77818_charger *chg)
{
struct device *dev = chg->dev;
@ -704,31 +678,21 @@ static void max77818_do_irq(struct max77818_charger *chg)
chg_input = max77818_charger_chgin_present(chg);
wc_input = max77818_charger_wcin_present(chg);
if (!wc_input) {
/* init/exit if only CHGIN is present */
if (chg_input)
max77818_charger_init_dev(chg);
else
max77818_charger_exit_dev(chg);
}
dev_info(dev, "CHGIN input %s\n", chg_input ? "inserted" :
"removed");
/* if CHGIN is the only present charger */
if (!wc_input)
max77818_charger_set_enable(chg, chg_input ? 1 : 0);
break;
case CHG_INT_WCIN_I:
chg_input = max77818_charger_chgin_present(chg);
wc_input = max77818_charger_wcin_present(chg);
if (!chg_input) {
/* init/exit if only WCIN is present */
if (wc_input)
max77818_charger_init_dev(chg);
else
max77818_charger_exit_dev(chg);
}
dev_info(dev, "WCIN input %s\n", wc_input ? "inserted" :
"removed");
/* if WCIN is the only present charger */
if (!chg_input)
max77818_charger_set_enable(chg, wc_input ? 1 : 0);
break;
default:
break;