drivers/acpi/sbs.c
Source file repositories/reference/linux-study-clean/drivers/acpi/sbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/sbs.c- Extension
.c- Size
- 19309 bytes
- Lines
- 718
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/slab.hlinux/module.hlinux/moduleparam.hlinux/kernel.hlinux/acpi.hlinux/timer.hlinux/jiffies.hlinux/delay.hlinux/platform_device.hlinux/power_supply.hlinux/platform_data/x86/apple.hacpi/battery.hsbshc.h
Detected Declarations
struct acpi_batterystruct acpi_sbsstruct acpi_battery_readerfunction battery_scalefunction acpi_battery_vscalefunction acpi_battery_ipscalefunction acpi_battery_modefunction acpi_battery_scalefunction sbs_get_ac_propertyfunction acpi_battery_technologyfunction acpi_sbs_battery_get_propertyfunction acpi_manager_get_infofunction acpi_battery_get_infofunction acpi_battery_get_statefunction acpi_battery_get_alarmfunction acpi_battery_set_alarmfunction acpi_ac_get_presentfunction acpi_battery_alarm_showfunction acpi_battery_alarm_storefunction acpi_battery_readfunction acpi_battery_addfunction acpi_battery_removefunction acpi_charger_addfunction acpi_charger_removefunction acpi_sbs_callbackfunction acpi_sbs_probefunction acpi_sbs_removefunction acpi_sbs_resume
Annotated Snippet
struct acpi_battery {
struct power_supply *bat;
struct power_supply_desc bat_desc;
struct acpi_sbs *sbs;
unsigned long update_time;
char name[8];
char manufacturer_name[ACPI_SBS_BLOCK_MAX];
char device_name[ACPI_SBS_BLOCK_MAX];
char device_chemistry[ACPI_SBS_BLOCK_MAX];
u16 alarm_capacity;
u16 full_charge_capacity;
u16 design_capacity;
u16 design_voltage;
u16 serial_number;
u16 cycle_count;
u16 temp_now;
u16 voltage_now;
s16 rate_now;
s16 rate_avg;
u16 capacity_now;
u16 state_of_charge;
u16 state;
u16 mode;
u16 spec;
u8 id;
u8 present:1;
};
#define to_acpi_battery(x) power_supply_get_drvdata(x)
struct acpi_sbs {
struct power_supply *charger;
struct acpi_device *device;
struct acpi_smb_hc *hc;
struct mutex lock;
struct acpi_battery battery[MAX_SBS_BAT];
u8 batteries_supported:4;
u8 manager_present:1;
u8 charger_present:1;
u8 charger_exists:1;
};
#define to_acpi_sbs(x) power_supply_get_drvdata(x)
static void acpi_sbs_remove(struct platform_device *pdev);
static int acpi_battery_get_state(struct acpi_battery *battery);
static inline int battery_scale(int log)
{
int scale = 1;
while (log--)
scale *= 10;
return scale;
}
static inline int acpi_battery_vscale(struct acpi_battery *battery)
{
return battery_scale((battery->spec & 0x0f00) >> 8);
}
static inline int acpi_battery_ipscale(struct acpi_battery *battery)
{
return battery_scale((battery->spec & 0xf000) >> 12);
}
static inline int acpi_battery_mode(struct acpi_battery *battery)
{
return (battery->mode & 0x8000);
}
static inline int acpi_battery_scale(struct acpi_battery *battery)
{
return (acpi_battery_mode(battery) ? 10 : 1) *
acpi_battery_ipscale(battery);
}
static int sbs_get_ac_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct acpi_sbs *sbs = to_acpi_sbs(psy);
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
val->intval = sbs->charger_present;
break;
default:
return -EINVAL;
}
return 0;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/acpi.h`, `linux/timer.h`, `linux/jiffies.h`.
- Detected declarations: `struct acpi_battery`, `struct acpi_sbs`, `struct acpi_battery_reader`, `function battery_scale`, `function acpi_battery_vscale`, `function acpi_battery_ipscale`, `function acpi_battery_mode`, `function acpi_battery_scale`, `function sbs_get_ac_property`, `function acpi_battery_technology`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.