aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/power_supply_sysfs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-02-01 23:13:05 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-02-01 23:13:05 -0500
commitae9458d6a0956aa21cb49e1251e35a8d4dacbe6e (patch)
tree98c162c79113bc2bd748a3ad5b6fb5ba66139751 /drivers/power/power_supply_sysfs.c
parent63e9b66e29357dd12e8b1d3ebf7036e7591f81e3 (diff)
parente91926e9ea9073d8ce95b74602e8c2d775f5a793 (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_sysfs.c')
-rw-r--r--drivers/power/power_supply_sysfs.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 249f61bae639..d4824840c5bf 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -14,6 +14,8 @@
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/power_supply.h> 15#include <linux/power_supply.h>
16 16
17#include "power_supply.h"
18
17/* 19/*
18 * This is because the name "current" breaks the device attr macro. 20 * This is because the name "current" breaks the device attr macro.
19 * The "current" word resolves to "(get_current())" so instead of 21 * The "current" word resolves to "(get_current())" so instead of
@@ -46,10 +48,8 @@ static ssize_t power_supply_show_property(struct device *dev,
46 "Unspecified failure" 48 "Unspecified failure"
47 }; 49 };
48 static char *technology_text[] = { 50 static char *technology_text[] = {
49 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd" 51 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd",
50 }; 52 "LiMn"
51 static char *capacity_level_text[] = {
52 "Unknown", "Critical", "Low", "Normal", "High", "Full"
53 }; 53 };
54 ssize_t ret; 54 ssize_t ret;
55 struct power_supply *psy = dev_get_drvdata(dev); 55 struct power_supply *psy = dev_get_drvdata(dev);
@@ -71,9 +71,6 @@ static ssize_t power_supply_show_property(struct device *dev,
71 return sprintf(buf, "%s\n", health_text[value.intval]); 71 return sprintf(buf, "%s\n", health_text[value.intval]);
72 else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) 72 else if (off == POWER_SUPPLY_PROP_TECHNOLOGY)
73 return sprintf(buf, "%s\n", technology_text[value.intval]); 73 return sprintf(buf, "%s\n", technology_text[value.intval]);
74 else if (off == POWER_SUPPLY_PROP_CAPACITY_LEVEL)
75 return sprintf(buf, "%s\n",
76 capacity_level_text[value.intval]);
77 else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) 74 else if (off >= POWER_SUPPLY_PROP_MODEL_NAME)
78 return sprintf(buf, "%s\n", value.strval); 75 return sprintf(buf, "%s\n", value.strval);
79 76
@@ -88,6 +85,8 @@ static struct device_attribute power_supply_attrs[] = {
88 POWER_SUPPLY_ATTR(present), 85 POWER_SUPPLY_ATTR(present),
89 POWER_SUPPLY_ATTR(online), 86 POWER_SUPPLY_ATTR(online),
90 POWER_SUPPLY_ATTR(technology), 87 POWER_SUPPLY_ATTR(technology),
88 POWER_SUPPLY_ATTR(voltage_max),
89 POWER_SUPPLY_ATTR(voltage_min),
91 POWER_SUPPLY_ATTR(voltage_max_design), 90 POWER_SUPPLY_ATTR(voltage_max_design),
92 POWER_SUPPLY_ATTR(voltage_min_design), 91 POWER_SUPPLY_ATTR(voltage_min_design),
93 POWER_SUPPLY_ATTR(voltage_now), 92 POWER_SUPPLY_ATTR(voltage_now),
@@ -159,8 +158,7 @@ dynamics_failed:
159 &power_supply_attrs[psy->properties[j]]); 158 &power_supply_attrs[psy->properties[j]]);
160statics_failed: 159statics_failed:
161 while (i--) 160 while (i--)
162 device_remove_file(psy->dev, 161 device_remove_file(psy->dev, &power_supply_static_attrs[i]);
163 &power_supply_static_attrs[psy->properties[i]]);
164succeed: 162succeed:
165 return rc; 163 return rc;
166} 164}
@@ -170,8 +168,7 @@ void power_supply_remove_attrs(struct power_supply *psy)
170 int i; 168 int i;
171 169
172 for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); i++) 170 for (i = 0; i < ARRAY_SIZE(power_supply_static_attrs); i++)
173 device_remove_file(psy->dev, 171 device_remove_file(psy->dev, &power_supply_static_attrs[i]);
174 &power_supply_static_attrs[i]);
175 172
176 for (i = 0; i < psy->num_properties; i++) 173 for (i = 0; i < psy->num_properties; i++)
177 device_remove_file(psy->dev, 174 device_remove_file(psy->dev,