drivers/nubus/proc.c
Source file repositories/reference/linux-study-clean/drivers/nubus/proc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nubus/proc.c- Extension
.c- Size
- 5172 bytes
- Lines
- 202
- Domain
- Driver Families
- Bucket
- drivers/nubus
- 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/types.hlinux/kernel.hlinux/nubus.hlinux/proc_fs.hlinux/seq_file.hlinux/slab.hlinux/init.hlinux/module.hlinux/uaccess.hasm/byteorder.h
Detected Declarations
struct nubus_proc_pde_datafunction Copyrightfunction nubus_proc_alloc_pde_datafunction nubus_proc_rsrc_showfunction nubus_rsrc_proc_openfunction nubus_proc_add_rsrc_memfunction nubus_proc_add_rsrcfunction nubus_proc_init
Annotated Snippet
struct nubus_proc_pde_data {
unsigned char *res_ptr;
unsigned int res_size;
};
static struct nubus_proc_pde_data *
nubus_proc_alloc_pde_data(unsigned char *ptr, unsigned int size)
{
struct nubus_proc_pde_data *pded;
pded = kmalloc_obj(*pded);
if (!pded)
return NULL;
pded->res_ptr = ptr;
pded->res_size = size;
return pded;
}
static int nubus_proc_rsrc_show(struct seq_file *m, void *v)
{
struct inode *inode = m->private;
struct nubus_proc_pde_data *pded;
pded = pde_data(inode);
if (!pded)
return 0;
if (pded->res_size > m->size)
return -EFBIG;
if (pded->res_size) {
int lanes = (int)proc_get_parent_data(inode);
struct nubus_dirent ent;
if (!lanes)
return 0;
ent.mask = lanes;
ent.base = pded->res_ptr;
ent.data = 0;
nubus_seq_write_rsrc_mem(m, &ent, pded->res_size);
} else {
unsigned int data = (unsigned int)pded->res_ptr;
seq_putc(m, data >> 16);
seq_putc(m, data >> 8);
seq_putc(m, data >> 0);
}
return 0;
}
static int nubus_rsrc_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, nubus_proc_rsrc_show, inode);
}
static const struct proc_ops nubus_rsrc_proc_ops = {
.proc_open = nubus_rsrc_proc_open,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_release = single_release,
};
void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
const struct nubus_dirent *ent,
unsigned int size)
{
char name[9];
struct nubus_proc_pde_data *pded;
if (!procdir || !nubus_populate_procfs)
return;
snprintf(name, sizeof(name), "%x", ent->type);
if (size)
pded = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size);
else
pded = NULL;
remove_proc_subtree(name, procdir);
proc_create_data(name, S_IFREG | 0444, procdir,
&nubus_rsrc_proc_ops, pded);
}
void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
const struct nubus_dirent *ent)
{
char name[9];
unsigned char *data = (unsigned char *)ent->data;
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/nubus.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/init.h`, `linux/module.h`.
- Detected declarations: `struct nubus_proc_pde_data`, `function Copyright`, `function nubus_proc_alloc_pde_data`, `function nubus_proc_rsrc_show`, `function nubus_rsrc_proc_open`, `function nubus_proc_add_rsrc_mem`, `function nubus_proc_add_rsrc`, `function nubus_proc_init`.
- Atlas domain: Driver Families / drivers/nubus.
- 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.