diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-02-02 15:13:05 +1100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-02-02 15:13:05 +1100 |
commit | ae9458d6a0956aa21cb49e1251e35a8d4dacbe6e (patch) | |
tree | 98c162c79113bc2bd748a3ad5b6fb5ba66139751 /drivers/power/power_supply_leds.c | |
parent | 63e9b66e29357dd12e8b1d3ebf7036e7591f81e3 (diff) | |
parent | e91926e9ea9073d8ce95b74602e8c2d775f5a793 (diff) |
Merge git://git.infradead.org/battery-2.6
* git://git.infradead.org/battery-2.6:
apm_power: check I.intval for zero value, we use it as the divisor
MAINTAINERS: remove kernel-discuss@handhelds.org list
pda_power: implement polling
pda_power: various cleanups
apm_power: support using VOLTAGE_* properties for apm calculations
pda_power: add suspend/resume support
power_supply: add few more values and props
pda_power: only register available psu
power: fix incorrect unregistration in power_supply_create_attrs error path
power: remove POWER_SUPPLY_PROP_CAPACITY_LEVEL
[BATTERY] power_supply_leds: use kasprintf
[BATTERY] Every file should include the headers containing the prototypes for its global functions.
Diffstat (limited to 'drivers/power/power_supply_leds.c')
-rw-r--r-- | drivers/power/power_supply_leds.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c index 7f8f3590b02..fa3034f85c3 100644 --- a/drivers/power/power_supply_leds.c +++ b/drivers/power/power_supply_leds.c @@ -10,8 +10,11 @@ * You may use this code as per GPL version 2 */ +#include <linux/kernel.h> #include <linux/power_supply.h> +#include "power_supply.h" + /* Battery specific LEDs triggers. */ static void power_supply_update_bat_leds(struct power_supply *psy) @@ -46,28 +49,20 @@ static int power_supply_create_bat_triggers(struct power_supply *psy) { int rc = 0; - psy->charging_full_trig_name = kmalloc(strlen(psy->name) + - sizeof("-charging-or-full"), GFP_KERNEL); + psy->charging_full_trig_name = kasprintf(GFP_KERNEL, + "%s-charging-or-full", psy->name); if (!psy->charging_full_trig_name) goto charging_full_failed; - psy->charging_trig_name = kmalloc(strlen(psy->name) + - sizeof("-charging"), GFP_KERNEL); + psy->charging_trig_name = kasprintf(GFP_KERNEL, + "%s-charging", psy->name); if (!psy->charging_trig_name) goto charging_failed; - psy->full_trig_name = kmalloc(strlen(psy->name) + - sizeof("-full"), GFP_KERNEL); + psy->full_trig_name = kasprintf(GFP_KERNEL, "%s-full", psy->name); if (!psy->full_trig_name) goto full_failed; - strcpy(psy->charging_full_trig_name, psy->name); - strcat(psy->charging_full_trig_name, "-charging-or-full"); - strcpy(psy->charging_trig_name, psy->name); - strcat(psy->charging_trig_name, "-charging"); - strcpy(psy->full_trig_name, psy->name); - strcat(psy->full_trig_name, "-full"); - led_trigger_register_simple(psy->charging_full_trig_name, &psy->charging_full_trig); led_trigger_register_simple(psy->charging_trig_name, @@ -118,14 +113,10 @@ static int power_supply_create_gen_triggers(struct power_supply *psy) { int rc = 0; - psy->online_trig_name = kmalloc(strlen(psy->name) + sizeof("-online"), - GFP_KERNEL); + psy->online_trig_name = kasprintf(GFP_KERNEL, "%s-online", psy->name); if (!psy->online_trig_name) goto online_failed; - strcpy(psy->online_trig_name, psy->name); - strcat(psy->online_trig_name, "-online"); - led_trigger_register_simple(psy->online_trig_name, &psy->online_trig); goto success; |