Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/types.h>
 3#include <linux/errno.h>
 4#include <linux/tty.h>
 5#include <linux/module.h>
 6
 7/*
 8 *  n_null.c - Null line discipline used in the failure path
 9 *
10 *  Copyright (C) Intel 2017
11 */
12
13static ssize_t n_null_read(struct tty_struct *tty, struct file *file, u8 *buf,
14			   size_t nr, void **cookie, unsigned long offset)
 
 
 
 
 
 
 
 
 
 
15{
16	return -EOPNOTSUPP;
17}
18
19static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
20			    const u8 *buf, size_t nr)
21{
22	return -EOPNOTSUPP;
23}
24
 
 
 
 
 
 
25static struct tty_ldisc_ops null_ldisc = {
26	.owner		=	THIS_MODULE,
27	.num		=	N_NULL,
28	.name		=	"n_null",
 
 
29	.read		=	n_null_read,
30	.write		=	n_null_write,
 
31};
32
33static int __init n_null_init(void)
34{
35	BUG_ON(tty_register_ldisc(&null_ldisc));
36	return 0;
37}
38
39static void __exit n_null_exit(void)
40{
41	tty_unregister_ldisc(&null_ldisc);
42}
43
44module_init(n_null_init);
45module_exit(n_null_exit);
46
47MODULE_LICENSE("GPL");
48MODULE_AUTHOR("Alan Cox");
49MODULE_ALIAS_LDISC(N_NULL);
50MODULE_DESCRIPTION("Null ldisc driver");
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/types.h>
 3#include <linux/errno.h>
 4#include <linux/tty.h>
 5#include <linux/module.h>
 6
 7/*
 8 *  n_null.c - Null line discipline used in the failure path
 9 *
10 *  Copyright (C) Intel 2017
11 */
12
13static int n_null_open(struct tty_struct *tty)
14{
15	return 0;
16}
17
18static void n_null_close(struct tty_struct *tty)
19{
20}
21
22static 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)
25{
26	return -EOPNOTSUPP;
27}
28
29static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
30			    const unsigned char *buf, size_t nr)
31{
32	return -EOPNOTSUPP;
33}
34
35static void n_null_receivebuf(struct tty_struct *tty,
36				 const unsigned char *cp, const char *fp,
37				 int cnt)
38{
39}
40
41static struct tty_ldisc_ops null_ldisc = {
42	.owner		=	THIS_MODULE,
43	.num		=	N_NULL,
44	.name		=	"n_null",
45	.open		=	n_null_open,
46	.close		=	n_null_close,
47	.read		=	n_null_read,
48	.write		=	n_null_write,
49	.receive_buf	=	n_null_receivebuf
50};
51
52static int __init n_null_init(void)
53{
54	BUG_ON(tty_register_ldisc(&null_ldisc));
55	return 0;
56}
57
58static void __exit n_null_exit(void)
59{
60	tty_unregister_ldisc(&null_ldisc);
61}
62
63module_init(n_null_init);
64module_exit(n_null_exit);
65
66MODULE_LICENSE("GPL");
67MODULE_AUTHOR("Alan Cox");
68MODULE_ALIAS_LDISC(N_NULL);
69MODULE_DESCRIPTION("Null ldisc driver");