drivers/char/ipmi/ipmi_devintf.c
Source file repositories/reference/linux-study-clean/drivers/char/ipmi/ipmi_devintf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/ipmi/ipmi_devintf.c- Extension
.c- Size
- 19588 bytes
- Lines
- 908
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/moduleparam.hlinux/errno.hlinux/poll.hlinux/sched.hlinux/spinlock.hlinux/slab.hlinux/ipmi.hlinux/mutex.hlinux/init.hlinux/device.hlinux/compat.h
Detected Declarations
struct ipmi_file_privatestruct compat_ipmi_msgstruct compat_ipmi_reqstruct compat_ipmi_recvstruct compat_ipmi_req_settimestruct ipmi_reg_listfunction file_receive_handlerfunction ipmi_pollfunction ipmi_fasyncfunction ipmi_openfunction ipmi_releasefunction handle_send_reqfunction handle_recvfunction copyout_recvfunction ipmi_ioctlfunction get_compat_ipmi_msgfunction get_compat_ipmi_reqfunction get_compat_ipmi_req_settimefunction get_compat_ipmi_recvfunction copyout_recv32function compat_ipmi_ioctlfunction ipmi_new_smifunction ipmi_smi_gonefunction init_ipmi_devintffunction cleanup_ipmimodule init init_ipmi_devintf
Annotated Snippet
static const struct file_operations ipmi_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = ipmi_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ipmi_ioctl,
#endif
.open = ipmi_open,
.release = ipmi_release,
.fasync = ipmi_fasync,
.poll = ipmi_poll,
.llseek = noop_llseek,
};
#define DEVICE_NAME "ipmidev"
static int ipmi_major;
module_param(ipmi_major, int, 0);
MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device. By"
" default, or if you set it to zero, it will choose the next"
" available device. Setting it to -1 will disable the"
" interface. Other values will set the major device number"
" to that value.");
/* Keep track of the devices that are registered. */
struct ipmi_reg_list {
dev_t dev;
struct list_head link;
};
static LIST_HEAD(reg_list);
static DEFINE_MUTEX(reg_list_mutex);
static const struct class ipmi_class = {
.name = "ipmi",
};
static void ipmi_new_smi(int if_num, struct device *device)
{
dev_t dev = MKDEV(ipmi_major, if_num);
struct ipmi_reg_list *entry;
entry = kmalloc_obj(*entry);
if (!entry) {
pr_err("ipmi_devintf: Unable to create the ipmi class device link\n");
return;
}
entry->dev = dev;
mutex_lock(®_list_mutex);
device_create(&ipmi_class, device, dev, NULL, "ipmi%d", if_num);
list_add(&entry->link, ®_list);
mutex_unlock(®_list_mutex);
}
static void ipmi_smi_gone(int if_num)
{
dev_t dev = MKDEV(ipmi_major, if_num);
struct ipmi_reg_list *entry;
mutex_lock(®_list_mutex);
list_for_each_entry(entry, ®_list, link) {
if (entry->dev == dev) {
list_del(&entry->link);
kfree(entry);
break;
}
}
device_destroy(&ipmi_class, dev);
mutex_unlock(®_list_mutex);
}
static struct ipmi_smi_watcher smi_watcher =
{
.owner = THIS_MODULE,
.new_smi = ipmi_new_smi,
.smi_gone = ipmi_smi_gone,
};
static int __init init_ipmi_devintf(void)
{
int rv;
if (ipmi_major < 0)
return -EINVAL;
pr_info("ipmi device interface\n");
rv = class_register(&ipmi_class);
if (rv)
return rv;
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/errno.h`, `linux/poll.h`, `linux/sched.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/ipmi.h`.
- Detected declarations: `struct ipmi_file_private`, `struct compat_ipmi_msg`, `struct compat_ipmi_req`, `struct compat_ipmi_recv`, `struct compat_ipmi_req_settime`, `struct ipmi_reg_list`, `function file_receive_handler`, `function ipmi_poll`, `function ipmi_fasync`, `function ipmi_open`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.