[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <8351665195cec6d2b73cce8b66f02d6dde246a8e.1323454016.git.jeremy@goop.org>
Date: Fri, 9 Dec 2011 14:43:17 -0800
From: Jeremy Fitzhardinge <jeremy@...p.org>
To: Anton Vorontsov <cbouatmailru@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Richard Hughes <hughsient@...il.com>,
Daniel Nicoletti <dantti12@...il.com>,
linux-input@...r.kernel.org, Jiri Kosina <jkosina@...e.cz>,
Jeremy Fitzhardinge <jeremy@...p.org>,
Richard Hughes <richard@...hsie.com>
Subject: [PATCH RFC V2 2/4] 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@...p.org>
Cc: Richard Hughes <richard@...hsie.com>
---
drivers/power/power_supply_core.c | 7 +++++++
include/linux/power_supply.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 329b46b..b10c121 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);
}
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 040a7b0..2e3c827 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -218,6 +218,7 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
extern int power_supply_register(struct device *parent,
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. */
extern struct class *power_supply_class;
--
1.7.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists