drivers/power/supply/power_supply_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/power_supply_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/power_supply_sysfs.c- Extension
.c- Size
- 20173 bytes
- Lines
- 669
- Domain
- Driver Families
- Bucket
- drivers/power
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ctype.hlinux/device.hlinux/power_supply.hlinux/slab.hlinux/stat.hlinux/string_helpers.hpower_supply.h
Detected Declarations
struct power_supply_attrfunction dev_attr_pspfunction power_supply_escape_spacesfunction power_supply_match_stringfunction power_supply_show_enum_with_availablefunction power_supply_show_charge_behaviourfunction scoped_guardfunction power_supply_show_charge_typesfunction scoped_guardfunction power_supply_format_propertyfunction power_supply_show_propertyfunction power_supply_store_propertyfunction power_supply_attr_is_visiblefunction power_supply_init_attrsfunction add_prop_ueventfunction power_supply_ueventfunction power_supply_charge_behaviour_showfunction power_supply_charge_behaviour_parsefunction power_supply_charge_types_showfunction power_supply_charge_types_parsefunction power_supply_sysfs_add_extensionfunction power_supply_sysfs_remove_extensionexport power_supply_charge_behaviour_showexport power_supply_charge_behaviour_parseexport power_supply_charge_types_showexport power_supply_charge_types_parse
Annotated Snippet
struct power_supply_attr {
const char *prop_name;
char attr_name[MAX_PROP_NAME_LEN + 1];
struct device_attribute dev_attr;
const char * const *text_values;
int text_values_len;
};
#define _POWER_SUPPLY_ATTR(_name, _text, _len) \
[POWER_SUPPLY_PROP_ ## _name] = \
{ \
.prop_name = #_name, \
.attr_name = #_name, \
.text_values = _text, \
.text_values_len = _len, \
}
#define POWER_SUPPLY_ATTR(_name) _POWER_SUPPLY_ATTR(_name, NULL, 0)
#define _POWER_SUPPLY_ENUM_ATTR(_name, _text) \
_POWER_SUPPLY_ATTR(_name, _text, ARRAY_SIZE(_text))
#define POWER_SUPPLY_ENUM_ATTR(_name) \
_POWER_SUPPLY_ENUM_ATTR(_name, POWER_SUPPLY_ ## _name ## _TEXT)
static const char * const POWER_SUPPLY_TYPE_TEXT[] = {
[POWER_SUPPLY_TYPE_UNKNOWN] = "Unknown",
[POWER_SUPPLY_TYPE_BATTERY] = "Battery",
[POWER_SUPPLY_TYPE_UPS] = "UPS",
[POWER_SUPPLY_TYPE_MAINS] = "Mains",
[POWER_SUPPLY_TYPE_USB] = "USB",
[POWER_SUPPLY_TYPE_USB_DCP] = "USB_DCP",
[POWER_SUPPLY_TYPE_USB_CDP] = "USB_CDP",
[POWER_SUPPLY_TYPE_USB_ACA] = "USB_ACA",
[POWER_SUPPLY_TYPE_USB_TYPE_C] = "USB_C",
[POWER_SUPPLY_TYPE_USB_PD] = "USB_PD",
[POWER_SUPPLY_TYPE_USB_PD_DRP] = "USB_PD_DRP",
[POWER_SUPPLY_TYPE_APPLE_BRICK_ID] = "BrickID",
[POWER_SUPPLY_TYPE_WIRELESS] = "Wireless",
};
static const char * const POWER_SUPPLY_USB_TYPE_TEXT[] = {
[POWER_SUPPLY_USB_TYPE_UNKNOWN] = "Unknown",
[POWER_SUPPLY_USB_TYPE_SDP] = "SDP",
[POWER_SUPPLY_USB_TYPE_DCP] = "DCP",
[POWER_SUPPLY_USB_TYPE_CDP] = "CDP",
[POWER_SUPPLY_USB_TYPE_ACA] = "ACA",
[POWER_SUPPLY_USB_TYPE_C] = "C",
[POWER_SUPPLY_USB_TYPE_PD] = "PD",
[POWER_SUPPLY_USB_TYPE_PD_DRP] = "PD_DRP",
[POWER_SUPPLY_USB_TYPE_PD_PPS] = "PD_PPS",
[POWER_SUPPLY_USB_TYPE_PD_SPR_AVS] = "PD_SPR_AVS",
[POWER_SUPPLY_USB_TYPE_PD_PPS_SPR_AVS] = "PD_PPS_SPR_AVS",
[POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID] = "BrickID",
};
static const char * const POWER_SUPPLY_STATUS_TEXT[] = {
[POWER_SUPPLY_STATUS_UNKNOWN] = "Unknown",
[POWER_SUPPLY_STATUS_CHARGING] = "Charging",
[POWER_SUPPLY_STATUS_DISCHARGING] = "Discharging",
[POWER_SUPPLY_STATUS_NOT_CHARGING] = "Not charging",
[POWER_SUPPLY_STATUS_FULL] = "Full",
};
static const char * const POWER_SUPPLY_CHARGE_TYPE_TEXT[] = {
[POWER_SUPPLY_CHARGE_TYPE_UNKNOWN] = "Unknown",
[POWER_SUPPLY_CHARGE_TYPE_NONE] = "N/A",
[POWER_SUPPLY_CHARGE_TYPE_TRICKLE] = "Trickle",
[POWER_SUPPLY_CHARGE_TYPE_FAST] = "Fast",
[POWER_SUPPLY_CHARGE_TYPE_STANDARD] = "Standard",
[POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE] = "Adaptive",
[POWER_SUPPLY_CHARGE_TYPE_CUSTOM] = "Custom",
[POWER_SUPPLY_CHARGE_TYPE_LONGLIFE] = "Long Life",
[POWER_SUPPLY_CHARGE_TYPE_BYPASS] = "Bypass",
};
static const char * const POWER_SUPPLY_HEALTH_TEXT[] = {
[POWER_SUPPLY_HEALTH_UNKNOWN] = "Unknown",
[POWER_SUPPLY_HEALTH_GOOD] = "Good",
[POWER_SUPPLY_HEALTH_OVERHEAT] = "Overheat",
[POWER_SUPPLY_HEALTH_DEAD] = "Dead",
[POWER_SUPPLY_HEALTH_OVERVOLTAGE] = "Over voltage",
[POWER_SUPPLY_HEALTH_UNDERVOLTAGE] = "Under voltage",
[POWER_SUPPLY_HEALTH_UNSPEC_FAILURE] = "Unspecified failure",
[POWER_SUPPLY_HEALTH_COLD] = "Cold",
[POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire",
[POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE] = "Safety timer expire",
[POWER_SUPPLY_HEALTH_OVERCURRENT] = "Over current",
[POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED] = "Calibration required",
[POWER_SUPPLY_HEALTH_WARM] = "Warm",
[POWER_SUPPLY_HEALTH_COOL] = "Cool",
[POWER_SUPPLY_HEALTH_HOT] = "Hot",
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/device.h`, `linux/power_supply.h`, `linux/slab.h`, `linux/stat.h`, `linux/string_helpers.h`, `power_supply.h`.
- Detected declarations: `struct power_supply_attr`, `function dev_attr_psp`, `function power_supply_escape_spaces`, `function power_supply_match_string`, `function power_supply_show_enum_with_available`, `function power_supply_show_charge_behaviour`, `function scoped_guard`, `function power_supply_show_charge_types`, `function scoped_guard`, `function power_supply_format_property`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.