diff options
author | Mathias Nyman <mathias.nyman@linux.intel.com> | 2020-07-23 17:45:25 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-23 17:05:28 +0200 |
commit | e0aa56dc7b18c80b12a9afd23d90aa6d186f639a (patch) | |
tree | a3a7f3ce83047b4e566e945391df071ecf46828e /drivers/usb/host/xhci-dbgtty.c | |
parent | 11e229a7585160c33228a9789405a504b8150525 (diff) | |
download | lwn-e0aa56dc7b18c80b12a9afd23d90aa6d186f639a.tar.gz lwn-e0aa56dc7b18c80b12a9afd23d90aa6d186f639a.zip |
xhci: dbc: simplify dbc requests allocation and queueing
Don't pass endpoint pointer, dbctty should not be aware of
struct dbc_ep, knowing the direction is enough.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200723144530.9992-23-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci-dbgtty.c')
-rw-r--r-- | drivers/usb/host/xhci-dbgtty.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 967f0419dad7..9886d42e1ff2 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -48,7 +48,7 @@ static int dbc_start_tx(struct dbc_port *port) list_del(&req->list_pool); spin_unlock(&port->port_lock); - status = dbc_ep_queue(port->out, req, GFP_ATOMIC); + status = dbc_ep_queue(req); spin_lock(&port->port_lock); if (status) { @@ -80,7 +80,7 @@ static void dbc_start_rx(struct dbc_port *port) req->length = DBC_MAX_PACKET; spin_unlock(&port->port_lock); - status = dbc_ep_queue(port->in, req, GFP_ATOMIC); + status = dbc_ep_queue(req); spin_lock(&port->port_lock); if (status) { @@ -123,28 +123,29 @@ static void dbc_write_complete(struct xhci_dbc *dbc, struct dbc_request *req) spin_unlock_irqrestore(&port->port_lock, flags); } -static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) +static void xhci_dbc_free_req(struct dbc_request *req) { kfree(req->buf); - dbc_free_request(dep, req); + dbc_free_request(req); } static int -xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, +xhci_dbc_alloc_requests(struct xhci_dbc *dbc, unsigned int direction, + struct list_head *head, void (*fn)(struct xhci_dbc *, struct dbc_request *)) { int i; struct dbc_request *req; for (i = 0; i < DBC_QUEUE_SIZE; i++) { - req = dbc_alloc_request(dep, GFP_KERNEL); + req = dbc_alloc_request(dbc, direction, GFP_KERNEL); if (!req) break; req->length = DBC_MAX_PACKET; req->buf = kmalloc(req->length, GFP_KERNEL); if (!req->buf) { - dbc_free_request(dep, req); + dbc_free_request(req); break; } @@ -156,14 +157,14 @@ xhci_dbc_alloc_requests(struct dbc_ep *dep, struct list_head *head, } static void -xhci_dbc_free_requests(struct dbc_ep *dep, struct list_head *head) +xhci_dbc_free_requests(struct list_head *head) { struct dbc_request *req; while (!list_empty(head)) { req = list_entry(head->next, struct dbc_request, list_pool); list_del(&req->list_pool); - xhci_dbc_free_req(dep, req); + xhci_dbc_free_req(req); } } @@ -456,12 +457,12 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) if (ret) goto buf_alloc_fail; - ret = xhci_dbc_alloc_requests(port->in, &port->read_pool, + ret = xhci_dbc_alloc_requests(dbc, BULK_IN, &port->read_pool, dbc_read_complete); if (ret) goto request_fail; - ret = xhci_dbc_alloc_requests(port->out, &port->write_pool, + ret = xhci_dbc_alloc_requests(dbc, BULK_OUT, &port->write_pool, dbc_write_complete); if (ret) goto request_fail; @@ -471,8 +472,8 @@ int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) return 0; request_fail: - xhci_dbc_free_requests(port->in, &port->read_pool); - xhci_dbc_free_requests(port->out, &port->write_pool); + xhci_dbc_free_requests(&port->read_pool); + xhci_dbc_free_requests(&port->write_pool); kfifo_free(&port->write_fifo); buf_alloc_fail: @@ -495,7 +496,7 @@ void xhci_dbc_tty_unregister_device(struct xhci_dbc *dbc) port->registered = false; kfifo_free(&port->write_fifo); - xhci_dbc_free_requests(get_out_ep(dbc), &port->read_pool); - xhci_dbc_free_requests(get_out_ep(dbc), &port->read_queue); - xhci_dbc_free_requests(get_in_ep(dbc), &port->write_pool); + xhci_dbc_free_requests(&port->read_pool); + xhci_dbc_free_requests(&port->read_queue); + xhci_dbc_free_requests(&port->write_pool); } |