drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.c- Extension
.c- Size
- 7483 bytes
- Lines
- 262
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/bits.hlinux/devm-helpers.hlinux/err.hlinux/i2c.hlinux/module.hlinux/power_supply.hlinux/types.hlinux/workqueue.hasm/byteorder.h
Detected Declarations
struct atla10_ec_battery_statestruct atla10_ec_battery_infostruct atla10_ec_datafunction atla10_ec_cmdfunction atla10_ec_updatefunction atla10_ec_psy_get_propertyfunction atla10_ec_external_power_changed_workfunction atla10_ec_external_power_changedfunction atla10_ec_probe
Annotated Snippet
struct atla10_ec_battery_state {
u8 status; /* Using ACPI Battery spec status bits */
u8 capacity; /* Percent */
__le16 charge_now_mAh;
__le16 voltage_now_mV;
__le16 current_now_mA;
__le16 charge_full_mAh;
__le16 temp; /* centi degrees Celsius */
} __packed;
struct atla10_ec_battery_info {
__le16 charge_full_design_mAh;
__le16 voltage_now_mV; /* Should be design voltage, but is not ? */
__le16 charge_full_design2_mAh;
} __packed;
struct atla10_ec_data {
struct i2c_client *client;
struct power_supply *psy;
struct delayed_work work;
struct mutex update_lock;
struct atla10_ec_battery_info info;
struct atla10_ec_battery_state state;
bool valid; /* true if state is valid */
unsigned long last_update; /* In jiffies */
};
static int atla10_ec_cmd(struct atla10_ec_data *data, u8 cmd, u8 len, u8 *values)
{
struct device *dev = &data->client->dev;
u8 buf[I2C_SMBUS_BLOCK_MAX];
int ret;
ret = i2c_smbus_read_block_data(data->client, cmd, buf);
if (ret != len) {
dev_err(dev, "I2C command 0x%02x error: %d\n", cmd, ret);
return -EIO;
}
memcpy(values, buf, len);
return 0;
}
static int atla10_ec_update(struct atla10_ec_data *data)
{
int ret;
if (data->valid && time_before(jiffies, data->last_update + UPDATE_INTERVAL_JIFFIES))
return 0;
ret = atla10_ec_cmd(data, ATLA10_EC_BATTERY_STATE_COMMAND,
sizeof(data->state), (u8 *)&data->state);
if (ret)
return ret;
data->last_update = jiffies;
data->valid = true;
return 0;
}
static int atla10_ec_psy_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct atla10_ec_data *data = power_supply_get_drvdata(psy);
int charge_now_mAh, charge_full_mAh, ret;
guard(mutex)(&data->update_lock);
ret = atla10_ec_update(data);
if (ret)
return ret;
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
if (data->state.status & ACPI_BATTERY_STATE_DISCHARGING)
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
else if (data->state.status & ACPI_BATTERY_STATE_CHARGING)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (data->state.capacity == 100)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
break;
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = data->state.capacity;
break;
case POWER_SUPPLY_PROP_CHARGE_NOW:
/*
* The EC has a bug where it reports charge-full-design as
Annotation
- Immediate include surface: `linux/bits.h`, `linux/devm-helpers.h`, `linux/err.h`, `linux/i2c.h`, `linux/module.h`, `linux/power_supply.h`, `linux/types.h`, `linux/workqueue.h`.
- Detected declarations: `struct atla10_ec_battery_state`, `struct atla10_ec_battery_info`, `struct atla10_ec_data`, `function atla10_ec_cmd`, `function atla10_ec_update`, `function atla10_ec_psy_get_property`, `function atla10_ec_external_power_changed_work`, `function atla10_ec_external_power_changed`, `function atla10_ec_probe`.
- Atlas domain: Driver Families / drivers/platform.
- 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.