Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752784AbdFMGwm (ORCPT ); Tue, 13 Jun 2017 02:52:42 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36146 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752304AbdFMGwk (ORCPT ); Tue, 13 Jun 2017 02:52:40 -0400 From: Tal Shorer 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 Subject: [PATCH v2 2/8] usb: gadget: u_serial: propagate poll() to the next layer Date: Tue, 13 Jun 2017 09:52:08 +0300 Message-Id: <1497336734-19368-3-git-send-email-tal.shorer@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497336734-19368-1-git-send-email-tal.shorer@gmail.com> References: <1497336734-19368-1-git-send-email-tal.shorer@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2137 Lines: 67 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 --- 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 #include #include @@ -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