diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2011-12-07 14:24:20 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2011-12-09 12:42:05 -0500 |
commit | 25a0bc2dfc2ea732f40af2dae52426ead66ae76e (patch) | |
tree | 180dc7e4122da2f40b241c5e936a0668420f4bb7 /drivers/power | |
parent | cfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff) |
power_supply: add SCOPE attribute to power supplies
This adds a "scope" attribute to a power_supply, which indicates how
much of the system it powers. It appears in sysfs as "scope" or in
the uevent file as POWER_SUPPLY_SCOPE=. There are presently three
possible values:
Unknown - unknown power topology
System - the power supply powers the whole system
Device - it powers a specific device, or tree of devices
A power supply which doesn't have a "scope" attribute should be assumed to
have "System" scope.
In general, usermode should assume that loss of all System-scoped power
supplies will power off the whole system, but any single one is sufficient
to power the system.
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Richard Hughes <richard@hughsie.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/power_supply_sysfs.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index e15d4c9d3988..21178ebfe51a 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c | |||
@@ -63,6 +63,9 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
63 | static char *capacity_level_text[] = { | 63 | static char *capacity_level_text[] = { |
64 | "Unknown", "Critical", "Low", "Normal", "High", "Full" | 64 | "Unknown", "Critical", "Low", "Normal", "High", "Full" |
65 | }; | 65 | }; |
66 | static char *scope_text[] = { | ||
67 | "Unknown", "System", "Device" | ||
68 | }; | ||
66 | ssize_t ret = 0; | 69 | ssize_t ret = 0; |
67 | struct power_supply *psy = dev_get_drvdata(dev); | 70 | struct power_supply *psy = dev_get_drvdata(dev); |
68 | const ptrdiff_t off = attr - power_supply_attrs; | 71 | const ptrdiff_t off = attr - power_supply_attrs; |
@@ -95,6 +98,8 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
95 | return sprintf(buf, "%s\n", capacity_level_text[value.intval]); | 98 | return sprintf(buf, "%s\n", capacity_level_text[value.intval]); |
96 | else if (off == POWER_SUPPLY_PROP_TYPE) | 99 | else if (off == POWER_SUPPLY_PROP_TYPE) |
97 | return sprintf(buf, "%s\n", type_text[value.intval]); | 100 | return sprintf(buf, "%s\n", type_text[value.intval]); |
101 | else if (off == POWER_SUPPLY_PROP_SCOPE) | ||
102 | return sprintf(buf, "%s\n", scope_text[value.intval]); | ||
98 | else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) | 103 | else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) |
99 | return sprintf(buf, "%s\n", value.strval); | 104 | return sprintf(buf, "%s\n", value.strval); |
100 | 105 | ||
@@ -167,6 +172,7 @@ static struct device_attribute power_supply_attrs[] = { | |||
167 | POWER_SUPPLY_ATTR(time_to_full_now), | 172 | POWER_SUPPLY_ATTR(time_to_full_now), |
168 | POWER_SUPPLY_ATTR(time_to_full_avg), | 173 | POWER_SUPPLY_ATTR(time_to_full_avg), |
169 | POWER_SUPPLY_ATTR(type), | 174 | POWER_SUPPLY_ATTR(type), |
175 | POWER_SUPPLY_ATTR(scope), | ||
170 | /* Properties of type `const char *' */ | 176 | /* Properties of type `const char *' */ |
171 | POWER_SUPPLY_ATTR(model_name), | 177 | POWER_SUPPLY_ATTR(model_name), |
172 | POWER_SUPPLY_ATTR(manufacturer), | 178 | POWER_SUPPLY_ATTR(manufacturer), |