drivers/hwmon/ltc2992.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ltc2992.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ltc2992.c- Extension
.c- Size
- 24868 bytes
- Lines
- 970
- 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.
- 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/bitfield.hlinux/bitops.hlinux/err.hlinux/gpio/driver.hlinux/hwmon.hlinux/i2c.hlinux/kernel.hlinux/module.hlinux/property.hlinux/regmap.h
Detected Declarations
struct ltc2992_statestruct ltc2992_gpio_regsfunction ltc2992_read_regfunction ltc2992_write_regfunction ltc2992_gpio_getfunction ltc2992_gpio_get_multiplefunction for_each_set_bitfunction ltc2992_gpio_setfunction ltc2992_gpio_set_multiplefunction for_each_set_bitfunction ltc2992_config_gpiofunction ltc2992_is_visiblefunction ltc2992_get_voltagefunction ltc2992_set_voltagefunction ltc2992_read_gpio_alarmfunction ltc2992_read_gpios_infunction ltc2992_read_in_alarmfunction ltc2992_read_infunction ltc2992_get_currentfunction ltc2992_set_currentfunction ltc2992_read_curr_alarmfunction ltc2992_read_currfunction ltc2992_get_powerfunction ltc2992_set_powerfunction ltc2992_read_power_alarmfunction ltc2992_read_powerfunction ltc2992_readfunction ltc2992_write_currfunction ltc2992_write_gpios_infunction ltc2992_write_infunction ltc2992_write_powerfunction ltc2992_write_chipfunction ltc2992_writefunction ltc2992_parse_dtfunction device_for_each_child_node_scopedfunction ltc2992_i2c_probe
Annotated Snippet
struct ltc2992_state {
struct i2c_client *client;
struct gpio_chip gc;
struct mutex gpio_mutex; /* lock for gpio access */
const char *gpio_names[LTC2992_GPIO_NR];
struct regmap *regmap;
u32 r_sense_uohm[2];
};
struct ltc2992_gpio_regs {
u8 data;
u8 max;
u8 min;
u8 max_thresh;
u8 min_thresh;
u8 alarm;
u8 min_alarm_msk;
u8 max_alarm_msk;
u8 ctrl;
u8 ctrl_bit;
};
static const struct ltc2992_gpio_regs ltc2992_gpio_addr_map[] = {
{
.data = LTC2992_G1,
.max = LTC2992_G1_MAX,
.min = LTC2992_G1_MIN,
.max_thresh = LTC2992_G1_MAX_THRESH,
.min_thresh = LTC2992_G1_MIN_THRESH,
.alarm = LTC2992_FAULT1,
.min_alarm_msk = LTC2992_GPIO1_FAULT_MSK(0),
.max_alarm_msk = LTC2992_GPIO1_FAULT_MSK(1),
.ctrl = LTC2992_GPIO_IO_CTRL,
.ctrl_bit = LTC2992_GPIO1_BIT,
},
{
.data = LTC2992_G2,
.max = LTC2992_G2_MAX,
.min = LTC2992_G2_MIN,
.max_thresh = LTC2992_G2_MAX_THRESH,
.min_thresh = LTC2992_G2_MIN_THRESH,
.alarm = LTC2992_FAULT2,
.min_alarm_msk = LTC2992_GPIO2_FAULT_MSK(0),
.max_alarm_msk = LTC2992_GPIO2_FAULT_MSK(1),
.ctrl = LTC2992_GPIO_IO_CTRL,
.ctrl_bit = LTC2992_GPIO2_BIT,
},
{
.data = LTC2992_G3,
.max = LTC2992_G3_MAX,
.min = LTC2992_G3_MIN,
.max_thresh = LTC2992_G3_MAX_THRESH,
.min_thresh = LTC2992_G3_MIN_THRESH,
.alarm = LTC2992_FAULT3,
.min_alarm_msk = LTC2992_GPIO3_FAULT_MSK(0),
.max_alarm_msk = LTC2992_GPIO3_FAULT_MSK(1),
.ctrl = LTC2992_GPIO_IO_CTRL,
.ctrl_bit = LTC2992_GPIO3_BIT,
},
{
.data = LTC2992_G4,
.max = LTC2992_G4_MAX,
.min = LTC2992_G4_MIN,
.max_thresh = LTC2992_G4_MAX_THRESH,
.min_thresh = LTC2992_G4_MIN_THRESH,
.alarm = LTC2992_FAULT3,
.min_alarm_msk = LTC2992_GPIO4_FAULT_MSK(0),
.max_alarm_msk = LTC2992_GPIO4_FAULT_MSK(1),
.ctrl = LTC2992_GPIO_CTRL,
.ctrl_bit = LTC2992_GPIO4_BIT,
},
};
static const char *ltc2992_gpio_names[LTC2992_GPIO_NR] = {
"GPIO1", "GPIO2", "GPIO3", "GPIO4",
};
static int ltc2992_read_reg(struct ltc2992_state *st, u8 addr, const u8 reg_len)
{
u8 regvals[4];
int val;
int ret;
int i;
ret = regmap_bulk_read(st->regmap, addr, regvals, reg_len);
if (ret < 0)
return ret;
val = 0;
for (i = 0; i < reg_len; i++)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/err.h`, `linux/gpio/driver.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct ltc2992_state`, `struct ltc2992_gpio_regs`, `function ltc2992_read_reg`, `function ltc2992_write_reg`, `function ltc2992_gpio_get`, `function ltc2992_gpio_get_multiple`, `function for_each_set_bit`, `function ltc2992_gpio_set`, `function ltc2992_gpio_set_multiple`, `function for_each_set_bit`.
- Atlas domain: Driver Families / drivers/hwmon.
- 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.