summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAmit Sunil Dhamne <amitsd@google.com>2026-07-14 21:10:52 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-17 12:32:45 +0200
commit3b17c8d8d658f24e319b1aacd937dc9be38c3fe4 (patch)
tree7b98283a2d464ac4f24dabee12f27bd0b64ad1c7 /include/linux
parent1e6be4bd53f0f06377c3ce3c26ea4a6cadd4ab46 (diff)
power: supply: Add helpers to get and put arrays of power supply handles
Add power_supply_get_system_batteries() to allow drivers to obtain a list of registered battery type power supply references in the system. Also add power_supply_put_system_batteries() to perform cleanup after the former function is called. Signed-off-by: Amit Sunil Dhamne <amitsd@google.com> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com> Link: https://patch.msgid.link/20260714-batt-status-v5-1-9de4aa900b69@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/power_supply.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 7a5e4c3242a0..9167a33d074b 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -806,11 +806,26 @@ extern int power_supply_reg_notifier(struct notifier_block *nb);
extern void power_supply_unreg_notifier(struct notifier_block *nb);
#if IS_ENABLED(CONFIG_POWER_SUPPLY)
extern struct power_supply *power_supply_get_by_name(const char *name);
+extern int __must_check power_supply_get_system_batteries(struct device *dev,
+ struct power_supply ***psys);
+extern void power_supply_put_system_batteries(struct power_supply **psys, int count);
extern void power_supply_put(struct power_supply *psy);
#else
static inline void power_supply_put(struct power_supply *psy) {}
static inline struct power_supply *power_supply_get_by_name(const char *name)
{ return NULL; }
+static inline int __must_check power_supply_get_system_batteries(struct device *dev,
+ struct power_supply ***psys)
+{
+ if (psys)
+ *psys = NULL;
+ return 0;
+}
+
+static inline void power_supply_put_system_batteries(struct power_supply **psys,
+ int count)
+{
+}
#endif
extern struct power_supply *power_supply_get_by_reference(struct fwnode_handle *fwnode,
const char *property);