Commit fea14e68 authored by Felipe Balbi's avatar Felipe Balbi

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: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent aad7c259
...@@ -401,13 +401,12 @@ static int alloc_requests(struct eth_dev *dev, struct gether *link, unsigned n) ...@@ -401,13 +401,12 @@ static int alloc_requests(struct eth_dev *dev, struct gether *link, unsigned n)
static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags) static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
{ {
struct usb_request *req; struct usb_request *req;
struct usb_request *tmp;
unsigned long flags; unsigned long flags;
/* fill unused rxq slots with some skb */ /* fill unused rxq slots with some skb */
spin_lock_irqsave(&dev->req_lock, flags); spin_lock_irqsave(&dev->req_lock, flags);
while (!list_empty(&dev->rx_reqs)) { list_for_each_entry_safe(req, tmp, &dev->rx_reqs, list) {
req = container_of(dev->rx_reqs.next,
struct usb_request, list);
list_del_init(&req->list); list_del_init(&req->list);
spin_unlock_irqrestore(&dev->req_lock, flags); spin_unlock_irqrestore(&dev->req_lock, flags);
...@@ -527,7 +526,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, ...@@ -527,7 +526,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
req = container_of(dev->tx_reqs.next, struct usb_request, list); req = list_first_entry(&dev->tx_reqs, struct usb_request, list);
list_del(&req->list); list_del(&req->list);
/* temporarily stop TX queue when the freelist empties */ /* temporarily stop TX queue when the freelist empties */
...@@ -1122,6 +1121,7 @@ void gether_disconnect(struct gether *link) ...@@ -1122,6 +1121,7 @@ void gether_disconnect(struct gether *link)
{ {
struct eth_dev *dev = link->ioport; struct eth_dev *dev = link->ioport;
struct usb_request *req; struct usb_request *req;
struct usb_request *tmp;
WARN_ON(!dev); WARN_ON(!dev);
if (!dev) if (!dev)
...@@ -1138,9 +1138,7 @@ void gether_disconnect(struct gether *link) ...@@ -1138,9 +1138,7 @@ void gether_disconnect(struct gether *link)
*/ */
usb_ep_disable(link->in_ep); usb_ep_disable(link->in_ep);
spin_lock(&dev->req_lock); spin_lock(&dev->req_lock);
while (!list_empty(&dev->tx_reqs)) { list_for_each_entry_safe(req, tmp, &dev->tx_reqs, list) {
req = container_of(dev->tx_reqs.next,
struct usb_request, list);
list_del(&req->list); list_del(&req->list);
spin_unlock(&dev->req_lock); spin_unlock(&dev->req_lock);
...@@ -1152,9 +1150,7 @@ void gether_disconnect(struct gether *link) ...@@ -1152,9 +1150,7 @@ void gether_disconnect(struct gether *link)
usb_ep_disable(link->out_ep); usb_ep_disable(link->out_ep);
spin_lock(&dev->req_lock); spin_lock(&dev->req_lock);
while (!list_empty(&dev->rx_reqs)) { list_for_each_entry_safe(req, tmp, &dev->rx_reqs, list) {
req = container_of(dev->rx_reqs.next,
struct usb_request, list);
list_del(&req->list); list_del(&req->list);
spin_unlock(&dev->req_lock); spin_unlock(&dev->req_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment