提交 83516651 编写于 作者: J Jeremy Fitzhardinge

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: NJeremy Fitzhardinge <jeremy@goop.org>
Cc: Richard Hughes <richard@hughsie.com>
上级 25a0bc2d
...@@ -147,6 +147,12 @@ struct power_supply *power_supply_get_by_name(char *name) ...@@ -147,6 +147,12 @@ struct power_supply *power_supply_get_by_name(char *name)
} }
EXPORT_SYMBOL_GPL(power_supply_get_by_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) static void power_supply_dev_release(struct device *dev)
{ {
pr_debug("device: '%s': %s\n", dev_name(dev), __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
...@@ -202,6 +208,7 @@ EXPORT_SYMBOL_GPL(power_supply_register); ...@@ -202,6 +208,7 @@ EXPORT_SYMBOL_GPL(power_supply_register);
void power_supply_unregister(struct power_supply *psy) void power_supply_unregister(struct power_supply *psy)
{ {
cancel_work_sync(&psy->changed_work); cancel_work_sync(&psy->changed_work);
sysfs_remove_link(&psy->dev->kobj, "powers");
power_supply_remove_triggers(psy); power_supply_remove_triggers(psy);
device_unregister(psy->dev); device_unregister(psy->dev);
} }
......
...@@ -218,6 +218,7 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; } ...@@ -218,6 +218,7 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
extern int power_supply_register(struct device *parent, extern int power_supply_register(struct device *parent,
struct power_supply *psy); struct power_supply *psy);
extern void power_supply_unregister(struct power_supply *psy); extern void power_supply_unregister(struct power_supply *psy);
extern int power_supply_powers(struct power_supply *psy, struct device *dev);
/* For APM emulation, think legacy userspace. */ /* For APM emulation, think legacy userspace. */
extern struct class *power_supply_class; extern struct class *power_supply_class;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册