From patchwork Wed Feb 27 07:48:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10831371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C56721669 for ; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1C2F29B9A for ; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3B452A356; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C2072B69D for ; Wed, 27 Feb 2019 07:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729614AbfB0HtB (ORCPT ); Wed, 27 Feb 2019 02:49:01 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:8655 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729542AbfB0HtB (ORCPT ); Wed, 27 Feb 2019 02:49:01 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 448ST96xDPzQ4; Wed, 27 Feb 2019 08:47:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1551253662; bh=+yM36rKNlN+7bQ+MvrsF3rCLf4rqVdFTR/+JjOh0AcY=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=hOqq/fRVWMeOiVMtNWqDD+scetPCt44Qiee9Ctb5NTwniWXylS0fJKix/Ut2esxNj F1rsWrfuC2M02B5+btkaejwgQnN/Xvaxj7ABEOQq5fIsUA2PuIEN68ZmQx5hbAHJQ8 9eGUJjN3nOmeFBuBjtO7iTs1KF2OYPOUl9ySaAQ+C2VQ+BXbAVCBQBXjodlHrk+Xo8 jozBhK8vmUQ1JEHyRdfmdOX8jR9r31QqFpafPTlakdp3KKqtZFigXb10m4VBbnn10I uuwVFs72Grk7+YGygjNl0OITANYqOlriCcRGrk/nv6TlYD431+VOrEDjsxY5WLINfe kLfImcKKEpnCQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Wed, 27 Feb 2019 08:48:57 +0100 Message-Id: <3a0a3ebfe65b7cc5b413ecc11af7aa9b0c97a532.1551253561.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 3/5] usb: gadget: u_serial: make OBEX port not a console MIME-Version: 1.0 To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prevent OBEX serial port from ever becoming a console. Signed-off-by: Michał Mirosław --- drivers/usb/gadget/function/f_acm.c | 2 +- drivers/usb/gadget/function/f_obex.c | 2 +- drivers/usb/gadget/function/f_serial.c | 2 +- drivers/usb/gadget/function/u_serial.c | 4 ++-- drivers/usb/gadget/function/u_serial.h | 2 +- drivers/usb/gadget/legacy/dbgp.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index 9fc98de83624..60d18c7dcef3 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c @@ -807,7 +807,7 @@ static struct usb_function_instance *acm_alloc_instance(void) if (!opts) return ERR_PTR(-ENOMEM); opts->func_inst.free_func_inst = acm_free_instance; - ret = gserial_alloc_line(&opts->port_num); + ret = gserial_alloc_line(&opts->port_num, true); if (ret) { kfree(opts); return ERR_PTR(ret); diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index 55b7f57d2dc7..8242ba76dc1e 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c @@ -432,7 +432,7 @@ static struct usb_function_instance *obex_alloc_inst(void) return ERR_PTR(-ENOMEM); opts->func_inst.free_func_inst = obex_free_inst; - ret = gserial_alloc_line(&opts->port_num); + ret = gserial_alloc_line(&opts->port_num, false); if (ret) { kfree(opts); return ERR_PTR(ret); diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c index c860f30a0ea2..788179a9a23c 100644 --- a/drivers/usb/gadget/function/f_serial.c +++ b/drivers/usb/gadget/function/f_serial.c @@ -303,7 +303,7 @@ static struct usb_function_instance *gser_alloc_inst(void) return ERR_PTR(-ENOMEM); opts->func_inst.free_func_inst = gser_free_inst; - ret = gserial_alloc_line(&opts->port_num); + ret = gserial_alloc_line(&opts->port_num, true); if (ret) { kfree(opts); return ERR_PTR(ret); diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 8d2d861e1543..dd138d372940 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -1179,7 +1179,7 @@ void gserial_free_line(unsigned char port_num) } EXPORT_SYMBOL_GPL(gserial_free_line); -int gserial_alloc_line(unsigned char *line_num) +int gserial_alloc_line(unsigned char *line_num, bool maybe_console) { struct usb_cdc_line_coding coding; struct gs_port *port; @@ -1221,7 +1221,7 @@ int gserial_alloc_line(unsigned char *line_num) } *line_num = port_num; - if (!port_num) + if (maybe_console && !port_num) gs_console_init(port); err: return ret; diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h index 9acaac1cbb75..40e89ddfe90e 100644 --- a/drivers/usb/gadget/function/u_serial.h +++ b/drivers/usb/gadget/function/u_serial.h @@ -54,7 +54,7 @@ struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags); void gs_free_req(struct usb_ep *, struct usb_request *req); /* management of individual TTY ports */ -int gserial_alloc_line(unsigned char *port_line); +int gserial_alloc_line(unsigned char *port_line, bool maybe_console); void gserial_free_line(unsigned char port_line); /* connect/disconnect is handled by individual functions */ diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c index e1d566c9918a..a6785a4a1ac6 100644 --- a/drivers/usb/gadget/legacy/dbgp.c +++ b/drivers/usb/gadget/legacy/dbgp.c @@ -305,7 +305,7 @@ static int dbgp_bind(struct usb_gadget *gadget, goto fail; } - if (gserial_alloc_line(&tty_line)) { + if (gserial_alloc_line(&tty_line, true)) { stp = 4; err = -ENODEV; goto fail;