Lines Matching +full:g +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0+
3 * u_ether.c -- Ethernet-over-USB link layer utilities for Gadget stack
5 * Copyright (C) 2003-2005,2008 David Brownell
6 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
27 * This component encapsulates the Ethernet link glue needed to provide
28 * one (!) network link through the USB gadget stack, normally "usb0".
35 * Link level addressing is handled by this component using module
36 * parameters; if no such parameters are provided, random link level
37 * addresses are used. Each end of the link uses one address. The
41 * The driver which assembles each configuration using such a link is
43 * instance of is network link. (The network layer provides ways for
44 * this single "physical" link to be used by multiple virtual links.)
47 #define UETH__VERSION "29-May-2008"
90 /*-------------------------------------------------------------------------*/
99 if (gadget->speed == USB_SPEED_HIGH || gadget->speed >= USB_SPEED_SUPER) in qlen()
105 /*-------------------------------------------------------------------------*/
113 strscpy(p->driver, "g_ether", sizeof(p->driver)); in eth_get_drvinfo()
114 strscpy(p->version, UETH__VERSION, sizeof(p->version)); in eth_get_drvinfo()
115 strscpy(p->fw_version, dev->gadget->name, sizeof(p->fw_version)); in eth_get_drvinfo()
116 strscpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof(p->bus_info)); in eth_get_drvinfo()
120 * - WOL (by tracking suspends and issuing remote wakeup)
121 * - msglevel (implies updated messaging)
122 * - ... probably more ethtool ops
132 if (test_and_set_bit(flag, &dev->todo)) in defer_kevent()
134 if (!schedule_work(&dev->work)) in defer_kevent()
145 struct usb_gadget *g = dev->gadget; in rx_submit() local
147 int retval = -ENOMEM; in rx_submit()
152 spin_lock_irqsave(&dev->lock, flags); in rx_submit()
153 if (dev->port_usb) in rx_submit()
154 out = dev->port_usb->out_ep; in rx_submit()
160 spin_unlock_irqrestore(&dev->lock, flags); in rx_submit()
161 return -ENOTCONN; in rx_submit()
168 * reads (e.g. DMA must be N*maxpacket), so for now don't trim a in rx_submit()
172 * pad to end-of-packet. That's potentially nice for speed, but in rx_submit()
176 size += sizeof(struct ethhdr) + dev->net->mtu + RX_EXTRA; in rx_submit()
177 size += dev->port_usb->header_len; in rx_submit()
179 if (g->quirk_ep_out_aligned_size) { in rx_submit()
180 size += out->maxpacket - 1; in rx_submit()
181 size -= size % out->maxpacket; in rx_submit()
184 if (dev->port_usb->is_fixed) in rx_submit()
185 size = max_t(size_t, size, dev->port_usb->fixed_out_len); in rx_submit()
186 spin_unlock_irqrestore(&dev->lock, flags); in rx_submit()
188 skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags); in rx_submit()
198 if (likely(!dev->no_skb_reserve)) in rx_submit()
201 req->buf = skb->data; in rx_submit()
202 req->length = size; in rx_submit()
203 req->complete = rx_complete; in rx_submit()
204 req->context = skb; in rx_submit()
207 if (retval == -ENOMEM) in rx_submit()
211 DBG(dev, "rx submit --> %d\n", retval); in rx_submit()
214 spin_lock_irqsave(&dev->req_lock, flags); in rx_submit()
215 list_add(&req->list, &dev->rx_reqs); in rx_submit()
216 spin_unlock_irqrestore(&dev->req_lock, flags); in rx_submit()
223 struct sk_buff *skb = req->context, *skb2; in rx_complete()
224 struct eth_dev *dev = ep->driver_data; in rx_complete()
225 int status = req->status; in rx_complete()
231 skb_put(skb, req->actual); in rx_complete()
233 if (dev->unwrap) { in rx_complete()
236 spin_lock_irqsave(&dev->lock, flags); in rx_complete()
237 if (dev->port_usb) { in rx_complete()
238 status = dev->unwrap(dev->port_usb, in rx_complete()
240 &dev->rx_frames); in rx_complete()
243 status = -ENOTCONN; in rx_complete()
245 spin_unlock_irqrestore(&dev->lock, flags); in rx_complete()
247 skb_queue_tail(&dev->rx_frames, skb); in rx_complete()
251 skb2 = skb_dequeue(&dev->rx_frames); in rx_complete()
254 || ETH_HLEN > skb2->len in rx_complete()
255 || skb2->len > GETHER_MAX_ETH_FRAME_LEN) { in rx_complete()
256 dev->net->stats.rx_errors++; in rx_complete()
257 dev->net->stats.rx_length_errors++; in rx_complete()
258 DBG(dev, "rx length %d\n", skb2->len); in rx_complete()
262 skb2->protocol = eth_type_trans(skb2, dev->net); in rx_complete()
263 dev->net->stats.rx_packets++; in rx_complete()
264 dev->net->stats.rx_bytes += skb2->len; in rx_complete()
271 skb2 = skb_dequeue(&dev->rx_frames); in rx_complete()
275 /* software-driven interface shutdown */ in rx_complete()
276 case -ECONNRESET: /* unlink */ in rx_complete()
277 case -ESHUTDOWN: /* disconnect etc */ in rx_complete()
282 case -ECONNABORTED: /* endpoint reset */ in rx_complete()
283 DBG(dev, "rx %s reset\n", ep->name); in rx_complete()
290 case -EOVERFLOW: in rx_complete()
291 dev->net->stats.rx_over_errors++; in rx_complete()
295 dev->net->stats.rx_errors++; in rx_complete()
302 if (!netif_running(dev->net)) { in rx_complete()
304 spin_lock(&dev->req_lock); in rx_complete()
305 list_add(&req->list, &dev->rx_reqs); in rx_complete()
306 spin_unlock(&dev->req_lock); in rx_complete()
319 return -ENOMEM; in prealloc()
324 if (i-- == 0) in prealloc()
327 while (i--) { in prealloc()
330 return list_empty(list) ? -ENOMEM : 0; in prealloc()
331 list_add(&req->list, list); in prealloc()
340 next = req->list.next; in prealloc()
341 list_del(&req->list); in prealloc()
352 static int alloc_requests(struct eth_dev *dev, struct gether *link, unsigned n) in alloc_requests() argument
356 spin_lock(&dev->req_lock); in alloc_requests()
357 status = prealloc(&dev->tx_reqs, link->in_ep, n); in alloc_requests()
360 status = prealloc(&dev->rx_reqs, link->out_ep, n); in alloc_requests()
367 spin_unlock(&dev->req_lock); in alloc_requests()
377 spin_lock_irqsave(&dev->req_lock, flags); in rx_fill()
378 while (!list_empty(&dev->rx_reqs)) { in rx_fill()
379 req = list_first_entry(&dev->rx_reqs, struct usb_request, list); in rx_fill()
380 list_del_init(&req->list); in rx_fill()
381 spin_unlock_irqrestore(&dev->req_lock, flags); in rx_fill()
388 spin_lock_irqsave(&dev->req_lock, flags); in rx_fill()
390 spin_unlock_irqrestore(&dev->req_lock, flags); in rx_fill()
397 if (test_and_clear_bit(WORK_RX_MEMORY, &dev->todo)) { in eth_work()
398 if (netif_running(dev->net)) in eth_work()
402 if (dev->todo) in eth_work()
403 DBG(dev, "work done, flags = 0x%lx\n", dev->todo); in eth_work()
408 struct sk_buff *skb = req->context; in tx_complete()
409 struct eth_dev *dev = ep->driver_data; in tx_complete()
411 switch (req->status) { in tx_complete()
413 dev->net->stats.tx_errors++; in tx_complete()
414 VDBG(dev, "tx err %d\n", req->status); in tx_complete()
416 case -ECONNRESET: /* unlink */ in tx_complete()
417 case -ESHUTDOWN: /* disconnect etc */ in tx_complete()
421 dev->net->stats.tx_bytes += skb->len; in tx_complete()
424 dev->net->stats.tx_packets++; in tx_complete()
426 spin_lock(&dev->req_lock); in tx_complete()
427 list_add(&req->list, &dev->tx_reqs); in tx_complete()
428 spin_unlock(&dev->req_lock); in tx_complete()
430 atomic_dec(&dev->tx_qlen); in tx_complete()
431 if (netif_carrier_ok(dev->net)) in tx_complete()
432 netif_wake_queue(dev->net); in tx_complete()
443 struct usb_function *func = &port->func; in ether_wakeup_host()
444 struct usb_gadget *gadget = func->config->cdev->gadget; in ether_wakeup_host()
446 if (func->func_suspended) in ether_wakeup_host()
465 spin_lock_irqsave(&dev->lock, flags); in eth_start_xmit()
466 if (dev->port_usb) { in eth_start_xmit()
467 in = dev->port_usb->in_ep; in eth_start_xmit()
468 cdc_filter = dev->port_usb->cdc_filter; in eth_start_xmit()
474 if (dev->port_usb && dev->port_usb->is_suspend) { in eth_start_xmit()
477 spin_unlock_irqrestore(&dev->lock, flags); in eth_start_xmit()
478 ether_wakeup_host(dev->port_usb); in eth_start_xmit()
482 spin_unlock_irqrestore(&dev->lock, flags); in eth_start_xmit()
492 u8 *dest = skb->data; in eth_start_xmit()
512 spin_lock_irqsave(&dev->req_lock, flags); in eth_start_xmit()
518 if (list_empty(&dev->tx_reqs)) { in eth_start_xmit()
519 spin_unlock_irqrestore(&dev->req_lock, flags); in eth_start_xmit()
523 req = list_first_entry(&dev->tx_reqs, struct usb_request, list); in eth_start_xmit()
524 list_del(&req->list); in eth_start_xmit()
527 if (list_empty(&dev->tx_reqs)) in eth_start_xmit()
529 spin_unlock_irqrestore(&dev->req_lock, flags); in eth_start_xmit()
535 if (dev->wrap) { in eth_start_xmit()
538 spin_lock_irqsave(&dev->lock, flags); in eth_start_xmit()
539 if (dev->port_usb) in eth_start_xmit()
540 skb = dev->wrap(dev->port_usb, skb); in eth_start_xmit()
541 spin_unlock_irqrestore(&dev->lock, flags); in eth_start_xmit()
546 if (dev->port_usb && in eth_start_xmit()
547 dev->port_usb->supports_multi_frame) in eth_start_xmit()
553 length = skb->len; in eth_start_xmit()
554 req->buf = skb->data; in eth_start_xmit()
555 req->context = skb; in eth_start_xmit()
556 req->complete = tx_complete; in eth_start_xmit()
559 if (dev->port_usb && in eth_start_xmit()
560 dev->port_usb->is_fixed && in eth_start_xmit()
561 length == dev->port_usb->fixed_in_len && in eth_start_xmit()
562 (length % in->maxpacket) == 0) in eth_start_xmit()
563 req->zero = 0; in eth_start_xmit()
565 req->zero = 1; in eth_start_xmit()
567 /* use zlp framing on tx for strict CDC-Ether conformance, in eth_start_xmit()
571 if (req->zero && !dev->zlp && (length % in->maxpacket) == 0) in eth_start_xmit()
574 req->length = length; in eth_start_xmit()
583 atomic_inc(&dev->tx_qlen); in eth_start_xmit()
589 dev->net->stats.tx_dropped++; in eth_start_xmit()
591 spin_lock_irqsave(&dev->req_lock, flags); in eth_start_xmit()
592 if (list_empty(&dev->tx_reqs)) in eth_start_xmit()
594 list_add(&req->list, &dev->tx_reqs); in eth_start_xmit()
595 spin_unlock_irqrestore(&dev->req_lock, flags); in eth_start_xmit()
600 /*-------------------------------------------------------------------------*/
610 atomic_set(&dev->tx_qlen, 0); in eth_start()
611 netif_wake_queue(dev->net); in eth_start()
617 struct gether *link; in eth_open() local
620 if (netif_carrier_ok(dev->net)) in eth_open()
623 spin_lock_irq(&dev->lock); in eth_open()
624 link = dev->port_usb; in eth_open()
625 if (link && link->open) in eth_open()
626 link->open(link); in eth_open()
627 spin_unlock_irq(&dev->lock); in eth_open()
641 dev->net->stats.rx_packets, dev->net->stats.tx_packets, in eth_stop()
642 dev->net->stats.rx_errors, dev->net->stats.tx_errors in eth_stop()
646 spin_lock_irqsave(&dev->lock, flags); in eth_stop()
647 if (dev->port_usb) { in eth_stop()
648 struct gether *link = dev->port_usb; in eth_stop() local
652 if (link->close) in eth_stop()
653 link->close(link); in eth_stop()
655 /* NOTE: we have no abort-queue primitive we could use in eth_stop()
658 * wrong, but that's a self-correcting error. in eth_stop()
664 in = link->in_ep->desc; in eth_stop()
665 out = link->out_ep->desc; in eth_stop()
666 usb_ep_disable(link->in_ep); in eth_stop()
667 usb_ep_disable(link->out_ep); in eth_stop()
670 link->in_ep->desc = in; in eth_stop()
671 link->out_ep->desc = out; in eth_stop()
672 usb_ep_enable(link->in_ep); in eth_stop()
673 usb_ep_enable(link->out_ep); in eth_stop()
676 spin_unlock_irqrestore(&dev->lock, flags); in eth_stop()
681 /*-------------------------------------------------------------------------*/
707 return -EINVAL; in get_ether_addr_str()
726 * gether_setup_name - initialize one ethernet-over-usb link
727 * @g: gadget to associated with these links
729 * host side of the link is recorded
733 * This sets up the single network link that may be exported by a
734 * gadget driver using this framework. The link layer addresses are
739 struct eth_dev *gether_setup_name(struct usb_gadget *g, in gether_setup_name() argument
750 return ERR_PTR(-ENOMEM); in gether_setup_name()
753 spin_lock_init(&dev->lock); in gether_setup_name()
754 spin_lock_init(&dev->req_lock); in gether_setup_name()
755 INIT_WORK(&dev->work, eth_work); in gether_setup_name()
756 INIT_LIST_HEAD(&dev->tx_reqs); in gether_setup_name()
757 INIT_LIST_HEAD(&dev->rx_reqs); in gether_setup_name()
759 skb_queue_head_init(&dev->rx_frames); in gether_setup_name()
762 dev->net = net; in gether_setup_name()
763 dev->qmult = qmult; in gether_setup_name()
764 snprintf(net->name, sizeof(net->name), "%s%%d", netname); in gether_setup_name()
767 net->addr_assign_type = NET_ADDR_RANDOM; in gether_setup_name()
768 dev_warn(&g->dev, in gether_setup_name()
771 net->addr_assign_type = NET_ADDR_SET; in gether_setup_name()
774 if (get_ether_addr(host_addr, dev->host_mac)) in gether_setup_name()
775 dev_warn(&g->dev, in gether_setup_name()
779 memcpy(ethaddr, dev->host_mac, ETH_ALEN); in gether_setup_name()
781 net->netdev_ops = ð_netdev_ops; in gether_setup_name()
783 net->ethtool_ops = &ops; in gether_setup_name()
785 /* MTU range: 14 - 15412 */ in gether_setup_name()
786 net->min_mtu = ETH_HLEN; in gether_setup_name()
787 net->max_mtu = GETHER_MAX_MTU_SIZE; in gether_setup_name()
789 dev->gadget = g; in gether_setup_name()
790 SET_NETDEV_DEV(net, &g->dev); in gether_setup_name()
795 dev_dbg(&g->dev, "register_netdev failed, %d\n", status); in gether_setup_name()
799 INFO(dev, "MAC %pM\n", net->dev_addr); in gether_setup_name()
800 INFO(dev, "HOST MAC %pM\n", dev->host_mac); in gether_setup_name()
803 * two kinds of host-initiated state changes: in gether_setup_name()
804 * - iff DATA transfer is active, carrier is "on" in gether_setup_name()
805 * - tx queueing enabled if open *and* carrier is "on" in gether_setup_name()
821 return ERR_PTR(-ENOMEM); in gether_setup_name_default()
824 spin_lock_init(&dev->lock); in gether_setup_name_default()
825 spin_lock_init(&dev->req_lock); in gether_setup_name_default()
826 INIT_WORK(&dev->work, eth_work); in gether_setup_name_default()
827 INIT_LIST_HEAD(&dev->tx_reqs); in gether_setup_name_default()
828 INIT_LIST_HEAD(&dev->rx_reqs); in gether_setup_name_default()
830 skb_queue_head_init(&dev->rx_frames); in gether_setup_name_default()
833 dev->net = net; in gether_setup_name_default()
834 dev->qmult = QMULT_DEFAULT; in gether_setup_name_default()
835 snprintf(net->name, sizeof(net->name), "%s%%d", netname); in gether_setup_name_default()
837 eth_random_addr(dev->dev_mac); in gether_setup_name_default()
840 net->addr_assign_type = NET_ADDR_RANDOM; in gether_setup_name_default()
842 eth_random_addr(dev->host_mac); in gether_setup_name_default()
844 net->netdev_ops = ð_netdev_ops; in gether_setup_name_default()
846 net->ethtool_ops = &ops; in gether_setup_name_default()
849 /* MTU range: 14 - 15412 */ in gether_setup_name_default()
850 net->min_mtu = ETH_HLEN; in gether_setup_name_default()
851 net->max_mtu = GETHER_MAX_MTU_SIZE; in gether_setup_name_default()
860 struct usb_gadget *g; in gether_register_netdev() local
863 if (!net->dev.parent) in gether_register_netdev()
864 return -EINVAL; in gether_register_netdev()
866 g = dev->gadget; in gether_register_netdev()
868 eth_hw_addr_set(net, dev->dev_mac); in gether_register_netdev()
872 dev_dbg(&g->dev, "register_netdev failed, %d\n", status); in gether_register_netdev()
875 INFO(dev, "HOST MAC %pM\n", dev->host_mac); in gether_register_netdev()
876 INFO(dev, "MAC %pM\n", dev->dev_mac); in gether_register_netdev()
878 /* two kinds of host-initiated state changes: in gether_register_netdev()
879 * - iff DATA transfer is active, carrier is "on" in gether_register_netdev()
880 * - tx queueing enabled if open *and* carrier is "on" in gether_register_netdev()
889 void gether_set_gadget(struct net_device *net, struct usb_gadget *g) in gether_set_gadget() argument
894 dev->gadget = g; in gether_set_gadget()
895 SET_NETDEV_DEV(net, &g->dev); in gether_set_gadget()
906 return -EINVAL; in gether_set_dev_addr()
907 memcpy(dev->dev_mac, new_addr, ETH_ALEN); in gether_set_dev_addr()
908 net->addr_assign_type = NET_ADDR_SET; in gether_set_dev_addr()
919 ret = get_ether_addr_str(dev->dev_mac, dev_addr, len); in gether_get_dev_addr()
936 return -EINVAL; in gether_set_host_addr()
937 memcpy(dev->host_mac, new_addr, ETH_ALEN); in gether_set_host_addr()
948 ret = get_ether_addr_str(dev->host_mac, host_addr, len); in gether_get_host_addr()
963 return -EINVAL; in gether_get_host_addr_cdc()
966 snprintf(host_addr, len, "%pm", dev->host_mac); in gether_get_host_addr_cdc()
979 memcpy(host_mac, dev->host_mac, ETH_ALEN); in gether_get_host_addr_u8()
988 dev->qmult = qmult; in gether_set_qmult()
997 return dev->qmult; in gether_get_qmult()
1008 dev->ifname_set ? net->name : netdev_name(net)); in gether_get_ifname()
1020 if (name[len - 1] == '\n') in gether_set_ifname()
1021 len--; in gether_set_ifname()
1024 return -E2BIG; in gether_set_ifname()
1028 return -EINVAL; in gether_set_ifname()
1033 return -EINVAL; in gether_set_ifname()
1035 strncpy(net->name, tmp, sizeof(net->name)); in gether_set_ifname()
1036 dev->ifname_set = true; in gether_set_ifname()
1042 void gether_suspend(struct gether *link) in gether_suspend() argument
1044 struct eth_dev *dev = link->ioport; in gether_suspend()
1050 if (atomic_read(&dev->tx_qlen)) { in gether_suspend()
1055 ether_wakeup_host(dev->port_usb); in gether_suspend()
1058 spin_lock_irqsave(&dev->lock, flags); in gether_suspend()
1059 link->is_suspend = true; in gether_suspend()
1060 spin_unlock_irqrestore(&dev->lock, flags); in gether_suspend()
1064 void gether_resume(struct gether *link) in gether_resume() argument
1066 struct eth_dev *dev = link->ioport; in gether_resume()
1072 if (netif_queue_stopped(dev->net)) in gether_resume()
1073 netif_start_queue(dev->net); in gether_resume()
1075 spin_lock_irqsave(&dev->lock, flags); in gether_resume()
1076 link->is_suspend = false; in gether_resume()
1077 spin_unlock_irqrestore(&dev->lock, flags); in gether_resume()
1082 * gether_cleanup - remove Ethernet-over-USB device
1092 unregister_netdev(dev->net); in gether_cleanup()
1093 flush_work(&dev->work); in gether_cleanup()
1094 free_netdev(dev->net); in gether_cleanup()
1099 * gether_connect - notify network layer that USB link is active
1100 * @link: the USB link, set up with endpoints, descriptors matching
1111 * indicate some error code (negative errno), ep->driver_data values
1114 struct net_device *gether_connect(struct gether *link) in gether_connect() argument
1116 struct eth_dev *dev = link->ioport; in gether_connect()
1120 return ERR_PTR(-EINVAL); in gether_connect()
1122 link->in_ep->driver_data = dev; in gether_connect()
1123 result = usb_ep_enable(link->in_ep); in gether_connect()
1125 DBG(dev, "enable %s --> %d\n", in gether_connect()
1126 link->in_ep->name, result); in gether_connect()
1130 link->out_ep->driver_data = dev; in gether_connect()
1131 result = usb_ep_enable(link->out_ep); in gether_connect()
1133 DBG(dev, "enable %s --> %d\n", in gether_connect()
1134 link->out_ep->name, result); in gether_connect()
1139 result = alloc_requests(dev, link, qlen(dev->gadget, in gether_connect()
1140 dev->qmult)); in gether_connect()
1143 dev->zlp = link->is_zlp_ok; in gether_connect()
1144 dev->no_skb_reserve = gadget_avoids_skb_reserve(dev->gadget); in gether_connect()
1145 DBG(dev, "qlen %d\n", qlen(dev->gadget, dev->qmult)); in gether_connect()
1147 dev->header_len = link->header_len; in gether_connect()
1148 dev->unwrap = link->unwrap; in gether_connect()
1149 dev->wrap = link->wrap; in gether_connect()
1151 spin_lock(&dev->lock); in gether_connect()
1152 dev->port_usb = link; in gether_connect()
1153 if (netif_running(dev->net)) { in gether_connect()
1154 if (link->open) in gether_connect()
1155 link->open(link); in gether_connect()
1157 if (link->close) in gether_connect()
1158 link->close(link); in gether_connect()
1160 spin_unlock(&dev->lock); in gether_connect()
1162 netif_carrier_on(dev->net); in gether_connect()
1163 if (netif_running(dev->net)) in gether_connect()
1168 (void) usb_ep_disable(link->out_ep); in gether_connect()
1170 (void) usb_ep_disable(link->in_ep); in gether_connect()
1176 return dev->net; in gether_connect()
1181 * gether_disconnect - notify network layer that USB link is inactive
1182 * @link: the USB link, on which gether_connect() was called
1192 void gether_disconnect(struct gether *link) in gether_disconnect() argument
1194 struct eth_dev *dev = link->ioport; in gether_disconnect()
1203 netif_stop_queue(dev->net); in gether_disconnect()
1204 netif_carrier_off(dev->net); in gether_disconnect()
1210 usb_ep_disable(link->in_ep); in gether_disconnect()
1211 spin_lock(&dev->req_lock); in gether_disconnect()
1212 while (!list_empty(&dev->tx_reqs)) { in gether_disconnect()
1213 req = list_first_entry(&dev->tx_reqs, struct usb_request, list); in gether_disconnect()
1214 list_del(&req->list); in gether_disconnect()
1216 spin_unlock(&dev->req_lock); in gether_disconnect()
1217 usb_ep_free_request(link->in_ep, req); in gether_disconnect()
1218 spin_lock(&dev->req_lock); in gether_disconnect()
1220 spin_unlock(&dev->req_lock); in gether_disconnect()
1221 link->in_ep->desc = NULL; in gether_disconnect()
1223 usb_ep_disable(link->out_ep); in gether_disconnect()
1224 spin_lock(&dev->req_lock); in gether_disconnect()
1225 while (!list_empty(&dev->rx_reqs)) { in gether_disconnect()
1226 req = list_first_entry(&dev->rx_reqs, struct usb_request, list); in gether_disconnect()
1227 list_del(&req->list); in gether_disconnect()
1229 spin_unlock(&dev->req_lock); in gether_disconnect()
1230 usb_ep_free_request(link->out_ep, req); in gether_disconnect()
1231 spin_lock(&dev->req_lock); in gether_disconnect()
1233 spin_unlock(&dev->req_lock); in gether_disconnect()
1234 link->out_ep->desc = NULL; in gether_disconnect()
1236 /* finish forgetting about this USB link episode */ in gether_disconnect()
1237 dev->header_len = 0; in gether_disconnect()
1238 dev->unwrap = NULL; in gether_disconnect()
1239 dev->wrap = NULL; in gether_disconnect()
1241 spin_lock(&dev->lock); in gether_disconnect()
1242 dev->port_usb = NULL; in gether_disconnect()
1243 link->is_suspend = false; in gether_disconnect()
1244 spin_unlock(&dev->lock); in gether_disconnect()