diff options
author | Vasily Khoruzhick <anarsoul@gmail.com> | 2011-01-07 11:28:17 -0500 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2011-01-31 08:31:51 -0500 |
commit | 6501f728c56f831626d52b236023e556bca37f51 (patch) | |
tree | 323e1764a2117b861a150eb0bb328e6dd6ebbf59 /drivers/power | |
parent | 0b9536c957095eb1497828aa51b34ac695f67eae (diff) |
power_supply: Add new LED trigger charging-blink-solid-full
Add new trigger to power_supply LEDs. It will blink when battery is
charging, and stay solid when battery is charged. It's usefull to
indicate battery state when there's only one LED available.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/power_supply_leds.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c index 031a554837f7..da25eb94e5c6 100644 --- a/drivers/power/power_supply_leds.c +++ b/drivers/power/power_supply_leds.c | |||
@@ -21,6 +21,8 @@ | |||
21 | static void power_supply_update_bat_leds(struct power_supply *psy) | 21 | static void power_supply_update_bat_leds(struct power_supply *psy) |
22 | { | 22 | { |
23 | union power_supply_propval status; | 23 | union power_supply_propval status; |
24 | unsigned long delay_on = 0; | ||
25 | unsigned long delay_off = 0; | ||
24 | 26 | ||
25 | if (psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &status)) | 27 | if (psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &status)) |
26 | return; | 28 | return; |
@@ -32,16 +34,22 @@ static void power_supply_update_bat_leds(struct power_supply *psy) | |||
32 | led_trigger_event(psy->charging_full_trig, LED_FULL); | 34 | led_trigger_event(psy->charging_full_trig, LED_FULL); |
33 | led_trigger_event(psy->charging_trig, LED_OFF); | 35 | led_trigger_event(psy->charging_trig, LED_OFF); |
34 | led_trigger_event(psy->full_trig, LED_FULL); | 36 | led_trigger_event(psy->full_trig, LED_FULL); |
37 | led_trigger_event(psy->charging_blink_full_solid_trig, | ||
38 | LED_FULL); | ||
35 | break; | 39 | break; |
36 | case POWER_SUPPLY_STATUS_CHARGING: | 40 | case POWER_SUPPLY_STATUS_CHARGING: |
37 | led_trigger_event(psy->charging_full_trig, LED_FULL); | 41 | led_trigger_event(psy->charging_full_trig, LED_FULL); |
38 | led_trigger_event(psy->charging_trig, LED_FULL); | 42 | led_trigger_event(psy->charging_trig, LED_FULL); |
39 | led_trigger_event(psy->full_trig, LED_OFF); | 43 | led_trigger_event(psy->full_trig, LED_OFF); |
44 | led_trigger_blink(psy->charging_blink_full_solid_trig, | ||
45 | &delay_on, &delay_off); | ||
40 | break; | 46 | break; |
41 | default: | 47 | default: |
42 | led_trigger_event(psy->charging_full_trig, LED_OFF); | 48 | led_trigger_event(psy->charging_full_trig, LED_OFF); |
43 | led_trigger_event(psy->charging_trig, LED_OFF); | 49 | led_trigger_event(psy->charging_trig, LED_OFF); |
44 | led_trigger_event(psy->full_trig, LED_OFF); | 50 | led_trigger_event(psy->full_trig, LED_OFF); |
51 | led_trigger_event(psy->charging_blink_full_solid_trig, | ||
52 | LED_OFF); | ||
45 | break; | 53 | break; |
46 | } | 54 | } |
47 | } | 55 | } |
@@ -64,15 +72,24 @@ static int power_supply_create_bat_triggers(struct power_supply *psy) | |||
64 | if (!psy->full_trig_name) | 72 | if (!psy->full_trig_name) |
65 | goto full_failed; | 73 | goto full_failed; |
66 | 74 | ||
75 | psy->charging_blink_full_solid_trig_name = kasprintf(GFP_KERNEL, | ||
76 | "%s-charging-blink-full-solid", psy->name); | ||
77 | if (!psy->charging_blink_full_solid_trig_name) | ||
78 | goto charging_blink_full_solid_failed; | ||
79 | |||
67 | led_trigger_register_simple(psy->charging_full_trig_name, | 80 | led_trigger_register_simple(psy->charging_full_trig_name, |
68 | &psy->charging_full_trig); | 81 | &psy->charging_full_trig); |
69 | led_trigger_register_simple(psy->charging_trig_name, | 82 | led_trigger_register_simple(psy->charging_trig_name, |
70 | &psy->charging_trig); | 83 | &psy->charging_trig); |
71 | led_trigger_register_simple(psy->full_trig_name, | 84 | led_trigger_register_simple(psy->full_trig_name, |
72 | &psy->full_trig); | 85 | &psy->full_trig); |
86 | led_trigger_register_simple(psy->charging_blink_full_solid_trig_name, | ||
87 | &psy->charging_blink_full_solid_trig); | ||
73 | 88 | ||
74 | goto success; | 89 | goto success; |
75 | 90 | ||
91 | charging_blink_full_solid_failed: | ||
92 | kfree(psy->full_trig_name); | ||
76 | full_failed: | 93 | full_failed: |
77 | kfree(psy->charging_trig_name); | 94 | kfree(psy->charging_trig_name); |
78 | charging_failed: | 95 | charging_failed: |
@@ -88,6 +105,8 @@ static void power_supply_remove_bat_triggers(struct power_supply *psy) | |||
88 | led_trigger_unregister_simple(psy->charging_full_trig); | 105 | led_trigger_unregister_simple(psy->charging_full_trig); |
89 | led_trigger_unregister_simple(psy->charging_trig); | 106 | led_trigger_unregister_simple(psy->charging_trig); |
90 | led_trigger_unregister_simple(psy->full_trig); | 107 | led_trigger_unregister_simple(psy->full_trig); |
108 | led_trigger_unregister_simple(psy->charging_blink_full_solid_trig); | ||
109 | kfree(psy->charging_blink_full_solid_trig_name); | ||
91 | kfree(psy->full_trig_name); | 110 | kfree(psy->full_trig_name); |
92 | kfree(psy->charging_trig_name); | 111 | kfree(psy->charging_trig_name); |
93 | kfree(psy->charging_full_trig_name); | 112 | kfree(psy->charging_full_trig_name); |