GIT 297e3883a9a58ace8bd66c15c632b054b4b262e3 git://git.infradead.org/battery-2.6.git commit Author: Andres Salomon Date: Wed Dec 12 14:12:59 2007 -0500 power: fix incorrect unregistration in power_supply_create_attrs error path In power_supply_create_attrs(), we create static attributes as referenced by power_supply_static_attrs[i]. After that, if we fail, we unregister via power_supply_static_attrs[psy->properties[i]]. This is incorrect, as psy->properties has absolutely no bearing on static attribs. This patch fixes it to unregister the correct attrib. Another line which was unnecessarily line wrapped is also unwrapped. Signed-off-by: Andres Salomon Signed-off-by: David Woodhouse commit 2f109f2764e0f0fdbfaf1816b7c1bb259d72f6f5 Author: Andres Salomon Date: Wed Dec 12 14:12:56 2007 -0500 power: remove POWER_SUPPLY_PROP_CAPACITY_LEVEL The CAPACITY_LEVEL stuff defines various levels of charge; however, what is the difference between them? What differentiates between HIGH and NORMAL, LOW and CRITICAL, etc? As it appears that these are fairly arbitrary, we end up making such policy decisions in the kernel (or in hardware). This is the sort of decision that should be made in userspace, not in the kernel. If the hardware does not support _CAPACITY and it cannot be easily calculated, then perhaps the driver should register a custom CAPACITY_LEVEL attribute; however, userspace should not become accustomed to looking for such a thing, and we should certainly not encourage drivers to provide CAPACITY_LEVEL stubs. The following removes support for POWER_SUPPLY_PROP_CAPACITY_LEVEL. The OLPC battery driver is the only driver making use of this, so it's removed from there as well. Signed-off-by: Andres Salomon Signed-off-by: David Woodhouse commit 378ec823a8bd08cf422c27269b1bba99211b0640 Author: Akinobu Mita Date: Sat Nov 17 19:55:58 2007 +0900 [BATTERY] power_supply_leds: use kasprintf Use kasprintf instead of kmalloc()-strcpy()-strcat(). Cc: Anton Vorontsov Cc: David Woodhouse Signed-off-by: Akinobu Mita Signed-off-by: Anton Vorontsov commit 38795503d3f2b22118748e8b52f81e407b81948c Author: Adrian Bunk Date: Mon Nov 26 00:25:45 2007 +0300 [BATTERY] Every file should include the headers containing the prototypes for its global functions. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Anton Vorontsov Documentation/power_supply_class.txt | 2 -- drivers/power/olpc_battery.c | 9 --------- drivers/power/power_supply_leds.c | 27 +++++++++------------------ drivers/power/power_supply_sysfs.c | 14 ++++---------- include/linux/power_supply.h | 10 ---------- 5 files changed, 13 insertions(+), 49 deletions(-) diff --git a/Documentation/power_supply_class.txt b/Documentation/power_supply_class.txt index 9758cf4..a032c31 100644 --- a/Documentation/power_supply_class.txt +++ b/Documentation/power_supply_class.txt @@ -100,8 +100,6 @@ age)". I.e. these attributes represents real thresholds, not design values. ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. CAPACITY - capacity in percents. -CAPACITY_LEVEL - capacity level. This corresponds to -POWER_SUPPLY_CAPACITY_LEVEL_*. TEMP - temperature of the power supply. TEMP_AMBIENT - ambient temperature. diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index c998e68..af7a231 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c @@ -226,14 +226,6 @@ static int olpc_bat_get_property(struct power_supply *psy, return ret; val->intval = ec_byte; break; - case POWER_SUPPLY_PROP_CAPACITY_LEVEL: - if (ec_byte & BAT_STAT_FULL) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; - else if (ec_byte & BAT_STAT_LOW) - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; - else - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; - break; case POWER_SUPPLY_PROP_TEMP: ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); if (ret) @@ -265,7 +257,6 @@ static enum power_supply_property olpc_bat_props[] = { POWER_SUPPLY_PROP_VOLTAGE_AVG, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CAPACITY, - POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP_AMBIENT, POWER_SUPPLY_PROP_MANUFACTURER, diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c index 7f8f359..fa3034f 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 #include +#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; diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 249f61b..bab591b 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -14,6 +14,8 @@ #include #include +#include "power_supply.h" + /* * This is because the name "current" breaks the device attr macro. * The "current" word resolves to "(get_current())" so instead of @@ -48,9 +50,6 @@ static ssize_t power_supply_show_property(struct device *dev, static char *technology_text[] = { "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd" }; - static char *capacity_level_text[] = { - "Unknown", "Critical", "Low", "Normal", "High", "Full" - }; ssize_t ret; struct power_supply *psy = dev_get_drvdata(dev); const ptrdiff_t off = attr - power_supply_attrs; @@ -71,9 +70,6 @@ static ssize_t power_supply_show_property(struct device *dev, return sprintf(buf, "%s\n", health_text[value.intval]); else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) return sprintf(buf, "%s\n", technology_text[value.intval]); - else if (off == POWER_SUPPLY_PROP_CAPACITY_LEVEL) - return sprintf(buf, "%s\n", - capacity_level_text[value.intval]); else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) return sprintf(buf, "%s\n", value.strval); @@ -159,8 +155,7 @@ dynamics_failed: &power_supply_attrs[psy->properties[j]]); statics_failed: while (i--) - device_remove_file(psy->dev, - &power_supply_static_attrs[psy->properties[i]]); + device_remove_file(psy->dev, &power_supply_static_attrs[i]); succeed: return rc; } @@ -170,8 +165,7 @@ void power_supply_remove_attrs(struct power_supply *psy) int i; for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); i++) - device_remove_file(psy->dev, - &power_supply_static_attrs[i]); + device_remove_file(psy->dev, &power_supply_static_attrs[i]); for (i = 0; i < psy->num_properties; i++) device_remove_file(psy->dev, diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 606c095..358b38d 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -56,15 +56,6 @@ enum { POWER_SUPPLY_TECHNOLOGY_NiCd, }; -enum { - POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0, - POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL, - POWER_SUPPLY_CAPACITY_LEVEL_LOW, - POWER_SUPPLY_CAPACITY_LEVEL_NORMAL, - POWER_SUPPLY_CAPACITY_LEVEL_HIGH, - POWER_SUPPLY_CAPACITY_LEVEL_FULL, -}; - enum power_supply_property { /* Properties of type `int' */ POWER_SUPPLY_PROP_STATUS = 0, @@ -91,7 +82,6 @@ enum power_supply_property { POWER_SUPPLY_PROP_ENERGY_NOW, POWER_SUPPLY_PROP_ENERGY_AVG, POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ - POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP_AMBIENT, POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,