drivers/hwmon/adm1026.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/adm1026.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/adm1026.c- Extension
.c- Size
- 60532 bytes
- Lines
- 1882
- 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/module.hlinux/init.hlinux/slab.hlinux/jiffies.hlinux/i2c.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/hwmon-vid.hlinux/err.hlinux/mutex.h
Detected Declarations
struct pwm_datastruct adm1026_datafunction SCALEfunction adm1026_read_valuefunction adm1026_write_valuefunction in_showfunction in_min_showfunction in_min_storefunction in_max_showfunction in_max_storefunction in16_showfunction in16_min_showfunction in16_min_storefunction in16_max_showfunction in16_max_storefunction fan_showfunction fan_min_showfunction fan_min_storefunction fixup_fan_minfunction fan_div_showfunction fan_div_storefunction temp_showfunction temp_min_showfunction temp_min_storefunction temp_max_showfunction temp_max_storefunction temp_offset_showfunction temp_offset_storefunction temp_auto_point1_temp_hyst_showfunction temp_auto_point2_temp_showfunction temp_auto_point1_temp_showfunction temp_auto_point1_temp_storefunction show_temp_crit_enablefunction set_temp_crit_enablefunction temp_crit_showfunction temp_crit_storefunction analog_out_showfunction analog_out_storefunction cpu0_vid_showfunction vrm_showfunction vrm_storefunction alarms_showfunction alarm_showfunction alarm_mask_showfunction alarm_mask_storefunction gpio_showfunction gpio_storefunction gpio_mask_show
Annotated Snippet
struct pwm_data {
u8 pwm;
u8 enable;
u8 auto_pwm_min;
};
struct adm1026_data {
struct i2c_client *client;
const struct attribute_group *groups[3];
struct mutex update_lock;
bool valid; /* true if following fields are valid */
unsigned long last_reading; /* In jiffies */
unsigned long last_config; /* In jiffies */
u8 in[17]; /* Register value */
u8 in_max[17]; /* Register value */
u8 in_min[17]; /* Register value */
s8 temp[3]; /* Register value */
s8 temp_min[3]; /* Register value */
s8 temp_max[3]; /* Register value */
s8 temp_tmin[3]; /* Register value */
s8 temp_crit[3]; /* Register value */
s8 temp_offset[3]; /* Register value */
u8 fan[8]; /* Register value */
u8 fan_min[8]; /* Register value */
u8 fan_div[8]; /* Decoded value */
struct pwm_data pwm1; /* Pwm control values */
u8 vrm; /* VRM version */
u8 analog_out; /* Register value (DAC) */
long alarms; /* Register encoding, combined */
long alarm_mask; /* Register encoding, combined */
long gpio; /* Register encoding, combined */
long gpio_mask; /* Register encoding, combined */
u8 gpio_config[17]; /* Decoded value */
u8 config1; /* Register value */
u8 config2; /* Register value */
u8 config3; /* Register value */
};
static int adm1026_read_value(struct i2c_client *client, u8 reg)
{
int res;
if (reg < 0x80) {
/* "RAM" locations */
res = i2c_smbus_read_byte_data(client, reg) & 0xff;
} else {
/* EEPROM, do nothing */
res = 0;
}
return res;
}
static int adm1026_write_value(struct i2c_client *client, u8 reg, int value)
{
int res;
if (reg < 0x80) {
/* "RAM" locations */
res = i2c_smbus_write_byte_data(client, reg, value);
} else {
/* EEPROM, do nothing */
res = 0;
}
return res;
}
static struct adm1026_data *adm1026_update_device(struct device *dev)
{
struct adm1026_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int i;
long value, alarms, gpio;
mutex_lock(&data->update_lock);
if (!data->valid
|| time_after(jiffies,
data->last_reading + ADM1026_DATA_INTERVAL)) {
/* Things that change quickly */
dev_dbg(&client->dev, "Reading sensor values\n");
for (i = 0; i <= 16; ++i) {
data->in[i] =
adm1026_read_value(client, ADM1026_REG_IN[i]);
}
for (i = 0; i <= 7; ++i) {
data->fan[i] =
adm1026_read_value(client, ADM1026_REG_FAN(i));
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/i2c.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/hwmon-vid.h`.
- Detected declarations: `struct pwm_data`, `struct adm1026_data`, `function SCALE`, `function adm1026_read_value`, `function adm1026_write_value`, `function in_show`, `function in_min_show`, `function in_min_store`, `function in_max_show`, `function in_max_store`.
- 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.