drivers/edac/edac_pci_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/edac/edac_pci_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/edac_pci_sysfs.c- Extension
.c- Size
- 19538 bytes
- Lines
- 744
- Domain
- Driver Families
- Bucket
- drivers/edac
- 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.
- 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/edac.hlinux/slab.hlinux/ctype.hedac_pci.hedac_module.h
Detected Declarations
struct instance_attributestruct edac_pci_dev_attributefunction edac_pci_get_check_errorsfunction edac_pci_get_log_pefunction edac_pci_get_log_npefunction edac_pci_get_panic_on_pefunction edac_pci_get_poll_msecfunction instance_pe_count_showfunction instance_npe_count_showfunction edac_pci_instance_releasefunction edac_pci_instance_showfunction edac_pci_instance_storefunction edac_pci_create_instance_kobjfunction edac_pci_unregister_sysfs_instance_kobjfunction edac_pci_int_showfunction edac_pci_int_storefunction edac_pci_dev_showfunction edac_pci_dev_storefunction edac_pci_release_main_kobjfunction edac_pci_main_kobj_setupfunction edac_pci_main_kobj_teardownfunction edac_pci_create_sysfsfunction edac_pci_remove_sysfsfunction get_pci_parity_statusfunction edac_pci_dev_parity_clearfunction edac_pci_dev_parity_testfunction edac_pci_dev_parity_iteratorfunction edac_pci_do_parity_checkfunction edac_pci_clear_parity_errorsfunction edac_pci_handle_pefunction edac_pci_handle_npeexport edac_pci_handle_peexport edac_pci_handle_npe
Annotated Snippet
const struct bus_type *edac_subsys;
struct device *dev_root;
edac_dbg(0, "\n");
/* check and count if we have already created the main kobject */
if (atomic_inc_return(&edac_pci_sysfs_refcount) != 1)
return 0;
/* First time, so create the main kobject and its
* controls and attributes
*/
edac_subsys = edac_get_sysfs_subsys();
/* Bump the reference count on this module to ensure the
* modules isn't unloaded until we deconstruct the top
* level main kobj for EDAC PCI
*/
if (!try_module_get(THIS_MODULE)) {
edac_dbg(1, "try_module_get() failed\n");
goto decrement_count_fail;
}
edac_pci_top_main_kobj = kzalloc_obj(struct kobject);
if (!edac_pci_top_main_kobj) {
edac_dbg(1, "Failed to allocate\n");
err = -ENOMEM;
goto kzalloc_fail;
}
/* Instanstiate the pci object */
dev_root = bus_get_dev_root(edac_subsys);
if (dev_root) {
err = kobject_init_and_add(edac_pci_top_main_kobj,
&ktype_edac_pci_main_kobj,
&dev_root->kobj, "pci");
put_device(dev_root);
}
if (err) {
edac_dbg(1, "Failed to register '.../edac/pci'\n");
goto kobject_init_and_add_fail;
}
/* At this point, to 'release' the top level kobject
* for EDAC PCI, then edac_pci_main_kobj_teardown()
* must be used, for resources to be cleaned up properly
*/
kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD);
edac_dbg(1, "Registered '.../edac/pci' kobject\n");
return 0;
/* Error unwind statck */
kobject_init_and_add_fail:
kobject_put(edac_pci_top_main_kobj);
kzalloc_fail:
module_put(THIS_MODULE);
decrement_count_fail:
/* if are on this error exit, nothing to tear down */
atomic_dec(&edac_pci_sysfs_refcount);
return err;
}
/*
* edac_pci_main_kobj_teardown()
*
* if no longer linked (needed) remove the top level EDAC PCI
* kobject with its controls and attributes
*/
static void edac_pci_main_kobj_teardown(void)
{
edac_dbg(0, "\n");
/* Decrement the count and only if no more controller instances
* are connected perform the unregisteration of the top level
* main kobj
*/
if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
edac_dbg(0, "called kobject_put on main kobj\n");
kobject_put(edac_pci_top_main_kobj);
}
}
int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
{
int err;
struct kobject *edac_kobj = &pci->kobj;
Annotation
- Immediate include surface: `linux/module.h`, `linux/edac.h`, `linux/slab.h`, `linux/ctype.h`, `edac_pci.h`, `edac_module.h`.
- Detected declarations: `struct instance_attribute`, `struct edac_pci_dev_attribute`, `function edac_pci_get_check_errors`, `function edac_pci_get_log_pe`, `function edac_pci_get_log_npe`, `function edac_pci_get_panic_on_pe`, `function edac_pci_get_poll_msec`, `function instance_pe_count_show`, `function instance_npe_count_show`, `function edac_pci_instance_release`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: pattern 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.