diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2007-11-17 05:55:58 -0500 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2008-02-01 18:42:59 -0500 |
commit | 4d24473c435c7c3ad7b43e43b70cdb16aba25443 (patch) | |
tree | 576d2cd5a41471eae0e57fa3c5a66e44cdec39a4 /drivers/power | |
parent | 25f12141e2be96e904239d963e25818b8854e72f (diff) |
[BATTERY] power_supply_leds: use kasprintf
Use kasprintf instead of kmalloc()-strcpy()-strcat().
Cc: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Anton Vorontsov <cbou@mail.ru>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/power_supply_leds.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c index 80ca28840b1a..fa3034f85c38 100644 --- a/drivers/power/power_supply_leds.c +++ b/drivers/power/power_supply_leds.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * You may use this code as per GPL version 2 | 10 | * You may use this code as per GPL version 2 |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/kernel.h> | ||
13 | #include <linux/power_supply.h> | 14 | #include <linux/power_supply.h> |
14 | 15 | ||
15 | #include "power_supply.h" | 16 | #include "power_supply.h" |
@@ -48,28 +49,20 @@ static int power_supply_create_bat_triggers(struct power_supply *psy) | |||
48 | { | 49 | { |
49 | int rc = 0; | 50 | int rc = 0; |
50 | 51 | ||
51 | psy->charging_full_trig_name = kmalloc(strlen(psy->name) + | 52 | psy->charging_full_trig_name = kasprintf(GFP_KERNEL, |
52 | sizeof("-charging-or-full"), GFP_KERNEL); | 53 | "%s-charging-or-full", psy->name); |
53 | if (!psy->charging_full_trig_name) | 54 | if (!psy->charging_full_trig_name) |
54 | goto charging_full_failed; | 55 | goto charging_full_failed; |
55 | 56 | ||
56 | psy->charging_trig_name = kmalloc(strlen(psy->name) + | 57 | psy->charging_trig_name = kasprintf(GFP_KERNEL, |
57 | sizeof("-charging"), GFP_KERNEL); | 58 | "%s-charging", psy->name); |
58 | if (!psy->charging_trig_name) | 59 | if (!psy->charging_trig_name) |
59 | goto charging_failed; | 60 | goto charging_failed; |
60 | 61 | ||
61 | psy->full_trig_name = kmalloc(strlen(psy->name) + | 62 | psy->full_trig_name = kasprintf(GFP_KERNEL, "%s-full", psy->name); |
62 | sizeof("-full"), GFP_KERNEL); | ||
63 | if (!psy->full_trig_name) | 63 | if (!psy->full_trig_name) |
64 | goto full_failed; | 64 | goto full_failed; |
65 | 65 | ||
66 | strcpy(psy->charging_full_trig_name, psy->name); | ||
67 | strcat(psy->charging_full_trig_name, "-charging-or-full"); | ||
68 | strcpy(psy->charging_trig_name, psy->name); | ||
69 | strcat(psy->charging_trig_name, "-charging"); | ||
70 | strcpy(psy->full_trig_name, psy->name); | ||
71 | strcat(psy->full_trig_name, "-full"); | ||
72 | |||
73 | led_trigger_register_simple(psy->charging_full_trig_name, | 66 | led_trigger_register_simple(psy->charging_full_trig_name, |
74 | &psy->charging_full_trig); | 67 | &psy->charging_full_trig); |
75 | led_trigger_register_simple(psy->charging_trig_name, | 68 | led_trigger_register_simple(psy->charging_trig_name, |
@@ -120,14 +113,10 @@ static int power_supply_create_gen_triggers(struct power_supply *psy) | |||
120 | { | 113 | { |
121 | int rc = 0; | 114 | int rc = 0; |
122 | 115 | ||
123 | psy->online_trig_name = kmalloc(strlen(psy->name) + sizeof("-online"), | 116 | psy->online_trig_name = kasprintf(GFP_KERNEL, "%s-online", psy->name); |
124 | GFP_KERNEL); | ||
125 | if (!psy->online_trig_name) | 117 | if (!psy->online_trig_name) |
126 | goto online_failed; | 118 | goto online_failed; |
127 | 119 | ||
128 | strcpy(psy->online_trig_name, psy->name); | ||
129 | strcat(psy->online_trig_name, "-online"); | ||
130 | |||
131 | led_trigger_register_simple(psy->online_trig_name, &psy->online_trig); | 120 | led_trigger_register_simple(psy->online_trig_name, &psy->online_trig); |
132 | 121 | ||
133 | goto success; | 122 | goto success; |