Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 357620
b: refs/heads/master
c: 7c34d7c
h: refs/heads/master
v: v3
  • Loading branch information
Jonas Aaberg authored and Lee Jones committed Feb 4, 2013
1 parent 193d37b commit 207bdf8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 379749c46320c82df95c7909ec888da8ed1fb22c
refs/heads/master: 7c34d7c2b54818078678a6507ce9a79c3d479243
27 changes: 27 additions & 0 deletions trunk/drivers/mfd/ab8500-sysctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/reboot.h>
#include <linux/signal.h>
#include <linux/power_supply.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-sysctrl.h>
Expand All @@ -19,6 +21,31 @@ void ab8500_power_off(void)
{
sigset_t old;
sigset_t all;
static char *pss[] = {"ab8500_ac", "ab8500_usb"};
int i;

/*
* 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) {
printk(KERN_INFO
"Charger \"%s\" is connected. Rebooting.\n",
pss[i]);
machine_restart(NULL);
}
}

sigfillset(&all);

Expand Down

0 comments on commit 207bdf8

Please sign in to comment.