diff options
author | Jonas Aaberg <jonas.aberg@stericsson.com> | 2011-08-17 09:58:52 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-02-04 03:28:44 -0500 |
commit | 0903940dcddcaa3f567a1a2308b0c55e2ce0643b (patch) | |
tree | aa0caeaaeb211105560edc2d23e09ec1aff3ad64 /drivers/mfd/ab8500-sysctrl.c | |
parent | 7c34d7c2b54818078678a6507ce9a79c3d479243 (diff) |
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>
Diffstat (limited to 'drivers/mfd/ab8500-sysctrl.c')
-rw-r--r-- | drivers/mfd/ab8500-sysctrl.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index 188d22b77a28..405ca686d9f3 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c | |||
@@ -23,6 +23,10 @@ void ab8500_power_off(void) | |||
23 | sigset_t all; | 23 | sigset_t all; |
24 | static char *pss[] = {"ab8500_ac", "ab8500_usb"}; | 24 | static char *pss[] = {"ab8500_ac", "ab8500_usb"}; |
25 | int i; | 25 | int i; |
26 | bool charger_present = false; | ||
27 | union power_supply_propval val; | ||
28 | struct power_supply *psy; | ||
29 | int ret; | ||
26 | 30 | ||
27 | /* | 31 | /* |
28 | * If we have a charger connected and we're powering off, | 32 | * If we have a charger connected and we're powering off, |
@@ -30,23 +34,36 @@ void ab8500_power_off(void) | |||
30 | */ | 34 | */ |
31 | 35 | ||
32 | for (i = 0; i < ARRAY_SIZE(pss); i++) { | 36 | for (i = 0; i < ARRAY_SIZE(pss); i++) { |
33 | union power_supply_propval val; | ||
34 | struct power_supply *psy; | ||
35 | int ret; | ||
36 | |||
37 | psy = power_supply_get_by_name(pss[i]); | 37 | psy = power_supply_get_by_name(pss[i]); |
38 | if (!psy) | 38 | if (!psy) |
39 | continue; | 39 | continue; |
40 | |||
40 | ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); | 41 | ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); |
41 | 42 | ||
42 | if (!ret && val.intval) { | 43 | 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) { | ||
43 | printk(KERN_INFO | 58 | printk(KERN_INFO |
44 | "Charger \"%s\" is connected. Rebooting.\n", | 59 | "Charger \"%s\" is connected with known battery." |
60 | " Rebooting.\n", | ||
45 | pss[i]); | 61 | pss[i]); |
46 | machine_restart(NULL); | 62 | machine_restart(NULL); |
47 | } | 63 | } |
48 | } | 64 | } |
49 | 65 | ||
66 | shutdown: | ||
50 | sigfillset(&all); | 67 | sigfillset(&all); |
51 | 68 | ||
52 | if (!sigprocmask(SIG_BLOCK, &all, &old)) { | 69 | if (!sigprocmask(SIG_BLOCK, &all, &old)) { |