summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2011-12-07 09:15:45 -0800
committerJeremy Fitzhardinge <jeremy@goop.org>2011-12-09 09:52:07 -0800
commit8351665195cec6d2b73cce8b66f02d6dde246a8e (patch)
tree3b31b34dc1737ff40679036d97a3f7d6c49ffa88 /drivers/power
parent25a0bc2dfc2ea732f40af2dae52426ead66ae76e (diff)
downloadlinux-stable-8351665195cec6d2b73cce8b66f02d6dde246a8e.tar.gz
linux-stable-8351665195cec6d2b73cce8b66f02d6dde246a8e.tar.bz2
linux-stable-8351665195cec6d2b73cce8b66f02d6dde246a8e.zip
power_supply: allow a power supply to explicitly point to powered device
If a power supply has a scope of "Device", then allow the power supply to indicate what device it actually powers. This is represented in the power supply's sysfs directory as a symlink named "powers", which points to the sysfs directory of the powered device. If the device has children, then the sub-devices are also powered by the same power supply. 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_core.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 329b46b2327d..b10c121244e5 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -147,6 +147,12 @@ struct power_supply *power_supply_get_by_name(char *name)
}
EXPORT_SYMBOL_GPL(power_supply_get_by_name);
+int power_supply_powers(struct power_supply *psy, struct device *dev)
+{
+ return sysfs_create_link_nowarn(&psy->dev->kobj, &dev->kobj, "powers");
+}
+EXPORT_SYMBOL_GPL(power_supply_powers);
+
static void power_supply_dev_release(struct device *dev)
{
pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
@@ -202,6 +208,7 @@ EXPORT_SYMBOL_GPL(power_supply_register);
void power_supply_unregister(struct power_supply *psy)
{
cancel_work_sync(&psy->changed_work);
+ sysfs_remove_link(&psy->dev->kobj, "powers");
power_supply_remove_triggers(psy);
device_unregister(psy->dev);
}