1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/types.h>
3 #include <linux/errno.h>
5 #include <linux/module.h>
8 * n_null.c - Null line discipline used in the failure path
10 * Copyright (C) Intel 2017
13 static int n_null_open(struct tty_struct *tty)
18 static void n_null_close(struct tty_struct *tty)
22 static ssize_t n_null_read(struct tty_struct *tty, struct file *file,
23 unsigned char *buf, size_t nr,
24 void **cookie, unsigned long offset)
29 static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
30 const unsigned char *buf, size_t nr)
35 static void n_null_receivebuf(struct tty_struct *tty,
36 const unsigned char *cp, const char *fp,
41 static struct tty_ldisc_ops null_ldisc = {
46 .close = n_null_close,
48 .write = n_null_write,
49 .receive_buf = n_null_receivebuf
52 static int __init n_null_init(void)
54 BUG_ON(tty_register_ldisc(&null_ldisc));
58 static void __exit n_null_exit(void)
60 tty_unregister_ldisc(&null_ldisc);
63 module_init(n_null_init);
64 module_exit(n_null_exit);
66 MODULE_LICENSE("GPL");
67 MODULE_AUTHOR("Alan Cox");
68 MODULE_ALIAS_LDISC(N_NULL);
69 MODULE_DESCRIPTION("Null ldisc driver");