drivers/hwmon/ina2xx.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ina2xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ina2xx.c- Extension
.c- Size
- 27549 bytes
- Lines
- 1066
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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/bitfield.hlinux/bits.hlinux/delay.hlinux/device.hlinux/err.hlinux/hwmon.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/property.hlinux/regmap.hlinux/slab.hlinux/sysfs.hlinux/util_macros.h
Detected Declarations
struct ina2xx_configstruct ina2xx_dataenum ina2xx_idsfunction Copyrightfunction ina2xx_volatile_regfunction ina226_reg_to_intervalfunction ina226_interval_to_regfunction ina2xx_get_valuefunction ina2xx_read_initfunction ina2xx_get_valuefunction ina226_alert_limit_readfunction ina226_alert_limit_writefunction ina2xx_chip_readfunction ina226_alert_readfunction ina2xx_in_readfunction READ_EINfunction ina2xx_power_readfunction ina2xx_curr_readfunction ina2xx_readfunction ina2xx_chip_writefunction ina2xx_in_writefunction ina2xx_power_writefunction ina2xx_curr_writefunction ina2xx_writefunction ina2xx_is_visiblefunction ina2xx_set_shuntfunction shunt_resistor_showfunction shunt_resistor_storefunction scoped_guardfunction ina2xx_initfunction ina2xx_probe
Annotated Snippet
struct ina2xx_config {
u16 config_default;
bool has_alerts; /* chip supports alerts and limits */
bool has_ishunt; /* chip has internal shunt resistor */
bool has_power_average; /* chip supports average power */
bool has_update_interval;
int calibration_value;
int shunt_div;
int shunt_voltage_shift;
int bus_voltage_shift;
int bus_voltage_lsb; /* uV */
int power_lsb_factor;
int current_shift;
};
struct ina2xx_data {
const struct ina2xx_config *config;
enum ina2xx_ids chip;
long rshunt;
long current_lsb_uA;
long power_lsb_uW;
struct regmap *regmap;
struct i2c_client *client;
};
static const struct ina2xx_config ina2xx_config[] = {
[ina219] = {
.config_default = INA219_CONFIG_DEFAULT,
.calibration_value = 4096,
.shunt_div = 100,
.shunt_voltage_shift = 0,
.bus_voltage_shift = 3,
.bus_voltage_lsb = 4000,
.power_lsb_factor = 20,
.has_alerts = false,
.has_ishunt = false,
.has_power_average = false,
.current_shift = 0,
.has_update_interval = false,
},
[ina226] = {
.config_default = INA226_CONFIG_DEFAULT,
.calibration_value = 2048,
.shunt_div = 400,
.shunt_voltage_shift = 0,
.bus_voltage_shift = 0,
.bus_voltage_lsb = 1250,
.power_lsb_factor = 25,
.has_alerts = true,
.has_ishunt = false,
.has_power_average = false,
.current_shift = 0,
.has_update_interval = true,
},
[ina234] = {
.config_default = INA226_CONFIG_DEFAULT,
.calibration_value = 2048,
.shunt_div = 25, /* 2.5 µV/LSB raw ADC reading from INA2XX_SHUNT_VOLTAGE */
.shunt_voltage_shift = 4,
.bus_voltage_shift = 4,
.bus_voltage_lsb = 25600,
.power_lsb_factor = 32,
.has_alerts = true,
.has_ishunt = false,
.has_power_average = false,
.current_shift = 4,
.has_update_interval = true,
},
[ina260] = {
.config_default = INA260_CONFIG_DEFAULT,
.shunt_div = 400,
.shunt_voltage_shift = 0,
.bus_voltage_shift = 0,
.bus_voltage_lsb = 1250,
.power_lsb_factor = 8,
.has_alerts = true,
.has_ishunt = true,
.has_power_average = false,
.current_shift = 0,
.has_update_interval = true,
},
[sy24655] = {
.config_default = SY24655_CONFIG_DEFAULT,
.calibration_value = 4096,
.shunt_div = 400,
.shunt_voltage_shift = 0,
.bus_voltage_shift = 0,
.bus_voltage_lsb = 1250,
.power_lsb_factor = 25,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/init.h`.
- Detected declarations: `struct ina2xx_config`, `struct ina2xx_data`, `enum ina2xx_ids`, `function Copyright`, `function ina2xx_volatile_reg`, `function ina226_reg_to_interval`, `function ina226_interval_to_reg`, `function ina2xx_get_value`, `function ina2xx_read_init`, `function ina2xx_get_value`.
- Atlas domain: Driver Families / drivers/hwmon.
- 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.