drivers/staging/nvec/nvec_power.c
Source file repositories/reference/linux-study-clean/drivers/staging/nvec/nvec_power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/nvec/nvec_power.c- Extension
.c- Size
- 10497 bytes
- Lines
- 448
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/platform_device.hlinux/err.hlinux/power_supply.hlinux/slab.hlinux/workqueue.hlinux/delay.hnvec.h
Detected Declarations
struct nvec_powerstruct bat_responsefunction nvec_power_notifierfunction get_bat_mfg_datafunction nvec_power_bat_notifierfunction nvec_power_get_propertyfunction nvec_battery_get_propertyfunction nvec_power_pollfunction nvec_power_probefunction nvec_power_remove
Annotated Snippet
struct nvec_power {
struct notifier_block notifier;
struct delayed_work poller;
struct nvec_chip *nvec;
int on;
int bat_present;
int bat_status;
int bat_voltage_now;
int bat_current_now;
int bat_current_avg;
int time_remain;
int charge_full_design;
int charge_last_full;
int critical_capacity;
int capacity_remain;
int bat_temperature;
int bat_cap;
int bat_type_enum;
char bat_manu[30];
char bat_model[30];
char bat_type[30];
};
enum {
SLOT_STATUS,
VOLTAGE,
TIME_REMAINING,
CURRENT,
AVERAGE_CURRENT,
AVERAGING_TIME_INTERVAL,
CAPACITY_REMAINING,
LAST_FULL_CHARGE_CAPACITY,
DESIGN_CAPACITY,
CRITICAL_CAPACITY,
TEMPERATURE,
MANUFACTURER,
MODEL,
TYPE,
};
enum {
AC,
BAT,
};
struct bat_response {
u8 event_type;
u8 length;
u8 sub_type;
u8 status;
/* payload */
union {
char plc[30];
u16 plu;
s16 pls;
};
};
static struct power_supply *nvec_bat_psy;
static struct power_supply *nvec_psy;
static int nvec_power_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
{
struct nvec_power *power =
container_of(nb, struct nvec_power, notifier);
struct bat_response *res = data;
if (event_type != NVEC_SYS)
return NOTIFY_DONE;
if (res->sub_type == 0) {
if (power->on != res->plu) {
power->on = res->plu;
power_supply_changed(nvec_psy);
}
return NOTIFY_STOP;
}
return NOTIFY_OK;
}
static const int bat_init[] = {
LAST_FULL_CHARGE_CAPACITY, DESIGN_CAPACITY, CRITICAL_CAPACITY,
MANUFACTURER, MODEL, TYPE,
};
static void get_bat_mfg_data(struct nvec_power *power)
{
int i;
char buf[] = { NVEC_BAT, SLOT_STATUS };
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/err.h`, `linux/power_supply.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/delay.h`, `nvec.h`.
- Detected declarations: `struct nvec_power`, `struct bat_response`, `function nvec_power_notifier`, `function get_bat_mfg_data`, `function nvec_power_bat_notifier`, `function nvec_power_get_property`, `function nvec_battery_get_property`, `function nvec_power_poll`, `function nvec_power_probe`, `function nvec_power_remove`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source 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.