drivers/edac/ecs.c
Source file repositories/reference/linux-study-clean/drivers/edac/ecs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/ecs.c- Extension
.c- Size
- 5865 bytes
- Lines
- 208
- Domain
- Driver Families
- Bucket
- drivers/edac
- 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.
- 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/edac.h
Detected Declarations
struct edac_ecs_dev_attrstruct edac_ecs_fru_contextstruct edac_ecs_contextenum edac_ecs_attributesfunction ecs_attr_visiblefunction ecs_create_descfunction edac_ecs_get_desc
Annotated Snippet
struct edac_ecs_dev_attr {
struct device_attribute dev_attr;
int fru_id;
};
struct edac_ecs_fru_context {
char name[EDAC_FEAT_NAME_LEN];
struct edac_ecs_dev_attr dev_attr[ECS_MAX_ATTRS];
struct attribute *ecs_attrs[ECS_MAX_ATTRS + 1];
struct attribute_group group;
};
struct edac_ecs_context {
u16 num_media_frus;
struct edac_ecs_fru_context *fru_ctxs;
};
#define TO_ECS_DEV_ATTR(_dev_attr) \
container_of(_dev_attr, struct edac_ecs_dev_attr, dev_attr)
#define EDAC_ECS_ATTR_SHOW(attrib, cb, type, format) \
static ssize_t attrib##_show(struct device *ras_feat_dev, \
struct device_attribute *attr, char *buf) \
{ \
struct edac_ecs_dev_attr *dev_attr = TO_ECS_DEV_ATTR(attr); \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_ecs_ops *ops = ctx->ecs.ecs_ops; \
type data; \
int ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->ecs.private, \
dev_attr->fru_id, &data); \
if (ret) \
return ret; \
\
return sysfs_emit(buf, format, data); \
}
EDAC_ECS_ATTR_SHOW(log_entry_type, get_log_entry_type, u32, "%u\n")
EDAC_ECS_ATTR_SHOW(mode, get_mode, u32, "%u\n")
EDAC_ECS_ATTR_SHOW(threshold, get_threshold, u32, "%u\n")
#define EDAC_ECS_ATTR_STORE(attrib, cb, type, conv_func) \
static ssize_t attrib##_store(struct device *ras_feat_dev, \
struct device_attribute *attr, \
const char *buf, size_t len) \
{ \
struct edac_ecs_dev_attr *dev_attr = TO_ECS_DEV_ATTR(attr); \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_ecs_ops *ops = ctx->ecs.ecs_ops; \
type data; \
int ret; \
\
ret = conv_func(buf, 0, &data); \
if (ret < 0) \
return ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->ecs.private, \
dev_attr->fru_id, data); \
if (ret) \
return ret; \
\
return len; \
}
EDAC_ECS_ATTR_STORE(log_entry_type, set_log_entry_type, unsigned long, kstrtoul)
EDAC_ECS_ATTR_STORE(mode, set_mode, unsigned long, kstrtoul)
EDAC_ECS_ATTR_STORE(reset, reset, unsigned long, kstrtoul)
EDAC_ECS_ATTR_STORE(threshold, set_threshold, unsigned long, kstrtoul)
static umode_t ecs_attr_visible(struct kobject *kobj, struct attribute *a, int attr_id)
{
struct device *ras_feat_dev = kobj_to_dev(kobj);
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev);
const struct edac_ecs_ops *ops = ctx->ecs.ecs_ops;
switch (attr_id) {
case ECS_LOG_ENTRY_TYPE:
if (ops->get_log_entry_type) {
if (ops->set_log_entry_type)
return a->mode;
else
return 0444;
}
break;
case ECS_MODE:
if (ops->get_mode) {
if (ops->set_mode)
return a->mode;
else
Annotation
- Immediate include surface: `linux/edac.h`.
- Detected declarations: `struct edac_ecs_dev_attr`, `struct edac_ecs_fru_context`, `struct edac_ecs_context`, `enum edac_ecs_attributes`, `function ecs_attr_visible`, `function ecs_create_desc`, `function edac_ecs_get_desc`.
- Atlas domain: Driver Families / drivers/edac.
- Implementation status: source 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.