1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Functions private to power supply class 4 * 5 * Copyright © 2007 Anton Vorontsov <cbou@mail.ru> 6 * Copyright © 2004 Szabolcs Gyurko 7 * Copyright © 2003 Ian Molton <spyro@f2s.com> 8 * 9 * Modified: 2004, Oct Szabolcs Gyurko 10 */ 11 12 #include <linux/lockdep.h> 13 14 struct device; 15 struct device_type; 16 struct power_supply; 17 18 extern int power_supply_property_is_writeable(struct power_supply *psy, 19 enum power_supply_property psp); 20 extern bool power_supply_has_property(struct power_supply *psy, 21 enum power_supply_property psp); 22 extern bool power_supply_ext_has_property(const struct power_supply_ext *ext, 23 enum power_supply_property psp); 24 25 struct power_supply_ext_registration { 26 struct list_head list_head; 27 const struct power_supply_ext *ext; 28 struct device *dev; 29 void *data; 30 }; 31 32 /* Make sure that the macro is a single expression */ 33 #define power_supply_for_each_extension(pos, psy) \ 34 if ( ({ lockdep_assert_held(&(psy)->extensions_sem); 0; }) ) \ 35 ; \ 36 else \ 37 list_for_each_entry(pos, &(psy)->extensions, list_head) \ 38 39 #ifdef CONFIG_SYSFS 40 41 extern void __init power_supply_init_attrs(void); 42 extern int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env); 43 extern const struct attribute_group *power_supply_attr_groups[]; 44 extern int power_supply_sysfs_add_extension(struct power_supply *psy, 45 const struct power_supply_ext *ext, 46 struct device *dev); 47 extern void power_supply_sysfs_remove_extension(struct power_supply *psy, 48 const struct power_supply_ext *ext); 49 50 #else 51 52 static inline void power_supply_init_attrs(void) {} 53 #define power_supply_attr_groups NULL 54 #define power_supply_uevent NULL 55 static inline int power_supply_sysfs_add_extension(struct power_supply *psy, 56 const struct power_supply_ext *ext, 57 struct device *dev) 58 { return 0; } 59 static inline void power_supply_sysfs_remove_extension(struct power_supply *psy, 60 const struct power_supply_ext *ext) {} 61 62 #endif /* CONFIG_SYSFS */ 63 64 #ifdef CONFIG_LEDS_TRIGGERS 65 66 extern void power_supply_update_leds(struct power_supply *psy); 67 extern int power_supply_create_triggers(struct power_supply *psy); 68 extern void power_supply_remove_triggers(struct power_supply *psy); 69 70 #else 71 72 static inline void power_supply_update_leds(struct power_supply *psy) {} 73 static inline int power_supply_create_triggers(struct power_supply *psy) 74 { return 0; } 75 static inline void power_supply_remove_triggers(struct power_supply *psy) {} 76 77 #endif /* CONFIG_LEDS_TRIGGERS */ 78 79 #ifdef CONFIG_POWER_SUPPLY_HWMON 80 81 int power_supply_add_hwmon_sysfs(struct power_supply *psy); 82 void power_supply_remove_hwmon_sysfs(struct power_supply *psy); 83 84 #else 85 86 static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy) 87 { 88 return 0; 89 } 90 91 static inline 92 void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {} 93 94 #endif /* CONFIG_POWER_SUPPLY_HWMON */ 95