drivers/hwmon/w83793.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/w83793.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/w83793.c- Extension
.c- Size
- 60253 bytes
- Lines
- 2144
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/i2c.hlinux/hwmon.hlinux/hwmon-vid.hlinux/hwmon-sysfs.hlinux/err.hlinux/mutex.hlinux/fs.hlinux/watchdog.hlinux/miscdevice.hlinux/uaccess.hlinux/kref.hlinux/notifier.hlinux/reboot.hlinux/jiffies.h
Detected Declarations
struct w83793_datafunction FAN_FROM_REGfunction FAN_TO_REGfunction TIME_FROM_REGfunction TIME_TO_REGfunction TEMP_FROM_REGfunction TEMP_TO_REGfunction w83793_release_resourcesfunction vrm_showfunction show_vidfunction vrm_storefunction show_alarm_beepfunction store_beepfunction show_beep_enablefunction store_beep_enablefunction store_chassis_clearfunction show_fanfunction store_fan_minfunction show_pwmfunction store_pwmfunction show_tempfunction store_tempfunction show_temp_modefunction store_temp_modefunction show_sf_setupfunction store_sf_setupfunction show_sf_ctrlfunction store_sf_ctrlfunction show_sf2_pwmfunction store_sf2_pwmfunction show_sf2_tempfunction store_sf2_tempfunction show_infunction store_infunction w83793_init_clientfunction watchdog_set_timeoutfunction watchdog_get_timeoutfunction watchdog_triggerfunction watchdog_enablefunction watchdog_disablefunction watchdog_openfunction watchdog_closefunction watchdog_writefunction watchdog_ioctlfunction watchdog_notify_sysfunction list_for_each_entryfunction w83793_removefunction w83793_detect_subclients
Annotated Snippet
static const struct file_operations watchdog_fops = {
.owner = THIS_MODULE,
.open = watchdog_open,
.release = watchdog_close,
.write = watchdog_write,
.unlocked_ioctl = watchdog_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
/*
* Notifier for system down
*/
static int watchdog_notify_sys(struct notifier_block *this, unsigned long code,
void *unused)
{
struct w83793_data *data = NULL;
if (code == SYS_DOWN || code == SYS_HALT) {
/* Disable each registered watchdog */
mutex_lock(&watchdog_data_mutex);
list_for_each_entry(data, &watchdog_data_list, list) {
if (data->watchdog_miscdev.minor)
watchdog_disable(data);
}
mutex_unlock(&watchdog_data_mutex);
}
return NOTIFY_DONE;
}
/*
* The WDT needs to learn about soft shutdowns in order to
* turn the timebomb registers off.
*/
static struct notifier_block watchdog_notifier = {
.notifier_call = watchdog_notify_sys,
};
/*
* Init / remove routines
*/
static void w83793_remove(struct i2c_client *client)
{
struct w83793_data *data = i2c_get_clientdata(client);
struct device *dev = &client->dev;
int i, tmp;
/* Unregister the watchdog (if registered) */
if (data->watchdog_miscdev.minor) {
misc_deregister(&data->watchdog_miscdev);
if (data->watchdog_is_open) {
dev_warn(&client->dev,
"i2c client detached with watchdog open! "
"Stopping watchdog.\n");
watchdog_disable(data);
}
mutex_lock(&watchdog_data_mutex);
list_del(&data->list);
mutex_unlock(&watchdog_data_mutex);
/* Tell the watchdog code the client is gone */
mutex_lock(&data->watchdog_lock);
data->client = NULL;
mutex_unlock(&data->watchdog_lock);
}
/* Reset Configuration Register to Disable Watch Dog Registers */
tmp = w83793_read_value(client, W83793_REG_CONFIG);
w83793_write_value(client, W83793_REG_CONFIG, tmp & ~0x04);
unregister_reboot_notifier(&watchdog_notifier);
hwmon_device_unregister(data->hwmon_dev);
for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++)
device_remove_file(dev,
&w83793_sensor_attr_2[i].dev_attr);
for (i = 0; i < ARRAY_SIZE(sda_single_files); i++)
device_remove_file(dev, &sda_single_files[i].dev_attr);
for (i = 0; i < ARRAY_SIZE(w83793_vid); i++)
device_remove_file(dev, &w83793_vid[i].dev_attr);
device_remove_file(dev, &dev_attr_vrm);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/i2c.h`, `linux/hwmon.h`, `linux/hwmon-vid.h`, `linux/hwmon-sysfs.h`, `linux/err.h`.
- Detected declarations: `struct w83793_data`, `function FAN_FROM_REG`, `function FAN_TO_REG`, `function TIME_FROM_REG`, `function TIME_TO_REG`, `function TEMP_FROM_REG`, `function TEMP_TO_REG`, `function w83793_release_resources`, `function vrm_show`, `function show_vid`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.