mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
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 <[email protected]> Cc: Richard Hughes <[email protected]>
This commit is contained in:
parent
25a0bc2dfc
commit
8351665195
2 changed files with 8 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue