arch/sh/boards/mach-landisk/gio.c
Source file repositories/reference/linux-study-clean/arch/sh/boards/mach-landisk/gio.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/boards/mach-landisk/gio.c- Extension
.c- Size
- 3251 bytes
- Lines
- 165
- Domain
- Architecture Layer
- Bucket
- arch/sh
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/kdev_t.hlinux/cdev.hlinux/fs.hasm/io.hlinux/uaccess.hmach-landisk/mach/gio.hmach-landisk/mach/iodata_landisk.h
Detected Declarations
function gio_openfunction gio_closefunction gio_ioctlfunction gio_initfunction gio_exitmodule init gio_init
Annotated Snippet
static const struct file_operations gio_fops = {
.owner = THIS_MODULE,
.open = gio_open, /* open */
.release = gio_close, /* release */
.unlocked_ioctl = gio_ioctl,
.llseek = noop_llseek,
};
static int __init gio_init(void)
{
int error;
printk(KERN_INFO "gio: driver initialized\n");
openCnt = 0;
if ((error = alloc_chrdev_region(&dev, 0, DEVCOUNT, "gio")) < 0) {
printk(KERN_ERR
"gio: Couldn't alloc_chrdev_region, error=%d\n",
error);
return 1;
}
cdev_p = cdev_alloc();
cdev_p->ops = &gio_fops;
error = cdev_add(cdev_p, dev, DEVCOUNT);
if (error) {
printk(KERN_ERR
"gio: Couldn't cdev_add, error=%d\n", error);
return 1;
}
return 0;
}
static void __exit gio_exit(void)
{
cdev_del(cdev_p);
unregister_chrdev_region(dev, DEVCOUNT);
}
module_init(gio_init);
module_exit(gio_exit);
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/kdev_t.h`, `linux/cdev.h`, `linux/fs.h`, `asm/io.h`, `linux/uaccess.h`, `mach-landisk/mach/gio.h`.
- Detected declarations: `function gio_open`, `function gio_close`, `function gio_ioctl`, `function gio_init`, `function gio_exit`, `module init gio_init`.
- Atlas domain: Architecture Layer / arch/sh.
- Implementation status: pattern 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.