1 #include <linux/types.h>
2 #include <linux/errno.h>
4 #include <linux/module.h>
7 * n_null.c - Null line discipline used in the failure path
9 * Copyright (C) Intel 2017
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 static int n_null_open(struct tty_struct *tty)
30 static void n_null_close(struct tty_struct *tty)
34 static ssize_t n_null_read(struct tty_struct *tty, struct file *file,
35 unsigned char __user * buf, size_t nr)
40 static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
41 const unsigned char *buf, size_t nr)
46 static void n_null_receivebuf(struct tty_struct *tty,
47 const unsigned char *cp, char *fp,
52 static struct tty_ldisc_ops null_ldisc = {
54 .magic = TTY_LDISC_MAGIC,
57 .close = n_null_close,
59 .write = n_null_write,
60 .receive_buf = n_null_receivebuf
63 static int __init n_null_init(void)
65 BUG_ON(tty_register_ldisc(N_NULL, &null_ldisc));
69 static void __exit n_null_exit(void)
71 tty_unregister_ldisc(N_NULL);
74 module_init(n_null_init);
75 module_exit(n_null_exit);
77 MODULE_LICENSE("GPL");
78 MODULE_AUTHOR("Alan Cox");
79 MODULE_ALIAS_LDISC(N_NULL);
80 MODULE_DESCRIPTION("Null ldisc driver");