Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 357621
b: refs/heads/master
c: 0903940
h: refs/heads/master
i:
  357619: 193d37b
v: v3
  • Loading branch information
Jonas Aaberg authored and Lee Jones committed Feb 4, 2013
1 parent 207bdf8 commit 855312e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7c34d7c2b54818078678a6507ce9a79c3d479243
refs/heads/master: 0903940dcddcaa3f567a1a2308b0c55e2ce0643b
27 changes: 22 additions & 5 deletions trunk/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 855312e

Please sign in to comment.