drivers/edac/scrub.c
Source file repositories/reference/linux-study-clean/drivers/edac/scrub.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/edac/scrub.c- Extension
.c- Size
- 6401 bytes
- Lines
- 211
- 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_scrub_dev_attrstruct edac_scrub_contextenum edac_scrub_attributesfunction scrub_attr_visiblefunction scrub_create_descfunction edac_scrub_get_desc
Annotated Snippet
struct edac_scrub_dev_attr {
struct device_attribute dev_attr;
u8 instance;
};
struct edac_scrub_context {
char name[EDAC_FEAT_NAME_LEN];
struct edac_scrub_dev_attr scrub_dev_attr[SCRUB_MAX_ATTRS];
struct attribute *scrub_attrs[SCRUB_MAX_ATTRS + 1];
struct attribute_group group;
};
#define TO_SCRUB_DEV_ATTR(_dev_attr) \
container_of(_dev_attr, struct edac_scrub_dev_attr, dev_attr)
#define EDAC_SCRUB_ATTR_SHOW(attrib, cb, type, format) \
static ssize_t attrib##_show(struct device *ras_feat_dev, \
struct device_attribute *attr, char *buf) \
{ \
u8 inst = TO_SCRUB_DEV_ATTR(attr)->instance; \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_scrub_ops *ops = ctx->scrub[inst].scrub_ops; \
type data; \
int ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->scrub[inst].private, &data); \
if (ret) \
return ret; \
\
return sysfs_emit(buf, format, data); \
}
EDAC_SCRUB_ATTR_SHOW(addr, read_addr, u64, "0x%llx\n")
EDAC_SCRUB_ATTR_SHOW(size, read_size, u64, "0x%llx\n")
EDAC_SCRUB_ATTR_SHOW(enable_background, get_enabled_bg, bool, "%u\n")
EDAC_SCRUB_ATTR_SHOW(min_cycle_duration, get_min_cycle, u32, "%u\n")
EDAC_SCRUB_ATTR_SHOW(max_cycle_duration, get_max_cycle, u32, "%u\n")
EDAC_SCRUB_ATTR_SHOW(current_cycle_duration, get_cycle_duration, u32, "%u\n")
#define EDAC_SCRUB_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) \
{ \
u8 inst = TO_SCRUB_DEV_ATTR(attr)->instance; \
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev); \
const struct edac_scrub_ops *ops = ctx->scrub[inst].scrub_ops; \
type data; \
int ret; \
\
ret = conv_func(buf, 0, &data); \
if (ret < 0) \
return ret; \
\
ret = ops->cb(ras_feat_dev->parent, ctx->scrub[inst].private, data); \
if (ret) \
return ret; \
\
return len; \
}
EDAC_SCRUB_ATTR_STORE(addr, write_addr, u64, kstrtou64)
EDAC_SCRUB_ATTR_STORE(size, write_size, u64, kstrtou64)
EDAC_SCRUB_ATTR_STORE(enable_background, set_enabled_bg, unsigned long, kstrtoul)
EDAC_SCRUB_ATTR_STORE(current_cycle_duration, set_cycle_duration, unsigned long, kstrtoul)
static umode_t scrub_attr_visible(struct kobject *kobj, struct attribute *a, int attr_id)
{
struct device *ras_feat_dev = kobj_to_dev(kobj);
struct device_attribute *dev_attr = container_of(a, struct device_attribute, attr);
u8 inst = TO_SCRUB_DEV_ATTR(dev_attr)->instance;
struct edac_dev_feat_ctx *ctx = dev_get_drvdata(ras_feat_dev);
const struct edac_scrub_ops *ops = ctx->scrub[inst].scrub_ops;
switch (attr_id) {
case SCRUB_ADDRESS:
if (ops->read_addr) {
if (ops->write_addr)
return a->mode;
else
return 0444;
}
break;
case SCRUB_SIZE:
if (ops->read_size) {
if (ops->write_size)
return a->mode;
else
return 0444;
}
Annotation
- Immediate include surface: `linux/edac.h`.
- Detected declarations: `struct edac_scrub_dev_attr`, `struct edac_scrub_context`, `enum edac_scrub_attributes`, `function scrub_attr_visible`, `function scrub_create_desc`, `function edac_scrub_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.