drivers/hwmon/max6639.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/max6639.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/max6639.c- Extension
.c- Size
- 20205 bytes
- Lines
- 812
- 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/module.hlinux/init.hlinux/slab.hlinux/jiffies.hlinux/i2c.hlinux/hwmon.hlinux/err.hlinux/regmap.hlinux/util_macros.h
Detected Declarations
struct max6639_datafunction max6639_temp_read_inputfunction max6639_temp_read_faultfunction max6639_temp_read_maxfunction max6639_temp_read_critfunction max6639_temp_read_emergencyfunction max6639_get_statusfunction max6639_temp_set_maxfunction max6639_temp_set_critfunction max6639_temp_set_emergencyfunction max6639_read_fanfunction max6639_set_pprfunction max6639_write_fanfunction max6639_fan_is_visiblefunction max6639_read_pwmfunction max6639_write_pwmfunction max6639_pwm_is_visiblefunction max6639_read_tempfunction max6639_write_tempfunction max6639_temp_is_visiblefunction max6639_readfunction max6639_writefunction max6639_is_visiblefunction rpm_range_to_regfunction max6639_probe_child_from_dtfunction max6639_init_clientfunction for_each_child_of_node_scopedfunction max6639_detectfunction max6639_regulator_disablefunction max6639_regmap_is_volatilefunction max6639_probefunction max6639_suspendfunction max6639_resume
Annotated Snippet
struct max6639_data {
struct regmap *regmap;
/* Register values initialized only once */
u8 ppr[MAX6639_NUM_CHANNELS]; /* Pulses per rotation 0..3 for 1..4 ppr */
u8 rpm_range[MAX6639_NUM_CHANNELS]; /* Index in above rpm_ranges table */
u32 target_rpm[MAX6639_NUM_CHANNELS];
/* Optional regulator for FAN supply */
struct regulator *reg;
};
static int max6639_temp_read_input(struct device *dev, int channel, long *temp)
{
u32 regs[2] = { MAX6639_REG_TEMP_EXT(channel), MAX6639_REG_TEMP(channel) };
struct max6639_data *data = dev_get_drvdata(dev);
u8 regvals[2];
int res;
res = regmap_multi_reg_read(data->regmap, regs, regvals, 2);
if (res < 0)
return res;
*temp = ((regvals[0] >> 5) | (regvals[1] << 3)) * 125;
return 0;
}
static int max6639_temp_read_fault(struct device *dev, int channel, long *fault)
{
struct max6639_data *data = dev_get_drvdata(dev);
unsigned int val;
int res;
res = regmap_read(data->regmap, MAX6639_REG_TEMP_EXT(channel), &val);
if (res < 0)
return res;
*fault = val & 1;
return 0;
}
static int max6639_temp_read_max(struct device *dev, int channel, long *max)
{
struct max6639_data *data = dev_get_drvdata(dev);
unsigned int val;
int res;
res = regmap_read(data->regmap, MAX6639_REG_THERM_LIMIT(channel), &val);
if (res < 0)
return res;
*max = (long)val * 1000;
return 0;
}
static int max6639_temp_read_crit(struct device *dev, int channel, long *crit)
{
struct max6639_data *data = dev_get_drvdata(dev);
unsigned int val;
int res;
res = regmap_read(data->regmap, MAX6639_REG_ALERT_LIMIT(channel), &val);
if (res < 0)
return res;
*crit = (long)val * 1000;
return 0;
}
static int max6639_temp_read_emergency(struct device *dev, int channel, long *emerg)
{
struct max6639_data *data = dev_get_drvdata(dev);
unsigned int val;
int res;
res = regmap_read(data->regmap, MAX6639_REG_OT_LIMIT(channel), &val);
if (res < 0)
return res;
*emerg = (long)val * 1000;
return 0;
}
static int max6639_get_status(struct device *dev, unsigned int *status)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/i2c.h`, `linux/hwmon.h`, `linux/err.h`, `linux/regmap.h`.
- Detected declarations: `struct max6639_data`, `function max6639_temp_read_input`, `function max6639_temp_read_fault`, `function max6639_temp_read_max`, `function max6639_temp_read_crit`, `function max6639_temp_read_emergency`, `function max6639_get_status`, `function max6639_temp_set_max`, `function max6639_temp_set_crit`, `function max6639_temp_set_emergency`.
- 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.