drivers/hwmon/adt7462.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/adt7462.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/adt7462.c- Extension
.c- Size
- 54483 bytes
- Lines
- 1841
- 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/jiffies.hlinux/i2c.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/err.hlinux/mod_devicetable.hlinux/mutex.hlinux/log2.hlinux/slab.h
Detected Declarations
struct adt7462_datafunction adt7462_read_word_datafunction ADT7462_REG_FANfunction ADT7462_REG_VOLT_MAXfunction ADT7462_REG_VOLT_MINfunction ADT7462_REG_VOLTfunction voltage_multiplierfunction temp_enabledfunction find_trange_valuefunction temp_min_showfunction temp_min_storefunction temp_max_showfunction temp_max_storefunction temp_showfunction temp_label_showfunction volt_max_showfunction volt_max_storefunction volt_min_showfunction volt_min_storefunction voltage_showfunction voltage_label_showfunction alarm_showfunction fan_enabledfunction fan_min_showfunction fan_min_storefunction fan_showfunction force_pwm_max_showfunction force_pwm_max_storefunction pwm_showfunction pwm_storefunction pwm_max_showfunction pwm_max_storefunction pwm_min_showfunction pwm_min_storefunction pwm_hyst_showfunction pwm_hyst_storefunction pwm_tmax_showfunction pwm_tmax_storefunction pwm_tmin_showfunction pwm_tmin_storefunction pwm_auto_showfunction set_pwm_channelfunction pwm_auto_storefunction pwm_auto_temp_showfunction cvt_auto_tempfunction pwm_auto_temp_storefunction adt7462_detectfunction adt7462_probe
Annotated Snippet
struct adt7462_data {
struct i2c_client *client;
struct mutex lock;
char sensors_valid;
char limits_valid;
unsigned long sensors_last_updated; /* In jiffies */
unsigned long limits_last_updated; /* In jiffies */
u8 temp[ADT7462_TEMP_COUNT];
/* bits 6-7 are quarter pieces of temp */
u8 temp_frac[ADT7462_TEMP_COUNT];
u8 temp_min[ADT7462_TEMP_COUNT];
u8 temp_max[ADT7462_TEMP_COUNT];
u16 fan[ADT7462_FAN_COUNT];
u8 fan_enabled;
u8 fan_min[ADT7462_FAN_COUNT];
u8 cfg2;
u8 pwm[ADT7462_PWM_COUNT];
u8 pin_cfg[ADT7462_PIN_CFG_REG_COUNT];
u8 voltages[ADT7462_VOLT_COUNT];
u8 volt_max[ADT7462_VOLT_COUNT];
u8 volt_min[ADT7462_VOLT_COUNT];
u8 pwm_min[ADT7462_PWM_COUNT];
u8 pwm_tmin[ADT7462_PWM_COUNT];
u8 pwm_trange[ADT7462_PWM_COUNT];
u8 pwm_max; /* only one per chip */
u8 pwm_cfg[ADT7462_PWM_COUNT];
u8 alarms[ADT7462_ALARM_REG_COUNT];
};
/*
* 16-bit registers on the ADT7462 are low-byte first. The data sheet says
* that the low byte must be read before the high byte.
*/
static inline int adt7462_read_word_data(struct i2c_client *client, u8 reg)
{
u16 foo;
foo = i2c_smbus_read_byte_data(client, reg);
foo |= ((u16)i2c_smbus_read_byte_data(client, reg + 1) << 8);
return foo;
}
/* For some reason these registers are not contiguous. */
static int ADT7462_REG_FAN(int fan)
{
if (fan < 4)
return ADT7462_REG_FAN_BASE_ADDR + (2 * fan);
return ADT7462_REG_FAN2_BASE_ADDR + (2 * (fan - 4));
}
/* Voltage registers are scattered everywhere */
static int ADT7462_REG_VOLT_MAX(struct adt7462_data *data, int which)
{
switch (which) {
case 0:
if (!(data->pin_cfg[0] & ADT7462_PIN7_INPUT))
return 0x7C;
break;
case 1:
return 0x69;
case 2:
if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
return 0x7F;
break;
case 3:
if (!(data->pin_cfg[1] & ADT7462_PIN21_INPUT))
return 0x7E;
break;
case 4:
if (!(data->pin_cfg[0] & ADT7462_DIODE3_INPUT))
return 0x4B;
break;
case 5:
if (!(data->pin_cfg[0] & ADT7462_DIODE1_INPUT))
return 0x49;
break;
case 6:
if (!(data->pin_cfg[1] & ADT7462_PIN13_INPUT))
return 0x68;
break;
case 7:
if (!(data->pin_cfg[1] & ADT7462_PIN8_INPUT))
return 0x7D;
break;
case 8:
if (!(data->pin_cfg[2] & ADT7462_PIN26_VOLT_INPUT))
return 0x6C;
break;
case 9:
if (!(data->pin_cfg[2] & ADT7462_PIN25_VOLT_INPUT))
Annotation
- Immediate include surface: `linux/module.h`, `linux/jiffies.h`, `linux/i2c.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/err.h`, `linux/mod_devicetable.h`, `linux/mutex.h`.
- Detected declarations: `struct adt7462_data`, `function adt7462_read_word_data`, `function ADT7462_REG_FAN`, `function ADT7462_REG_VOLT_MAX`, `function ADT7462_REG_VOLT_MIN`, `function ADT7462_REG_VOLT`, `function voltage_multiplier`, `function temp_enabled`, `function find_trange_value`, `function temp_min_show`.
- 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.