drivers/platform/x86/ibm_rtl.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/ibm_rtl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/ibm_rtl.c- Extension
.c- Size
- 7877 bytes
- Lines
- 326
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/delay.hlinux/module.hlinux/io.hlinux/dmi.hlinux/efi.hlinux/mutex.hasm/bios_ebda.hlinux/io-64-nonatomic-lo-hi.h
Detected Declarations
struct ibm_rtl_tablefunction rtl_port_unmapfunction ibm_rtl_writefunction rtl_show_versionfunction rtl_show_statefunction rtl_set_statefunction rtl_setup_sysfsfunction rtl_teardown_sysfsfunction ibm_rtl_initfunction ibm_rtl_exitmodule init ibm_rtl_init
Annotated Snippet
static const struct bus_type rtl_subsys = {
.name = "ibm_rtl",
.dev_name = "ibm_rtl",
};
static DEVICE_ATTR(version, S_IRUGO, rtl_show_version, NULL);
static DEVICE_ATTR(state, 0600, rtl_show_state, rtl_set_state);
static struct device_attribute *rtl_attributes[] = {
&dev_attr_version,
&dev_attr_state,
NULL
};
static int rtl_setup_sysfs(void) {
int ret, i;
ret = subsys_system_register(&rtl_subsys, NULL);
if (!ret) {
struct device *dev_root = bus_get_dev_root(&rtl_subsys);
if (dev_root) {
for (i = 0; rtl_attributes[i]; i ++)
device_create_file(dev_root, rtl_attributes[i]);
put_device(dev_root);
}
}
return ret;
}
static void rtl_teardown_sysfs(void) {
struct device *dev_root = bus_get_dev_root(&rtl_subsys);
int i;
if (dev_root) {
for (i = 0; rtl_attributes[i]; i ++)
device_remove_file(dev_root, rtl_attributes[i]);
put_device(dev_root);
}
bus_unregister(&rtl_subsys);
}
static const struct dmi_system_id ibm_rtl_dmi_table[] __initconst = {
{ \
.matches = { \
DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
}, \
},
{ }
};
static int __init ibm_rtl_init(void) {
unsigned long ebda_addr, ebda_size;
unsigned int ebda_kb;
int ret = -ENODEV, i;
if (force)
pr_warn("module loaded by force\n");
/* first ensure that we are running on IBM HW */
else if (efi_enabled(EFI_BOOT) || !dmi_check_system(ibm_rtl_dmi_table))
return -ENODEV;
/* Get the address for the Extended BIOS Data Area */
ebda_addr = get_bios_ebda();
if (!ebda_addr) {
RTL_DEBUG("no BIOS EBDA found\n");
return -ENODEV;
}
ebda_map = ioremap(ebda_addr, 4);
if (!ebda_map)
return -ENOMEM;
/* First word in the EDBA is the Size in KB */
ebda_kb = ioread16(ebda_map);
RTL_DEBUG("EBDA is %d kB\n", ebda_kb);
if (ebda_kb == 0)
goto out;
iounmap(ebda_map);
ebda_size = ebda_kb*1024;
/* Remap the whole table */
ebda_map = ioremap(ebda_addr, ebda_size);
if (!ebda_map)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/delay.h`, `linux/module.h`, `linux/io.h`, `linux/dmi.h`, `linux/efi.h`, `linux/mutex.h`, `asm/bios_ebda.h`.
- Detected declarations: `struct ibm_rtl_table`, `function rtl_port_unmap`, `function ibm_rtl_write`, `function rtl_show_version`, `function rtl_show_state`, `function rtl_set_state`, `function rtl_setup_sysfs`, `function rtl_teardown_sysfs`, `function ibm_rtl_init`, `function ibm_rtl_exit`.
- Atlas domain: Driver Families / drivers/platform.
- 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.