Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1664512

[PATCH v2 1/8] tty: add a poll() callback in struct tty_operations

From Tal Shorer <tal.shorer@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations
Date 2017-06-13 09:00 +0200
Message-ID <tRNXY-4BW-23@gated-at.bofh.it> (permalink)
References <tRNXX-4BW-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If a tty driver wants to notify the user of some exceptional event,
such as a usb cdc acm device set_line_coding event, it needs a way to
modify the mask returned by poll() and possible also add wait queues.
In order to do that, we allow the driver to supply a poll() callback
of its own, which will be called in n_tty_poll().

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 drivers/tty/n_tty.c        | 2 ++
 include/linux/tty_driver.h | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index bdf0e6e..7af8c29 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2394,6 +2394,8 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
 			tty_chars_in_buffer(tty) < WAKEUP_CHARS &&
 			tty_write_room(tty) > 0)
 		mask |= POLLOUT | POLLWRNORM;
+	if (tty->ops->poll)
+		mask |= tty->ops->poll(tty, file, wait);
 	return mask;
 }
 
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index b742b5e..630ef03 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -243,6 +243,7 @@
 #include <linux/list.h>
 #include <linux/cdev.h>
 #include <linux/termios.h>
+#include <linux/poll.h>
 
 struct tty_struct;
 struct tty_driver;
@@ -285,6 +286,8 @@ struct tty_operations {
 	int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
 	int (*get_icount)(struct tty_struct *tty,
 				struct serial_icounter_struct *icount);
+	unsigned int (*poll)(struct tty_struct *tty, struct file *file,
+				poll_table *wait);
 #ifdef CONFIG_CONSOLE_POLL
 	int (*poll_init)(struct tty_driver *driver, int line, char *options);
 	int (*poll_get_char)(struct tty_driver *driver, int line);
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer <tal.shorer@gmail.com> - 2017-06-13 09:00 +0200
  Re: [PATCH v2 1/8] tty: add a poll() callback in struct  tty_operations Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-06-14 03:20 +0200
    Re: [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer <tal.shorer@gmail.com> - 2017-06-14 10:30 +0200
      Re: [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer <tal.shorer@gmail.com> - 2017-06-14 10:30 +0200
      Re: [PATCH v2 1/8] tty: add a poll() callback in struct  tty_operations Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-06-14 15:40 +0200
        Re: [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer <tal.shorer@gmail.com> - 2017-06-15 16:50 +0200

csiph-web