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 <dilinger@debian.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by Andres Salomon and committed by Anton Vorontsov 8efe4440 4d24473c

-27
-2
Documentation/power_supply_class.txt
··· 100 ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. 101 102 CAPACITY - capacity in percents. 103 - CAPACITY_LEVEL - capacity level. This corresponds to 104 - POWER_SUPPLY_CAPACITY_LEVEL_*. 105 106 TEMP - temperature of the power supply. 107 TEMP_AMBIENT - ambient temperature.
··· 100 ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. 101 102 CAPACITY - capacity in percents. 103 104 TEMP - temperature of the power supply. 105 TEMP_AMBIENT - ambient temperature.
-9
drivers/power/olpc_battery.c
··· 226 return ret; 227 val->intval = ec_byte; 228 break; 229 - case POWER_SUPPLY_PROP_CAPACITY_LEVEL: 230 - if (ec_byte & BAT_STAT_FULL) 231 - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; 232 - else if (ec_byte & BAT_STAT_LOW) 233 - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; 234 - else 235 - val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; 236 - break; 237 case POWER_SUPPLY_PROP_TEMP: 238 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); 239 if (ret) ··· 257 POWER_SUPPLY_PROP_VOLTAGE_AVG, 258 POWER_SUPPLY_PROP_CURRENT_AVG, 259 POWER_SUPPLY_PROP_CAPACITY, 260 - POWER_SUPPLY_PROP_CAPACITY_LEVEL, 261 POWER_SUPPLY_PROP_TEMP, 262 POWER_SUPPLY_PROP_TEMP_AMBIENT, 263 POWER_SUPPLY_PROP_MANUFACTURER,
··· 226 return ret; 227 val->intval = ec_byte; 228 break; 229 case POWER_SUPPLY_PROP_TEMP: 230 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); 231 if (ret) ··· 265 POWER_SUPPLY_PROP_VOLTAGE_AVG, 266 POWER_SUPPLY_PROP_CURRENT_AVG, 267 POWER_SUPPLY_PROP_CAPACITY, 268 POWER_SUPPLY_PROP_TEMP, 269 POWER_SUPPLY_PROP_TEMP_AMBIENT, 270 POWER_SUPPLY_PROP_MANUFACTURER,
-6
drivers/power/power_supply_sysfs.c
··· 50 static char *technology_text[] = { 51 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd" 52 }; 53 - static char *capacity_level_text[] = { 54 - "Unknown", "Critical", "Low", "Normal", "High", "Full" 55 - }; 56 ssize_t ret; 57 struct power_supply *psy = dev_get_drvdata(dev); 58 const ptrdiff_t off = attr - power_supply_attrs; ··· 70 return sprintf(buf, "%s\n", health_text[value.intval]); 71 else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) 72 return sprintf(buf, "%s\n", technology_text[value.intval]); 73 - else if (off == POWER_SUPPLY_PROP_CAPACITY_LEVEL) 74 - return sprintf(buf, "%s\n", 75 - capacity_level_text[value.intval]); 76 else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) 77 return sprintf(buf, "%s\n", value.strval); 78
··· 50 static char *technology_text[] = { 51 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd" 52 }; 53 ssize_t ret; 54 struct power_supply *psy = dev_get_drvdata(dev); 55 const ptrdiff_t off = attr - power_supply_attrs; ··· 73 return sprintf(buf, "%s\n", health_text[value.intval]); 74 else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) 75 return sprintf(buf, "%s\n", technology_text[value.intval]); 76 else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) 77 return sprintf(buf, "%s\n", value.strval); 78
-10
include/linux/power_supply.h
··· 56 POWER_SUPPLY_TECHNOLOGY_NiCd, 57 }; 58 59 - enum { 60 - POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0, 61 - POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL, 62 - POWER_SUPPLY_CAPACITY_LEVEL_LOW, 63 - POWER_SUPPLY_CAPACITY_LEVEL_NORMAL, 64 - POWER_SUPPLY_CAPACITY_LEVEL_HIGH, 65 - POWER_SUPPLY_CAPACITY_LEVEL_FULL, 66 - }; 67 - 68 enum power_supply_property { 69 /* Properties of type `int' */ 70 POWER_SUPPLY_PROP_STATUS = 0, ··· 82 POWER_SUPPLY_PROP_ENERGY_NOW, 83 POWER_SUPPLY_PROP_ENERGY_AVG, 84 POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ 85 - POWER_SUPPLY_PROP_CAPACITY_LEVEL, 86 POWER_SUPPLY_PROP_TEMP, 87 POWER_SUPPLY_PROP_TEMP_AMBIENT, 88 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
··· 56 POWER_SUPPLY_TECHNOLOGY_NiCd, 57 }; 58 59 enum power_supply_property { 60 /* Properties of type `int' */ 61 POWER_SUPPLY_PROP_STATUS = 0, ··· 91 POWER_SUPPLY_PROP_ENERGY_NOW, 92 POWER_SUPPLY_PROP_ENERGY_AVG, 93 POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ 94 POWER_SUPPLY_PROP_TEMP, 95 POWER_SUPPLY_PROP_TEMP_AMBIENT, 96 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,