drivers/power/supply/sbs-manager.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/sbs-manager.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/sbs-manager.c- Extension
.c- Size
- 10352 bytes
- Lines
- 421
- 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.
- 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/gpio/driver.hlinux/module.hlinux/i2c.hlinux/i2c-mux.hlinux/power_supply.hlinux/property.h
Detected Declarations
struct sbsm_datafunction sbsm_read_wordfunction sbsm_write_wordfunction sbsm_get_propertyfunction sbsm_prop_is_writeablefunction sbsm_set_propertyfunction sbsm_selectfunction sbsm_gpio_get_valuefunction sbsm_gpio_direction_inputfunction sbsm_do_alertfunction sbsm_alertfunction sbsm_gpio_setupfunction sbsm_del_mux_adapterfunction sbsm_probe
Annotated Snippet
struct sbsm_data {
struct i2c_client *client;
struct i2c_mux_core *muxc;
struct power_supply *psy;
u8 cur_chan; /* currently selected channel */
struct gpio_chip chip;
bool is_ltc1760; /* special capabilities */
unsigned int supported_bats;
unsigned int last_state;
unsigned int last_state_cont;
};
static enum power_supply_property sbsm_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_CHARGE_TYPE,
};
static int sbsm_read_word(struct i2c_client *client, u8 address)
{
int reg, retries;
for (retries = SBSM_RETRY_CNT; retries > 0; retries--) {
reg = i2c_smbus_read_word_data(client, address);
if (reg >= 0)
break;
}
if (reg < 0) {
dev_err(&client->dev, "failed to read register 0x%02x\n",
address);
}
return reg;
}
static int sbsm_write_word(struct i2c_client *client, u8 address, u16 word)
{
int ret, retries;
for (retries = SBSM_RETRY_CNT; retries > 0; retries--) {
ret = i2c_smbus_write_word_data(client, address, word);
if (ret >= 0)
break;
}
if (ret < 0)
dev_err(&client->dev, "failed to write to register 0x%02x\n",
address);
return ret;
}
static int sbsm_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct sbsm_data *data = power_supply_get_drvdata(psy);
int regval = 0;
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
regval = sbsm_read_word(data->client, SBSM_CMD_BATSYSSTATECONT);
if (regval < 0)
return regval;
val->intval = !!(regval & SBSM_BIT_AC_PRESENT);
break;
case POWER_SUPPLY_PROP_CHARGE_TYPE:
regval = sbsm_read_word(data->client, SBSM_CMD_BATSYSSTATE);
if (regval < 0)
return regval;
if ((regval & SBSM_MASK_CHARGE_BAT) == 0) {
val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
return 0;
}
val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
if (data->is_ltc1760) {
/* charge mode fast if turbo is active */
regval = sbsm_read_word(data->client, SBSM_CMD_LTC);
if (regval < 0)
return regval;
else if (regval & SBSM_BIT_TURBO)
val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
}
break;
Annotation
- Immediate include surface: `linux/gpio/driver.h`, `linux/module.h`, `linux/i2c.h`, `linux/i2c-mux.h`, `linux/power_supply.h`, `linux/property.h`.
- Detected declarations: `struct sbsm_data`, `function sbsm_read_word`, `function sbsm_write_word`, `function sbsm_get_property`, `function sbsm_prop_is_writeable`, `function sbsm_set_property`, `function sbsm_select`, `function sbsm_gpio_get_value`, `function sbsm_gpio_direction_input`, `function sbsm_do_alert`.
- Atlas domain: Driver Families / drivers/power.
- 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.