Listing 2. Minimal tty Driver #define TINY_TTY_MAJOR 240 /* experimental range */ #define TINY_TTY_MINORS 255 /* use the whole major up */ static int tty_refcount; static struct tty_struct *tiny_tty[TINY_TTY_MINORS]; static struct termios *tiny_termios[TINY_TTY_MINORS]; static struct termios *tiny_termios_locked[TINY_TTY_MINORS]; static struct tty_driver tiny_tty_driver { magic: TTY_DRIVER_MAGIC, driver_name: "tiny_tty", #ifdef CONFIG_DEVFS_FS name: "tts/ttty%d", #else name: "ttty", #endif major: TINY_TTY_MAJOR, num: TINY_TTY_MINORS, type: TTY_DRIVER_TYPE_SERIAL, subtype: SERIAL_TYPE_NORMAL, flags: TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS, refcount: &tiny_refcount, table: tiny_tty, termios: tiny_termios, termios_locked: tiny_termios_locked, open: tiny_open, close: tiny_close, write: tiny_write, write_room: tiny_write_room, }; static int __init tiny_init (void) { /* register the tty driver */ tiny_tty_driver.init_termios = tty_std_termios; tiny_tty_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; if (tty_register_driver (&tiny_tty_driver)) { printk (KERN_ERR "failed to register tiny tty driver"); return -1; return 0; } static void __exit tiny_exit (void) { tty_unregister_driver (&tiny_tty_driver); } module_init (tiny_init); module_exit (tiny_exit);