Skip to content

Commit fea14e6

Browse files
author
Felipe Balbi
committed
usb: gadget: u_ether: use better list accessors
We have helpers for some of these, let's rely on them instead of open coding what they do in u_ether.c Signed-off-by: Felipe Balbi <[email protected]>
1 parent aad7c25 commit fea14e6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/usb/gadget/function/u_ether.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,12 @@ static int alloc_requests(struct eth_dev *dev, struct gether *link, unsigned n)
401401
static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
402402
{
403403
struct usb_request *req;
404+
struct usb_request *tmp;
404405
unsigned long flags;
405406

406407
/* fill unused rxq slots with some skb */
407408
spin_lock_irqsave(&dev->req_lock, flags);
408-
while (!list_empty(&dev->rx_reqs)) {
409-
req = container_of(dev->rx_reqs.next,
410-
struct usb_request, list);
409+
list_for_each_entry_safe(req, tmp, &dev->rx_reqs, list) {
411410
list_del_init(&req->list);
412411
spin_unlock_irqrestore(&dev->req_lock, flags);
413412

@@ -527,7 +526,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
527526
return NETDEV_TX_BUSY;
528527
}
529528

530-
req = container_of(dev->tx_reqs.next, struct usb_request, list);
529+
req = list_first_entry(&dev->tx_reqs, struct usb_request, list);
531530
list_del(&req->list);
532531

533532
/* temporarily stop TX queue when the freelist empties */
@@ -1122,6 +1121,7 @@ void gether_disconnect(struct gether *link)
11221121
{
11231122
struct eth_dev *dev = link->ioport;
11241123
struct usb_request *req;
1124+
struct usb_request *tmp;
11251125

11261126
WARN_ON(!dev);
11271127
if (!dev)
@@ -1138,9 +1138,7 @@ void gether_disconnect(struct gether *link)
11381138
*/
11391139
usb_ep_disable(link->in_ep);
11401140
spin_lock(&dev->req_lock);
1141-
while (!list_empty(&dev->tx_reqs)) {
1142-
req = container_of(dev->tx_reqs.next,
1143-
struct usb_request, list);
1141+
list_for_each_entry_safe(req, tmp, &dev->tx_reqs, list) {
11441142
list_del(&req->list);
11451143

11461144
spin_unlock(&dev->req_lock);
@@ -1152,9 +1150,7 @@ void gether_disconnect(struct gether *link)
11521150

11531151
usb_ep_disable(link->out_ep);
11541152
spin_lock(&dev->req_lock);
1155-
while (!list_empty(&dev->rx_reqs)) {
1156-
req = container_of(dev->rx_reqs.next,
1157-
struct usb_request, list);
1153+
list_for_each_entry_safe(req, tmp, &dev->rx_reqs, list) {
11581154
list_del(&req->list);
11591155

11601156
spin_unlock(&dev->req_lock);

0 commit comments

Comments
 (0)