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