linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tal Shorer <tal.shorer@gmail.com>
To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
	balbi@kernel.org, corbet@lwn.net
Cc: Tal Shorer <tal.shorer@gmail.com>
Subject: [PATCH v2 2/8] usb: gadget: u_serial: propagate poll() to the next layer
Date: Tue, 13 Jun 2017 09:52:08 +0300	[thread overview]
Message-ID: <1497336734-19368-3-git-send-email-tal.shorer@gmail.com> (raw)
In-Reply-To: <1497336734-19368-1-git-send-email-tal.shorer@gmail.com>

In order for a serial function to add flags to the poll() mask of their
tty files, propagate the poll() callback to the next layer so it can
return a mask if it sees fit to do so.

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 drivers/usb/gadget/function/u_serial.c | 16 ++++++++++++++++
 drivers/usb/gadget/function/u_serial.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 9b0805f..d466f58 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1025,6 +1025,21 @@ static int gs_break_ctl(struct tty_struct *tty, int duration)
 	return status;
 }
 
+static unsigned int gs_poll(struct tty_struct *tty, struct file *file,
+	poll_table *wait)
+{
+	struct gs_port *port = tty->driver_data;
+	struct gserial *gser;
+	unsigned int mask = 0;
+
+	spin_lock_irq(&port->port_lock);
+	gser = port->port_usb;
+	if (gser && gser->poll)
+		mask |= gser->poll(gser, file, wait);
+	spin_unlock_irq(&port->port_lock);
+	return mask;
+}
+
 static const struct tty_operations gs_tty_ops = {
 	.open =			gs_open,
 	.close =		gs_close,
@@ -1035,6 +1050,7 @@ static const struct tty_operations gs_tty_ops = {
 	.chars_in_buffer =	gs_chars_in_buffer,
 	.unthrottle =		gs_unthrottle,
 	.break_ctl =		gs_break_ctl,
+	.poll =			gs_poll,
 };
 
 /*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h
index c20210c..ce00840 100644
--- a/drivers/usb/gadget/function/u_serial.h
+++ b/drivers/usb/gadget/function/u_serial.h
@@ -12,6 +12,7 @@
 #ifndef __U_SERIAL_H
 #define __U_SERIAL_H
 
+#include <linux/poll.h>
 #include <linux/usb/composite.h>
 #include <linux/usb/cdc.h>
 
@@ -50,6 +51,8 @@ struct gserial {
 	void (*connect)(struct gserial *p);
 	void (*disconnect)(struct gserial *p);
 	int (*send_break)(struct gserial *p, int duration);
+	unsigned int (*poll)(struct gserial *p, struct file *file,
+				poll_table *wait);
 };
 
 /* utilities to allocate/free request and buffer */
-- 
2.7.4

  parent reply	other threads:[~2017-06-13  6:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13  6:52 [PATCH v2 0/8] Allow f_acm gadgets to notify the user about SetLineCoding requests Tal Shorer
2017-06-13  6:52 ` [PATCH v2 1/8] tty: add a poll() callback in struct tty_operations Tal Shorer
2017-06-14  1:15   ` Alan Cox
2017-06-14  8:20     ` Tal Shorer
2017-06-14  8:27       ` Tal Shorer
2017-06-14 13:33       ` Alan Cox
2017-06-15 14:44         ` Tal Shorer
2017-06-13  6:52 ` Tal Shorer [this message]
2017-06-13  6:52 ` [PATCH v2 3/8] usb: gadget: f_acm: validate set_line_coding requests Tal Shorer
2017-06-13  6:52 ` [PATCH v2 4/8] usb: gadget: u_serial: propagate ioctl() to the next layer Tal Shorer
2017-06-13  6:52 ` [PATCH v2 5/8] usb: gadget: f_acm: initialize port_line_coding when creating an instance Tal Shorer
2017-06-13  6:52 ` [PATCH v2 6/8] usb: gadget: f_acm: add an ioctl to get the current line coding Tal Shorer
2017-06-13  9:19   ` Greg KH
2017-06-13  9:24     ` Tal Shorer
2017-06-13  6:52 ` [PATCH v2 7/8] usb: gadget: f_acm: notify the user on SetLineCoding Tal Shorer
2017-06-13  6:52 ` [PATCH v2 8/8] usb: gadget: u_serial: remove port_line_config from struct gserial Tal Shorer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497336734-19368-3-git-send-email-tal.shorer@gmail.com \
    --to=tal.shorer@gmail.com \
    --cc=balbi@kernel.org \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).