drivers/hwmon/sch5636.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/sch5636.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/sch5636.c- Extension
.c- Size
- 14956 bytes
- Lines
- 524
- 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/mod_devicetable.hlinux/init.hlinux/slab.hlinux/jiffies.hlinux/platform_device.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/err.hlinux/mutex.hsch56xx-common.h
Detected Declarations
struct sch5636_datafunction reg_to_rpmfunction name_showfunction in_value_showfunction in_label_showfunction temp_value_showfunction temp_fault_showfunction temp_alarm_showfunction fan_value_showfunction fan_fault_showfunction fan_alarm_showfunction sch5636_removefunction sch5636_probe
Annotated Snippet
struct sch5636_data {
unsigned short addr;
struct device *hwmon_dev;
struct mutex update_lock;
bool valid; /* true if following fields are valid */
unsigned long last_updated; /* In jiffies */
u8 in[SCH5636_NO_INS];
u8 temp_val[SCH5636_NO_TEMPS];
u8 temp_ctrl[SCH5636_NO_TEMPS];
u16 fan_val[SCH5636_NO_FANS];
u8 fan_ctrl[SCH5636_NO_FANS];
};
static struct sch5636_data *sch5636_update_device(struct device *dev)
{
struct sch5636_data *data = dev_get_drvdata(dev);
struct sch5636_data *ret = data;
int i, val;
mutex_lock(&data->update_lock);
/* Cache the values for 1 second */
if (data->valid && !time_after(jiffies, data->last_updated + HZ))
goto abort;
for (i = 0; i < SCH5636_NO_INS; i++) {
val = sch56xx_read_virtual_reg(data->addr,
SCH5636_REG_IN_VAL[i]);
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
data->in[i] = val;
}
for (i = 0; i < SCH5636_NO_TEMPS; i++) {
if (data->temp_ctrl[i] & SCH5636_TEMP_DEACTIVATED)
continue;
val = sch56xx_read_virtual_reg(data->addr,
SCH5636_REG_TEMP_VAL[i]);
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
data->temp_val[i] = val;
val = sch56xx_read_virtual_reg(data->addr,
SCH5636_REG_TEMP_CTRL(i));
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
data->temp_ctrl[i] = val;
/* Alarms need to be explicitly write-cleared */
if (val & SCH5636_TEMP_ALARM) {
sch56xx_write_virtual_reg(data->addr,
SCH5636_REG_TEMP_CTRL(i), val);
}
}
for (i = 0; i < SCH5636_NO_FANS; i++) {
if (data->fan_ctrl[i] & SCH5636_FAN_DEACTIVATED)
continue;
val = sch56xx_read_virtual_reg16(data->addr,
SCH5636_REG_FAN_VAL[i]);
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
data->fan_val[i] = val;
val = sch56xx_read_virtual_reg(data->addr,
SCH5636_REG_FAN_CTRL(i));
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
data->fan_ctrl[i] = val;
/* Alarms need to be explicitly write-cleared */
if (val & SCH5636_FAN_ALARM) {
sch56xx_write_virtual_reg(data->addr,
SCH5636_REG_FAN_CTRL(i), val);
}
}
data->last_updated = jiffies;
data->valid = true;
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/init.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/platform_device.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`.
- Detected declarations: `struct sch5636_data`, `function reg_to_rpm`, `function name_show`, `function in_value_show`, `function in_label_show`, `function temp_value_show`, `function temp_fault_show`, `function temp_alarm_show`, `function fan_value_show`, `function fan_fault_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.