drivers/edac/edac_device_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/edac/edac_device_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/edac_device_sysfs.c- Extension
.c- Size
- 23316 bytes
- Lines
- 854
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ctype.hlinux/module.hlinux/slab.hlinux/edac.hedac_device.hedac_module.h
Detected Declarations
struct ctl_info_attributestruct instance_attributefunction edac_device_ctl_log_ue_showfunction edac_device_ctl_log_ue_storefunction edac_device_ctl_log_ce_showfunction edac_device_ctl_log_ce_storefunction edac_device_ctl_panic_on_ue_showfunction edac_device_ctl_panic_on_ue_storefunction edac_device_ctl_poll_msec_showfunction edac_device_ctl_poll_msec_storefunction edac_dev_ctl_info_showfunction edac_dev_ctl_info_storefunction kobjfunction edac_device_register_sysfs_main_kobjfunction edac_device_unregister_sysfs_main_kobjfunction instance_ue_count_showfunction instance_ce_count_showfunction edac_device_ctrl_instance_releasefunction edac_dev_instance_showfunction edac_dev_instance_storefunction block_ue_count_showfunction block_ce_count_showfunction edac_device_ctrl_block_releasefunction edac_dev_block_showfunction edac_device_create_blockfunction edac_device_delete_blockfunction edac_device_create_instancefunction edac_device_delete_instancefunction edac_device_create_instancesfunction edac_device_delete_instancesfunction edac_device_add_main_sysfs_attributesfunction edac_device_remove_main_sysfs_attributesfunction edac_device_create_sysfsfunction edac_device_remove_sysfs
Annotated Snippet
const struct bus_type *edac_subsys;
int err = -ENODEV;
edac_dbg(1, "\n");
/* get the /sys/devices/system/edac reference */
edac_subsys = edac_get_sysfs_subsys();
/* Point to the 'edac_subsys' this instance 'reports' to */
edac_dev->edac_subsys = edac_subsys;
/* Init the devices's kobject */
memset(&edac_dev->kobj, 0, sizeof(struct kobject));
/* Record which module 'owns' this control structure
* and bump the ref count of the module
*/
edac_dev->owner = THIS_MODULE;
if (!try_module_get(edac_dev->owner))
goto err_out;
/* register */
dev_root = bus_get_dev_root(edac_subsys);
if (dev_root) {
err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
&dev_root->kobj, "%s", edac_dev->name);
put_device(dev_root);
}
if (err) {
edac_dbg(1, "Failed to register '.../edac/%s'\n",
edac_dev->name);
goto err_kobj_reg;
}
kobject_uevent(&edac_dev->kobj, KOBJ_ADD);
/* At this point, to 'free' the control struct,
* edac_device_unregister_sysfs_main_kobj() must be used
*/
edac_dbg(4, "Registered '.../edac/%s' kobject\n", edac_dev->name);
return 0;
/* Error exit stack */
err_kobj_reg:
kobject_put(&edac_dev->kobj);
module_put(edac_dev->owner);
err_out:
return err;
}
/*
* edac_device_unregister_sysfs_main_kobj:
* the '..../edac/<name>' kobject
*/
void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev)
{
edac_dbg(0, "\n");
edac_dbg(4, "name of kobject is: %s\n", kobject_name(&dev->kobj));
/*
* Unregister the edac device's kobject and
* allow for reference count to reach 0 at which point
* the callback will be called to:
* a) module_put() this module
* b) 'kfree' the memory
*/
kobject_put(&dev->kobj);
}
/* edac_dev -> instance information */
/*
* Set of low-level instance attribute show functions
*/
static ssize_t instance_ue_count_show(struct edac_device_instance *instance,
char *data)
{
return sprintf(data, "%u\n", instance->counters.ue_count);
}
static ssize_t instance_ce_count_show(struct edac_device_instance *instance,
char *data)
{
return sprintf(data, "%u\n", instance->counters.ce_count);
}
#define to_instance(k) container_of(k, struct edac_device_instance, kobj)
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/module.h`, `linux/slab.h`, `linux/edac.h`, `edac_device.h`, `edac_module.h`.
- Detected declarations: `struct ctl_info_attribute`, `struct instance_attribute`, `function edac_device_ctl_log_ue_show`, `function edac_device_ctl_log_ue_store`, `function edac_device_ctl_log_ce_show`, `function edac_device_ctl_log_ce_store`, `function edac_device_ctl_panic_on_ue_show`, `function edac_device_ctl_panic_on_ue_store`, `function edac_device_ctl_poll_msec_show`, `function edac_device_ctl_poll_msec_store`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: pattern 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.