drivers/pnp/pnpbios/proc.c
Source file repositories/reference/linux-study-clean/drivers/pnp/pnpbios/proc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pnp/pnpbios/proc.c- Extension
.c- Size
- 6832 bytes
- Lines
- 287
- Domain
- Driver Families
- Bucket
- drivers/pnp
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/kernel.hlinux/slab.hlinux/types.hlinux/proc_fs.hlinux/pnp.hlinux/seq_file.hlinux/init.hlinux/uaccess.hpnpbios.h
Detected Declarations
function pnpconfig_proc_showfunction escd_info_proc_showfunction escd_proc_showfunction pnp_legacyres_proc_showfunction pnp_devices_proc_showfunction pnpbios_proc_showfunction pnpbios_proc_openfunction pnpbios_proc_writefunction pnpbios_interface_attach_devicefunction pnpbios_proc_initfunction pnpbios_proc_exit
Annotated Snippet
if (nodenum <= thisnodenum) {
printk(KERN_ERR
"%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
"PnPBIOS: proc_read_devices:",
(unsigned int)nodenum,
(unsigned int)thisnodenum);
break;
}
}
kfree(node);
return 0;
}
static int pnpbios_proc_show(struct seq_file *m, void *v)
{
void *data = m->private;
struct pnp_bios_node *node;
int boot = (long)data >> 8;
u8 nodenum = (long)data;
int len;
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
kfree(node);
return -EIO;
}
len = node->size - sizeof(struct pnp_bios_node);
seq_write(m, node->data, len);
kfree(node);
return 0;
}
static int pnpbios_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, pnpbios_proc_show, pde_data(inode));
}
static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{
void *data = pde_data(file_inode(file));
struct pnp_bios_node *node;
int boot = (long)data >> 8;
u8 nodenum = (long)data;
int ret = count;
node = kzalloc(node_info.max_node_size, GFP_KERNEL);
if (!node)
return -ENOMEM;
if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
ret = -EIO;
goto out;
}
if (count != node->size - sizeof(struct pnp_bios_node)) {
ret = -EINVAL;
goto out;
}
if (copy_from_user(node->data, buf, count)) {
ret = -EFAULT;
goto out;
}
if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) {
ret = -EINVAL;
goto out;
}
ret = count;
out:
kfree(node);
return ret;
}
static const struct proc_ops pnpbios_proc_ops = {
.proc_open = pnpbios_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
.proc_write = pnpbios_proc_write,
};
int pnpbios_interface_attach_device(struct pnp_bios_node *node)
{
char name[3];
sprintf(name, "%02x", node->handle);
if (!proc_pnp)
return -EIO;
if (!pnpbios_dont_use_current_config) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/types.h`, `linux/proc_fs.h`, `linux/pnp.h`, `linux/seq_file.h`, `linux/init.h`.
- Detected declarations: `function pnpconfig_proc_show`, `function escd_info_proc_show`, `function escd_proc_show`, `function pnp_legacyres_proc_show`, `function pnp_devices_proc_show`, `function pnpbios_proc_show`, `function pnpbios_proc_open`, `function pnpbios_proc_write`, `function pnpbios_interface_attach_device`, `function pnpbios_proc_init`.
- Atlas domain: Driver Families / drivers/pnp.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.