diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-29 17:37:02 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-04-29 17:37:02 -0700 |
commit | 17d4ded2fc9d4f0b7c3c74ed9f80420c59d36e0b (patch) | |
tree | 02d25a0b39465b2c68536b709f30822c313724c9 /drivers/power/supply/power_supply_sysfs.c | |
parent | e81507acdc19d91df4121f409871f3e4e055f6c2 (diff) | |
parent | baba1315a74d12772d4940a05d58dc03e6ec0635 (diff) | |
download | linux-17d4ded2fc9d4f0b7c3c74ed9f80420c59d36e0b.tar.gz linux-17d4ded2fc9d4f0b7c3c74ed9f80420c59d36e0b.tar.bz2 linux-17d4ded2fc9d4f0b7c3c74ed9f80420c59d36e0b.zip |
Merge tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
- power-supply core support for automatic handling of constant battery
data supplied by firmware
- generic-adc-battery: major cleanup
- axp288_charger: fix ACPI issues on x86 Android tablets
- rk817: cleanup and fix handling for low state of charge
* tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (26 commits)
power: supply: rk817: Fix low SOC bugs
power: supply: rk817: Drop unneeded debugging code
power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets
power: supply: generic-adc-battery: style fixes
power: supply: generic-adc-battery: improve error message
power: supply: generic-adc-battery: update copyright info
power: supply: generic-adc-battery: add DT support
power: supply: generic-adc-battery: add temperature support
power: supply: generic-adc-battery: simplify read_channel logic
power: supply: generic-adc-battery: use simple-battery API
power: supply: generic-adc-battery: drop memory alloc error message
power: supply: generic-adc-battery: drop charge now support
power: supply: generic-adc-battery: drop jitter delay support
power: supply: generic-adc-battery: fix unit scaling
power: supply: generic-adc-battery: convert to managed resources
power: supply: core: auto-exposure of simple-battery data
dt-bindings: power: supply: adc-battery: add binding
power: supply: bq256xx: Support to disable charger
power: supply: charger-manager: Use of_property_read_bool() for boolean properties
power: reset: qcom-pon: drop of_match_ptr for ID table
...
Diffstat (limited to 'drivers/power/supply/power_supply_sysfs.c')
-rw-r--r-- | drivers/power/supply/power_supply_sysfs.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index c228205e0953..ba3b125cd66e 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -221,9 +221,10 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(MANUFACTURER), POWER_SUPPLY_ATTR(SERIAL_NUMBER), }; +#define POWER_SUPPLY_ATTR_CNT ARRAY_SIZE(power_supply_attrs) static struct attribute * -__power_supply_attrs[ARRAY_SIZE(power_supply_attrs) + 1]; +__power_supply_attrs[POWER_SUPPLY_ATTR_CNT + 1]; static struct power_supply_attr *to_ps_attr(struct device_attribute *attr) { @@ -380,6 +381,9 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj, } } + if (power_supply_battery_info_has_prop(psy->battery_info, attrno)) + return mode; + return 0; } @@ -461,6 +465,10 @@ static int add_prop_uevent(const struct device *dev, struct kobj_uevent_env *env int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env) { const struct power_supply *psy = dev_get_drvdata(dev); + const enum power_supply_property *battery_props = + power_supply_battery_info_properties; + unsigned long psy_drv_properties[POWER_SUPPLY_ATTR_CNT / + sizeof(unsigned long) + 1] = {0}; int ret = 0, j; char *prop_buf; @@ -482,12 +490,25 @@ int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env) goto out; for (j = 0; j < psy->desc->num_properties; j++) { + set_bit(psy->desc->properties[j], psy_drv_properties); ret = add_prop_uevent(dev, env, psy->desc->properties[j], prop_buf); if (ret) goto out; } + for (j = 0; j < power_supply_battery_info_properties_size; j++) { + if (test_bit(battery_props[j], psy_drv_properties)) + continue; + if (!power_supply_battery_info_has_prop(psy->battery_info, + battery_props[j])) + continue; + ret = add_prop_uevent(dev, env, battery_props[j], + prop_buf); + if (ret) + goto out; + } + out: free_page((unsigned long)prop_buf); |