drivers/power/supply/surface-rt-ec.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/surface-rt-ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/surface-rt-ec.c- Extension
.c- Size
- 9887 bytes
- Lines
- 390
- Domain
- Driver Families
- Bucket
- drivers/power
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/devm-helpers.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/interrupt.hlinux/module.hlinux/property.hlinux/power_supply.hlinux/types.h
Detected Declarations
struct srt_ec_devicefunction srt_bat_get_valuefunction srt_bat_power_supply_get_propertyfunction srt_psy_power_supply_get_propertyfunction srt_bat_poll_workfunction srt_psy_detect_irqfunction srt_ec_probefunction srt_ec_suspendfunction srt_ec_resume
Annotated Snippet
struct srt_ec_device {
struct i2c_client *client;
struct power_supply *bat;
struct power_supply *psy;
struct gpio_desc *enable_gpiod;
struct delayed_work poll_work;
unsigned int technology;
unsigned int capacity;
const char *serial;
char manufacturer[13];
char model_name[10];
};
static const enum power_supply_property srt_bat_power_supply_props[] = {
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_SERIAL_NUMBER,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
};
static const enum power_supply_property srt_psy_power_supply_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_PRESENT,
};
static int srt_bat_get_value(struct i2c_client *client, int reg, int *val)
{
int ret;
switch (reg) {
case REGW_CHARGE_NOW:
case REGW_CHARGE_FULL_DESIGN:
case REGW_CHARGE_FULL:
case REGW_VOLTAGE_MAX_DESIGN:
case REGW_VOLTAGE_NOW:
ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
*val = ret * 1000;
break;
case REGW_CURRENT_NOW:
ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
*val = (s16)ret * 1000;
break;
case REGW_CAPACITY:
case REGW_CYCLE_COUNT:
ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
*val = ret;
break;
case REGB_STATUS:
ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0)
return ret;
if (ret & BIT(0))
*val = POWER_SUPPLY_STATUS_CHARGING;
else
*val = POWER_SUPPLY_STATUS_DISCHARGING;
break;
case REGB_ONLINE:
ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/devm-helpers.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/module.h`, `linux/property.h`, `linux/power_supply.h`.
- Detected declarations: `struct srt_ec_device`, `function srt_bat_get_value`, `function srt_bat_power_supply_get_property`, `function srt_psy_power_supply_get_property`, `function srt_bat_poll_work`, `function srt_psy_detect_irq`, `function srt_ec_probe`, `function srt_ec_suspend`, `function srt_ec_resume`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.