xref: /openbmc/linux/drivers/tty/n_null.c (revision 49b8220c)
1e3b3d0f5SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
28a8dabf2SAlan Cox #include <linux/types.h>
38a8dabf2SAlan Cox #include <linux/errno.h>
48a8dabf2SAlan Cox #include <linux/tty.h>
58a8dabf2SAlan Cox #include <linux/module.h>
68a8dabf2SAlan Cox 
78a8dabf2SAlan Cox /*
88a8dabf2SAlan Cox  *  n_null.c - Null line discipline used in the failure path
98a8dabf2SAlan Cox  *
108a8dabf2SAlan Cox  *  Copyright (C) Intel 2017
118a8dabf2SAlan Cox  */
128a8dabf2SAlan Cox 
n_null_read(struct tty_struct * tty,struct file * file,u8 * buf,size_t nr,void ** cookie,unsigned long offset)13*49b8220cSJiri Slaby (SUSE) static ssize_t n_null_read(struct tty_struct *tty, struct file *file, u8 *buf,
14*49b8220cSJiri Slaby (SUSE) 			   size_t nr, void **cookie, unsigned long offset)
158a8dabf2SAlan Cox {
168a8dabf2SAlan Cox 	return -EOPNOTSUPP;
178a8dabf2SAlan Cox }
188a8dabf2SAlan Cox 
n_null_write(struct tty_struct * tty,struct file * file,const u8 * buf,size_t nr)198a8dabf2SAlan Cox static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
20*49b8220cSJiri Slaby (SUSE) 			    const u8 *buf, size_t nr)
218a8dabf2SAlan Cox {
228a8dabf2SAlan Cox 	return -EOPNOTSUPP;
238a8dabf2SAlan Cox }
248a8dabf2SAlan Cox 
258a8dabf2SAlan Cox static struct tty_ldisc_ops null_ldisc = {
268a8dabf2SAlan Cox 	.owner		=	THIS_MODULE,
27fbadf70aSJiri Slaby 	.num		=	N_NULL,
288a8dabf2SAlan Cox 	.name		=	"n_null",
298a8dabf2SAlan Cox 	.read		=	n_null_read,
308a8dabf2SAlan Cox 	.write		=	n_null_write,
318a8dabf2SAlan Cox };
328a8dabf2SAlan Cox 
n_null_init(void)338a8dabf2SAlan Cox static int __init n_null_init(void)
348a8dabf2SAlan Cox {
35fbadf70aSJiri Slaby 	BUG_ON(tty_register_ldisc(&null_ldisc));
368a8dabf2SAlan Cox 	return 0;
378a8dabf2SAlan Cox }
388a8dabf2SAlan Cox 
n_null_exit(void)398a8dabf2SAlan Cox static void __exit n_null_exit(void)
408a8dabf2SAlan Cox {
41f81ee8b8SJiri Slaby 	tty_unregister_ldisc(&null_ldisc);
428a8dabf2SAlan Cox }
438a8dabf2SAlan Cox 
448a8dabf2SAlan Cox module_init(n_null_init);
458a8dabf2SAlan Cox module_exit(n_null_exit);
468a8dabf2SAlan Cox 
478a8dabf2SAlan Cox MODULE_LICENSE("GPL");
488a8dabf2SAlan Cox MODULE_AUTHOR("Alan Cox");
498a8dabf2SAlan Cox MODULE_ALIAS_LDISC(N_NULL);
508a8dabf2SAlan Cox MODULE_DESCRIPTION("Null ldisc driver");
51