From: Ladislav Michl <ladis@linux-mips.org>
To: linux-usb@vger.kernel.org, linux-serial@vger.kernel.org
Cc: "Felipe Balbi" <balbi@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Subject: [PATCH v2 2/5] usb: gadget: u_serial: Remove console specific alloc/free req functions
Date: Sat, 13 Jul 2019 23:10:58 +0200 [thread overview]
Message-ID: <20190713211057.GC25753@lenoch> (raw)
In-Reply-To: <20190713210853.GA25753@lenoch>
Driver already contains request allocation and deallocation
functions, so use them also for console_req.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
Changes:
- v2: Move locking changes into separate patch
drivers/usb/gadget/function/u_serial.c | 28 ++------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 876af4085cea..cb88a640179e 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -892,30 +892,6 @@ static struct tty_driver *gs_tty_driver;
static struct gscons_info gscons_info;
static struct console gserial_cons;
-static struct usb_request *gs_request_new(struct usb_ep *ep)
-{
- struct usb_request *req = usb_ep_alloc_request(ep, GFP_ATOMIC);
- if (!req)
- return NULL;
-
- req->buf = kmalloc(ep->maxpacket, GFP_ATOMIC);
- if (!req->buf) {
- usb_ep_free_request(ep, req);
- return NULL;
- }
-
- return req;
-}
-
-static void gs_request_free(struct usb_request *req, struct usb_ep *ep)
-{
- if (!req)
- return;
-
- kfree(req->buf);
- usb_ep_free_request(ep, req);
-}
-
static void gs_complete_out(struct usb_ep *ep, struct usb_request *req)
{
struct gscons_info *info = &gscons_info;
@@ -955,7 +931,7 @@ static int gs_console_connect(int port_num)
port = ports[port_num].port;
ep = port->port_usb->in;
if (!info->console_req) {
- info->console_req = gs_request_new(ep);
+ info->console_req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
if (!info->console_req)
return -ENOMEM;
info->console_req->complete = gs_complete_out;
@@ -974,7 +950,7 @@ static void gs_console_disconnect(struct usb_ep *ep)
struct gscons_info *info = &gscons_info;
struct usb_request *req = info->console_req;
- gs_request_free(req, ep);
+ gs_free_req(ep, req);
info->console_req = NULL;
}
--
2.22.0
next prev parent reply other threads:[~2019-07-13 21:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-13 21:08 [PATCH v2 0/5] usb: gadget: u_serial: Fix and cleanup Ladislav Michl
2019-07-13 21:10 ` [PATCH v2 1/5] usb: gadget: u_serial: Fix console_req complete event race Ladislav Michl
2019-07-13 21:10 ` Ladislav Michl [this message]
2019-07-13 21:11 ` [PATCH v2 3/5] usb: gadget: u_serial: Fix console_req access race Ladislav Michl
2019-07-13 21:11 ` [PATCH v2 4/5] usb: gadget: u_serial: Fix starving write Ladislav Michl
2019-07-13 21:12 ` [PATCH v2 5/5] usb: gadget: u_serial: Use bool for req_busy Ladislav Michl
2019-07-14 10:04 ` [PATCH v2 0/5] usb: gadget: u_serial: Fix and cleanup Michał Mirosław
2019-07-14 11:37 ` Michał Mirosław
2019-07-14 13:22 ` Ladislav Michl
2019-07-15 10:40 ` Ladislav Michl
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=20190713211057.GC25753@lenoch \
--to=ladis@linux-mips.org \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
/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).