Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753021AbdFMGw7 (ORCPT ); Tue, 13 Jun 2017 02:52:59 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35223 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905AbdFMGwz (ORCPT ); Tue, 13 Jun 2017 02:52:55 -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 4/8] usb: gadget: u_serial: propagate ioctl() to the next layer Date: Tue, 13 Jun 2017 09:52:10 +0300 Message-Id: <1497336734-19368-5-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: 1931 Lines: 57 In order for a serial function to implement its own ioctl() calls, propagate the ioctl() callback to the next layer so it can handle it if it sees fit to do so. Signed-off-by: Tal Shorer --- drivers/usb/gadget/function/u_serial.c | 15 +++++++++++++++ drivers/usb/gadget/function/u_serial.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index d466f58..8d9abf1 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -1040,6 +1040,20 @@ static unsigned int gs_poll(struct tty_struct *tty, struct file *file, return mask; } +static int gs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) +{ + struct gs_port *port = tty->driver_data; + struct gserial *gser; + int ret = -ENOIOCTLCMD; + + spin_lock_irq(&port->port_lock); + gser = port->port_usb; + if (gser && gser->ioctl) + ret = gser->ioctl(gser, cmd, arg); + spin_unlock_irq(&port->port_lock); + return ret; +} + static const struct tty_operations gs_tty_ops = { .open = gs_open, .close = gs_close, @@ -1051,6 +1065,7 @@ static const struct tty_operations gs_tty_ops = { .unthrottle = gs_unthrottle, .break_ctl = gs_break_ctl, .poll = gs_poll, + .ioctl = gs_ioctl, }; /*-------------------------------------------------------------------------*/ diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h index ce00840..8d0901e 100644 --- a/drivers/usb/gadget/function/u_serial.h +++ b/drivers/usb/gadget/function/u_serial.h @@ -53,6 +53,7 @@ struct gserial { int (*send_break)(struct gserial *p, int duration); unsigned int (*poll)(struct gserial *p, struct file *file, poll_table *wait); + int (*ioctl)(struct gserial *p, unsigned int cmd, unsigned long arg); }; /* utilities to allocate/free request and buffer */ -- 2.7.4