patches: refresh patches on v4.14-rc1
[openwrt/staging/blogic.git] / patches / 0025-usb-sg / usbnet.patch
1 --- a/drivers/net/usb/usbnet.c
2 +++ b/drivers/net/usb/usbnet.c
3 @@ -1310,6 +1310,7 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
4
5 /*-------------------------------------------------------------------------*/
6
7 +#if LINUX_VERSION_IS_GEQ(3,35,0)
8 static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
9 {
10 unsigned num_sgs, total_len = 0;
11 @@ -1342,6 +1343,12 @@ static int build_dma_sg(const struct sk_
12
13 return 1;
14 }
15 +#else
16 +static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
17 +{
18 + return -ENXIO;
19 +}
20 +#endif
21
22 netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
23 struct net_device *net)
24 @@ -1398,12 +1405,19 @@ netdev_tx_t usbnet_start_xmit (struct sk
25 if (!(info->flags & FLAG_SEND_ZLP)) {
26 if (!(info->flags & FLAG_MULTI_PACKET)) {
27 length++;
28 +#if LINUX_VERSION_IS_GEQ(3,35,0)
29 if (skb_tailroom(skb) && !urb->num_sgs) {
30 skb->data[skb->len] = 0;
31 __skb_put(skb, 1);
32 } else if (urb->num_sgs)
33 sg_set_buf(&urb->sg[urb->num_sgs++],
34 dev->padding_pkt, 1);
35 +#else
36 + if (skb_tailroom(skb)) {
37 + skb->data[skb->len] = 0;
38 + __skb_put(skb, 1);
39 + }
40 +#endif
41 }
42 } else
43 urb->transfer_flags |= URB_ZERO_PACKET;
44 @@ -1470,7 +1484,9 @@ not_drop:
45 if (skb)
46 dev_kfree_skb_any (skb);
47 if (urb) {
48 +#if LINUX_VERSION_IS_GEQ(3,35,0)
49 kfree(urb->sg);
50 +#endif
51 usb_free_urb(urb);
52 }
53 } else
54 @@ -1523,7 +1539,9 @@ static void usbnet_bh (unsigned long par
55 rx_process (dev, skb);
56 continue;
57 case tx_done:
58 +#if LINUX_VERSION_IS_GEQ(3,35,0)
59 kfree(entry->urb->sg);
60 +#endif
61 case rx_cleanup:
62 usb_free_urb (entry->urb);
63 dev_kfree_skb (skb);
64 @@ -1892,7 +1910,9 @@ int usbnet_resume (struct usb_interface
65 retval = usb_submit_urb(res, GFP_ATOMIC);
66 if (retval < 0) {
67 dev_kfree_skb_any(skb);
68 +#if LINUX_VERSION_IS_GEQ(3,35,0)
69 kfree(res->sg);
70 +#endif
71 usb_free_urb(res);
72 usb_autopm_put_interface_async(dev->intf);
73 } else {