drivers/macintosh/ans-lcd.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/ans-lcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/ans-lcd.c- Extension
.c- Size
- 4108 bytes
- Lines
- 206
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/errno.hlinux/kernel.hlinux/miscdevice.hlinux/fcntl.hlinux/module.hlinux/delay.hlinux/fs.hlinux/of.hlinux/uaccess.hasm/sections.hasm/io.hans-lcd.h
Detected Declarations
function anslcd_write_byte_ctrlfunction anslcd_write_byte_datafunction anslcd_writefunction anslcd_ioctlfunction anslcd_openfunction anslcd_initfunction anslcd_exitmodule init anslcd_init
Annotated Snippet
const struct file_operations anslcd_fops = {
.write = anslcd_write,
.unlocked_ioctl = anslcd_ioctl,
.open = anslcd_open,
.llseek = default_llseek,
};
static struct miscdevice anslcd_dev = {
LCD_MINOR,
"anslcd",
&anslcd_fops
};
static const char anslcd_logo[] __initconst =
"********************" /* Line #1 */
"* LINUX! *" /* Line #3 */
"* Welcome to *" /* Line #2 */
"********************"; /* Line #4 */
static int __init
anslcd_init(void)
{
int a;
int retval;
struct device_node* node;
node = of_find_node_by_name(NULL, "lcd");
if (!node || !of_node_name_eq(node->parent, "gc")) {
of_node_put(node);
return -ENODEV;
}
of_node_put(node);
anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
retval = misc_register(&anslcd_dev);
if(retval < 0){
printk(KERN_INFO "LCD: misc_register failed\n");
iounmap(anslcd_ptr);
return retval;
}
#ifdef DEBUG
printk(KERN_DEBUG "LCD: init\n");
#endif
mutex_lock(&anslcd_mutex);
anslcd_write_byte_ctrl ( 0x38 );
anslcd_write_byte_ctrl ( 0x0c );
anslcd_write_byte_ctrl ( 0x06 );
anslcd_write_byte_ctrl ( 0x01 );
anslcd_write_byte_ctrl ( 0x02 );
for(a=0;a<80;a++) {
anslcd_write_byte_data(anslcd_logo[a]);
}
mutex_unlock(&anslcd_mutex);
return 0;
}
static void __exit
anslcd_exit(void)
{
misc_deregister(&anslcd_dev);
iounmap(anslcd_ptr);
}
module_init(anslcd_init);
module_exit(anslcd_exit);
MODULE_LICENSE("GPL v2");
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/miscdevice.h`, `linux/fcntl.h`, `linux/module.h`, `linux/delay.h`, `linux/fs.h`.
- Detected declarations: `function anslcd_write_byte_ctrl`, `function anslcd_write_byte_data`, `function anslcd_write`, `function anslcd_ioctl`, `function anslcd_open`, `function anslcd_init`, `function anslcd_exit`, `module init anslcd_init`.
- Atlas domain: Driver Families / drivers/macintosh.
- 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.