Skip to content

Commit

Permalink
mfd: ab8500-sysctrl: Only reboot into charging mode if battery type i…
Browse files Browse the repository at this point in the history
…s 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>
  • Loading branch information
Jonas Aaberg authored and Lee Jones committed Feb 4, 2013
1 parent 7c34d7c commit 0903940
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions drivers/mfd/ab8500-sysctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,47 @@ void ab8500_power_off(void)
sigset_t all;
static char *pss[] = {"ab8500_ac", "ab8500_usb"};
int i;
bool charger_present = false;
union power_supply_propval val;
struct power_supply *psy;
int ret;

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

for (i = 0; i < ARRAY_SIZE(pss); i++) {
union power_supply_propval val;
struct power_supply *psy;
int ret;

psy = power_supply_get_by_name(pss[i]);
if (!psy)
continue;

ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);

if (!ret && val.intval) {
charger_present = true;
break;
}
}

if (!charger_present)
goto shutdown;

/* Check if battery is known */
psy = power_supply_get_by_name("ab8500_btemp");
if (psy) {
ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY,
&val);
if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) {
printk(KERN_INFO
"Charger \"%s\" is connected. Rebooting.\n",
"Charger \"%s\" is connected with known battery."
" Rebooting.\n",
pss[i]);
machine_restart(NULL);
}
}

shutdown:
sigfillset(&all);

if (!sigprocmask(SIG_BLOCK, &all, &old)) {
Expand Down

0 comments on commit 0903940

Please sign in to comment.