drivers/firmware/edd.c
Source file repositories/reference/linux-study-clean/drivers/firmware/edd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/edd.c- Extension
.c- Size
- 19777 bytes
- Lines
- 781
- Domain
- Driver Families
- Bucket
- drivers/firmware
- 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/module.hlinux/string.hlinux/types.hlinux/init.hlinux/stat.hlinux/err.hlinux/ctype.hlinux/slab.hlinux/limits.hlinux/device.hlinux/pci.hlinux/blkdev.hlinux/edd.h
Detected Declarations
struct edd_devicestruct edd_attributefunction edd_has_mbr_signaturefunction edd_has_edd_infofunction edd_dev_get_infofunction edd_dev_set_infofunction edd_attr_showfunction edd_show_host_busfunction edd_show_interfacefunction edd_show_raw_datafunction edd_show_versionfunction edd_show_mbr_signaturefunction edd_show_extensionsfunction edd_show_info_flagsfunction edd_show_legacy_max_cylinderfunction edd_show_legacy_max_headfunction edd_show_legacy_sectors_per_trackfunction edd_show_default_cylindersfunction edd_show_default_headsfunction edd_show_default_sectors_per_trackfunction edd_show_sectorsfunction meaninglessfunction edd_has_legacy_max_headfunction edd_has_legacy_sectors_per_trackfunction edd_has_default_cylindersfunction edd_has_default_headsfunction edd_has_default_sectors_per_trackfunction edd_has_edd30function edd_releasefunction edd_dev_is_typefunction edd_get_pci_devfunction edd_create_symlink_to_pcidevfunction edd_device_unregisterfunction edd_populate_dirfunction edd_device_registerfunction edd_num_devicesfunction edd_initfunction edd_exit
Annotated Snippet
struct edd_device {
unsigned int index;
unsigned int mbr_signature;
struct edd_info *info;
struct kobject kobj;
};
struct edd_attribute {
struct attribute attr;
ssize_t(*show) (struct edd_device * edev, char *buf);
int (*test) (struct edd_device * edev);
};
/* forward declarations */
static int edd_dev_is_type(struct edd_device *edev, const char *type);
static struct pci_dev *edd_get_pci_dev(struct edd_device *edev);
static struct edd_device *edd_devices[EDD_MBR_SIG_MAX];
#define EDD_DEVICE_ATTR(_name,_mode,_show,_test) \
struct edd_attribute edd_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.test = _test, \
};
static int
edd_has_mbr_signature(struct edd_device *edev)
{
return edev->index < min_t(unsigned char, edd.mbr_signature_nr, EDD_MBR_SIG_MAX);
}
static int
edd_has_edd_info(struct edd_device *edev)
{
return edev->index < min_t(unsigned char, edd.edd_info_nr, EDDMAXNR);
}
static inline struct edd_info *
edd_dev_get_info(struct edd_device *edev)
{
return edev->info;
}
static inline void
edd_dev_set_info(struct edd_device *edev, int i)
{
edev->index = i;
if (edd_has_mbr_signature(edev))
edev->mbr_signature = edd.mbr_signature[i];
if (edd_has_edd_info(edev))
edev->info = &edd.edd_info[i];
}
#define to_edd_attr(_attr) container_of(_attr,struct edd_attribute,attr)
#define to_edd_device(obj) container_of(obj,struct edd_device,kobj)
static ssize_t
edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
{
struct edd_device *dev = to_edd_device(kobj);
struct edd_attribute *edd_attr = to_edd_attr(attr);
ssize_t ret = -EIO;
if (edd_attr->show)
ret = edd_attr->show(dev, buf);
return ret;
}
static const struct sysfs_ops edd_attr_ops = {
.show = edd_attr_show,
};
static ssize_t
edd_show_host_bus(struct edd_device *edev, char *buf)
{
struct edd_info *info;
char *p = buf;
int i;
if (!edev)
return -EINVAL;
info = edd_dev_get_info(edev);
if (!info || !buf)
return -EINVAL;
for (i = 0; i < 4; i++) {
if (isprint(info->params.host_bus_type[i])) {
p += scnprintf(p, left, "%c", info->params.host_bus_type[i]);
} else {
Annotation
- Immediate include surface: `linux/module.h`, `linux/string.h`, `linux/types.h`, `linux/init.h`, `linux/stat.h`, `linux/err.h`, `linux/ctype.h`, `linux/slab.h`.
- Detected declarations: `struct edd_device`, `struct edd_attribute`, `function edd_has_mbr_signature`, `function edd_has_edd_info`, `function edd_dev_get_info`, `function edd_dev_set_info`, `function edd_attr_show`, `function edd_show_host_bus`, `function edd_show_interface`, `function edd_show_raw_data`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.