Skip to content

Commit 0903940

Browse files
Jonas AabergLee Jones
authored andcommitted
mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known
When a charger is connected, we usually want AB8500 based systems to reboot into charging-only mode. However, if the battery type cannot be identified this would be futile, so we'll just shut the system down instead. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
1 parent 7c34d7c commit 0903940

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

‎drivers/mfd/ab8500-sysctrl.c‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,47 @@ void ab8500_power_off(void)
2323
sigset_t all;
2424
static char *pss[] = {"ab8500_ac", "ab8500_usb"};
2525
int i;
26+
bool charger_present = false;
27+
union power_supply_propval val;
28+
struct power_supply *psy;
29+
int ret;
2630

2731
/*
2832
* If we have a charger connected and we're powering off,
2933
* reboot into charge-only mode.
3034
*/
3135

3236
for (i = 0; i < ARRAY_SIZE(pss); i++) {
33-
union power_supply_propval val;
34-
struct power_supply *psy;
35-
int ret;
36-
3737
psy = power_supply_get_by_name(pss[i]);
3838
if (!psy)
3939
continue;
40+
4041
ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
4142

4243
if (!ret && val.intval) {
44+
charger_present = true;
45+
break;
46+
}
47+
}
48+
49+
if (!charger_present)
50+
goto shutdown;
51+
52+
/* Check if battery is known */
53+
psy = power_supply_get_by_name("ab8500_btemp");
54+
if (psy) {
55+
ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY,
56+
&val);
57+
if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) {
4358
printk(KERN_INFO
44-
"Charger \"%s\" is connected. Rebooting.\n",
59+
"Charger \"%s\" is connected with known battery."
60+
" Rebooting.\n",
4561
pss[i]);
4662
machine_restart(NULL);
4763
}
4864
}
4965

66+
shutdown:
5067
sigfillset(&all);
5168

5269
if (!sigprocmask(SIG_BLOCK, &all, &old)) {

0 commit comments

Comments
 (0)