diff options
author | Andres Salomon <dilinger@collabora.co.uk> | 2009-06-30 02:13:01 -0400 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2009-06-30 18:44:03 -0400 |
commit | b294a290d24d1196d68399cc3a9b8c50bfb55abd (patch) | |
tree | 6d8b2ec03c90bfc4ba3c478af9bfbd0e49b1b45a | |
parent | bfdb46ce8494eae30dbaae65c81e684e6db6228b (diff) |
Revert "power: remove POWER_SUPPLY_PROP_CAPACITY_LEVEL"
This reverts commit 8efe444038a205e79b38b7ad03878824901849a8 and
4cbc76eadf56399cd11fb736b33c53aec9caab8c.
Richard@laptop.org was apparently using CAPACITY_LEVEL for debugging
battery/EC problems, and was upset that it was removed. This readds it.
Conflicts:
Documentation/power_supply_class.txt
Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
-rw-r--r-- | Documentation/power/power_supply_class.txt | 2 | ||||
-rw-r--r-- | drivers/power/olpc_battery.c | 9 | ||||
-rw-r--r-- | drivers/power/power_supply_sysfs.c | 6 | ||||
-rw-r--r-- | include/linux/power_supply.h | 10 |
4 files changed, 27 insertions, 0 deletions
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt index c6cd4956047c..709d95571d7b 100644 --- a/Documentation/power/power_supply_class.txt +++ b/Documentation/power/power_supply_class.txt | |||
@@ -108,6 +108,8 @@ relative, time-based measurements. | |||
108 | ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. | 108 | ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. |
109 | 109 | ||
110 | CAPACITY - capacity in percents. | 110 | CAPACITY - capacity in percents. |
111 | CAPACITY_LEVEL - capacity level. This corresponds to | ||
112 | POWER_SUPPLY_CAPACITY_LEVEL_*. | ||
111 | 113 | ||
112 | TEMP - temperature of the power supply. | 114 | TEMP - temperature of the power supply. |
113 | TEMP_AMBIENT - ambient temperature. | 115 | TEMP_AMBIENT - ambient temperature. |
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 58e419299cd6..3a589df09376 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -276,6 +276,14 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
276 | return ret; | 276 | return ret; |
277 | val->intval = ec_byte; | 277 | val->intval = ec_byte; |
278 | break; | 278 | break; |
279 | case POWER_SUPPLY_PROP_CAPACITY_LEVEL: | ||
280 | if (ec_byte & BAT_STAT_FULL) | ||
281 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; | ||
282 | else if (ec_byte & BAT_STAT_LOW) | ||
283 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; | ||
284 | else | ||
285 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; | ||
286 | break; | ||
279 | case POWER_SUPPLY_PROP_TEMP: | 287 | case POWER_SUPPLY_PROP_TEMP: |
280 | ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); | 288 | ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); |
281 | if (ret) | 289 | if (ret) |
@@ -321,6 +329,7 @@ static enum power_supply_property olpc_bat_props[] = { | |||
321 | POWER_SUPPLY_PROP_VOLTAGE_AVG, | 329 | POWER_SUPPLY_PROP_VOLTAGE_AVG, |
322 | POWER_SUPPLY_PROP_CURRENT_AVG, | 330 | POWER_SUPPLY_PROP_CURRENT_AVG, |
323 | POWER_SUPPLY_PROP_CAPACITY, | 331 | POWER_SUPPLY_PROP_CAPACITY, |
332 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, | ||
324 | POWER_SUPPLY_PROP_TEMP, | 333 | POWER_SUPPLY_PROP_TEMP, |
325 | POWER_SUPPLY_PROP_TEMP_AMBIENT, | 334 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
326 | POWER_SUPPLY_PROP_MANUFACTURER, | 335 | POWER_SUPPLY_PROP_MANUFACTURER, |
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index da73591017f9..9deabbde6fd6 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c | |||
@@ -51,6 +51,9 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
51 | "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd", | 51 | "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd", |
52 | "LiMn" | 52 | "LiMn" |
53 | }; | 53 | }; |
54 | static char *capacity_level_text[] = { | ||
55 | "Unknown", "Critical", "Low", "Normal", "High", "Full" | ||
56 | }; | ||
54 | ssize_t ret; | 57 | ssize_t ret; |
55 | struct power_supply *psy = dev_get_drvdata(dev); | 58 | struct power_supply *psy = dev_get_drvdata(dev); |
56 | const ptrdiff_t off = attr - power_supply_attrs; | 59 | const ptrdiff_t off = attr - power_supply_attrs; |
@@ -71,6 +74,8 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
71 | return sprintf(buf, "%s\n", health_text[value.intval]); | 74 | return sprintf(buf, "%s\n", health_text[value.intval]); |
72 | else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) | 75 | else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) |
73 | return sprintf(buf, "%s\n", technology_text[value.intval]); | 76 | return sprintf(buf, "%s\n", technology_text[value.intval]); |
77 | else if (off == POWER_SUPPLY_PROP_CAPACITY_LEVEL) | ||
78 | return sprintf(buf, "%s\n", capacity_level_text[value.intval]); | ||
74 | else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) | 79 | else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) |
75 | return sprintf(buf, "%s\n", value.strval); | 80 | return sprintf(buf, "%s\n", value.strval); |
76 | 81 | ||
@@ -109,6 +114,7 @@ static struct device_attribute power_supply_attrs[] = { | |||
109 | POWER_SUPPLY_ATTR(energy_now), | 114 | POWER_SUPPLY_ATTR(energy_now), |
110 | POWER_SUPPLY_ATTR(energy_avg), | 115 | POWER_SUPPLY_ATTR(energy_avg), |
111 | POWER_SUPPLY_ATTR(capacity), | 116 | POWER_SUPPLY_ATTR(capacity), |
117 | POWER_SUPPLY_ATTR(capacity_level), | ||
112 | POWER_SUPPLY_ATTR(temp), | 118 | POWER_SUPPLY_ATTR(temp), |
113 | POWER_SUPPLY_ATTR(temp_ambient), | 119 | POWER_SUPPLY_ATTR(temp_ambient), |
114 | POWER_SUPPLY_ATTR(time_to_empty_now), | 120 | POWER_SUPPLY_ATTR(time_to_empty_now), |
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 594c494ac3f0..0ab6aa171241 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h | |||
@@ -58,6 +58,15 @@ enum { | |||
58 | POWER_SUPPLY_TECHNOLOGY_LiMn, | 58 | POWER_SUPPLY_TECHNOLOGY_LiMn, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | enum { | ||
62 | POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0, | ||
63 | POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL, | ||
64 | POWER_SUPPLY_CAPACITY_LEVEL_LOW, | ||
65 | POWER_SUPPLY_CAPACITY_LEVEL_NORMAL, | ||
66 | POWER_SUPPLY_CAPACITY_LEVEL_HIGH, | ||
67 | POWER_SUPPLY_CAPACITY_LEVEL_FULL, | ||
68 | }; | ||
69 | |||
61 | enum power_supply_property { | 70 | enum power_supply_property { |
62 | /* Properties of type `int' */ | 71 | /* Properties of type `int' */ |
63 | POWER_SUPPLY_PROP_STATUS = 0, | 72 | POWER_SUPPLY_PROP_STATUS = 0, |
@@ -89,6 +98,7 @@ enum power_supply_property { | |||
89 | POWER_SUPPLY_PROP_ENERGY_NOW, | 98 | POWER_SUPPLY_PROP_ENERGY_NOW, |
90 | POWER_SUPPLY_PROP_ENERGY_AVG, | 99 | POWER_SUPPLY_PROP_ENERGY_AVG, |
91 | POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ | 100 | POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ |
101 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, | ||
92 | POWER_SUPPLY_PROP_TEMP, | 102 | POWER_SUPPLY_PROP_TEMP, |
93 | POWER_SUPPLY_PROP_TEMP_AMBIENT, | 103 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
94 | POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, | 104 | POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, |