drivers/edac/edac_device.c
Source file repositories/reference/linux-study-clean/drivers/edac/edac_device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/edac_device.c- Extension
.c- Size
- 19887 bytes
- Lines
- 759
- Domain
- Driver Families
- Bucket
- drivers/edac
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
asm/page.hlinux/uaccess.hlinux/ctype.hlinux/highmem.hlinux/init.hlinux/jiffies.hlinux/module.hlinux/slab.hlinux/smp.hlinux/spinlock.hlinux/sysctl.hlinux/timer.hedac_device.hedac_module.h
Detected Declarations
function edac_device_dump_devicefunction edac_device_alloc_ctl_infofunction edac_device_free_ctl_infofunction list_for_eachfunction add_edac_dev_to_global_listfunction del_edac_device_from_global_listfunction edac_device_workq_functionfunction edac_device_workq_setupfunction edac_device_workq_teardownfunction edac_device_reset_delay_periodfunction edac_device_alloc_indexfunction edac_device_add_devicefunction edac_device_get_log_cefunction edac_device_get_log_uefunction edac_device_get_panic_on_uefunction edac_device_handle_ce_countfunction edac_device_handle_ue_countfunction edac_dev_releasefunction edac_dev_unregfunction edac_dev_registerexport edac_device_alloc_ctl_infoexport edac_device_free_ctl_infoexport edac_device_alloc_indexexport edac_device_add_deviceexport edac_device_del_deviceexport edac_device_handle_ce_countexport edac_device_handle_ue_countexport edac_dev_register
Annotated Snippet
if (rover->dev_idx >= edac_dev->dev_idx) {
if (unlikely(rover->dev_idx == edac_dev->dev_idx))
goto fail1;
insert_before = item;
break;
}
}
list_add_tail_rcu(&edac_dev->link, insert_before);
return 0;
fail0:
edac_printk(KERN_WARNING, EDAC_MC,
"%s (%s) %s %s already assigned %d\n",
dev_name(rover->dev), edac_dev_name(rover),
rover->mod_name, rover->ctl_name, rover->dev_idx);
return 1;
fail1:
edac_printk(KERN_WARNING, EDAC_MC,
"bug in low-level driver: attempt to assign\n"
" duplicate dev_idx %d in %s()\n", rover->dev_idx,
__func__);
return 1;
}
/*
* del_edac_device_from_global_list
*/
static void del_edac_device_from_global_list(struct edac_device_ctl_info
*edac_device)
{
list_del_rcu(&edac_device->link);
/* these are for safe removal of devices from global list while
* NMI handlers may be traversing list
*/
synchronize_rcu();
INIT_LIST_HEAD(&edac_device->link);
}
/*
* edac_device_workq_function
* performs the operation scheduled by a workq request
*
* this workq is embedded within an edac_device_ctl_info
* structure, that needs to be polled for possible error events.
*
* This operation is to acquire the list mutex lock
* (thus preventing insertation or deletion)
* and then call the device's poll function IFF this device is
* running polled and there is a poll function defined.
*/
static void edac_device_workq_function(struct work_struct *work_req)
{
struct delayed_work *d_work = to_delayed_work(work_req);
struct edac_device_ctl_info *edac_dev = to_edac_device_ctl_work(d_work);
mutex_lock(&device_ctls_mutex);
/* If we are being removed, bail out immediately */
if (edac_dev->op_state == OP_OFFLINE) {
mutex_unlock(&device_ctls_mutex);
return;
}
/* Only poll controllers that are running polled and have a check */
if ((edac_dev->op_state == OP_RUNNING_POLL) &&
(edac_dev->edac_check != NULL)) {
edac_dev->edac_check(edac_dev);
}
mutex_unlock(&device_ctls_mutex);
/* Reschedule the workq for the next time period to start again
* if the number of msec is for 1 sec, then adjust to the next
* whole one second to save timers firing all over the period
* between integral seconds
*/
if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
else
edac_queue_work(&edac_dev->work, edac_dev->delay);
}
/*
* edac_device_workq_setup
* initialize a workq item for this edac_device instance
* passing in the new delay period in msec
Annotation
- Immediate include surface: `asm/page.h`, `linux/uaccess.h`, `linux/ctype.h`, `linux/highmem.h`, `linux/init.h`, `linux/jiffies.h`, `linux/module.h`, `linux/slab.h`.
- Detected declarations: `function edac_device_dump_device`, `function edac_device_alloc_ctl_info`, `function edac_device_free_ctl_info`, `function list_for_each`, `function add_edac_dev_to_global_list`, `function del_edac_device_from_global_list`, `function edac_device_workq_function`, `function edac_device_workq_setup`, `function edac_device_workq_teardown`, `function edac_device_reset_delay_period`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: integration 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.