OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | --- a/drivers/net/usb/ipheth.c 2018-08-16 00:14:55.000000000 +0800 |
2 | +++ b/drivers/net/usb/ipheth.c 2019-02-26 15:21:16.600320776 +0800 |
||
3 | @@ -87,7 +87,7 @@ |
||
4 | #define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ) |
||
5 | #define IPHETH_CARRIER_ON 0x04 |
||
6 | |||
7 | -static struct usb_device_id ipheth_table[] = { |
||
8 | +static const struct usb_device_id ipheth_table[] = { |
||
9 | { USB_DEVICE_AND_INTERFACE_INFO( |
||
10 | USB_VENDOR_APPLE, USB_PRODUCT_IPHONE, |
||
11 | IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, |
||
12 | @@ -149,6 +149,7 @@ struct ipheth_device { |
||
13 | u8 bulk_in; |
||
14 | u8 bulk_out; |
||
15 | struct delayed_work carrier_work; |
||
16 | + bool confirmed_pairing; |
||
17 | }; |
||
18 | |||
19 | static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags); |
||
20 | @@ -253,13 +254,13 @@ static void ipheth_rcvbulk_callback(stru |
||
21 | return; |
||
22 | } |
||
23 | |||
24 | - memcpy(skb_put(skb, len), buf, len); |
||
25 | + __skb_put_data(skb, buf, len); |
||
26 | skb->dev = dev->net; |
||
27 | skb->protocol = eth_type_trans(skb, dev->net); |
||
28 | |||
29 | dev->net->stats.rx_packets++; |
||
30 | dev->net->stats.rx_bytes += len; |
||
31 | - |
||
32 | + dev->confirmed_pairing = true; |
||
33 | netif_rx(skb); |
||
34 | ipheth_rx_submit(dev, GFP_ATOMIC); |
||
35 | } |
||
36 | @@ -281,14 +282,24 @@ static void ipheth_sndbulk_callback(stru |
||
37 | __func__, status); |
||
38 | |||
39 | dev_kfree_skb_irq(dev->tx_skb); |
||
40 | - netif_wake_queue(dev->net); |
||
41 | + if (status == 0) |
||
42 | + netif_wake_queue(dev->net); |
||
43 | + else |
||
44 | + // on URB error, trigger immediate poll |
||
45 | + schedule_delayed_work(&dev->carrier_work, 0); |
||
46 | } |
||
47 | |||
48 | static int ipheth_carrier_set(struct ipheth_device *dev) |
||
49 | { |
||
50 | - struct usb_device *udev = dev->udev; |
||
51 | + struct usb_device *udev; |
||
52 | int retval; |
||
53 | |||
54 | + if (!dev) |
||
55 | + return 0; |
||
56 | + if (!dev->confirmed_pairing) |
||
57 | + return 0; |
||
58 | + |
||
59 | + udev = dev->udev; |
||
60 | retval = usb_control_msg(udev, |
||
61 | usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), |
||
62 | IPHETH_CMD_CARRIER_CHECK, /* request */ |
||
63 | @@ -303,11 +314,14 @@ static int ipheth_carrier_set(struct iph |
||
64 | return retval; |
||
65 | } |
||
66 | |||
67 | - if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) |
||
68 | + if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) { |
||
69 | netif_carrier_on(dev->net); |
||
70 | - else |
||
71 | + if (dev->tx_urb->status != -EINPROGRESS) |
||
72 | + netif_wake_queue(dev->net); |
||
73 | + } else { |
||
74 | netif_carrier_off(dev->net); |
||
75 | - |
||
76 | + netif_stop_queue(dev->net); |
||
77 | + } |
||
78 | return 0; |
||
79 | } |
||
80 | |||
81 | @@ -387,7 +401,6 @@ static int ipheth_open(struct net_device |
||
82 | return retval; |
||
83 | |||
84 | schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); |
||
85 | - netif_start_queue(net); |
||
86 | return retval; |
||
87 | } |
||
88 | |||
89 | @@ -491,7 +504,7 @@ static int ipheth_probe(struct usb_inter |
||
90 | dev->udev = udev; |
||
91 | dev->net = netdev; |
||
92 | dev->intf = intf; |
||
93 | - |
||
94 | + dev->confirmed_pairing = false; |
||
95 | /* Set up endpoints */ |
||
96 | hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); |
||
97 | if (hintf == NULL) { |
||
98 | @@ -542,7 +555,9 @@ static int ipheth_probe(struct usb_inter |
||
99 | retval = -EIO; |
||
100 | goto err_register_netdev; |
||
101 | } |
||
102 | - |
||
103 | + // carrier down and transmit queues stopped until packet from device |
||
104 | + netif_carrier_off(netdev); |
||
105 | + netif_tx_stop_all_queues(netdev); |
||
106 | dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n"); |
||
107 | return 0; |
||
108 | |||
109 | @@ -585,4 +600,4 @@ module_usb_driver(ipheth_driver); |
||
110 | |||
111 | MODULE_AUTHOR("Diego Giagio <diego@giagio.com>"); |
||
112 | MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver"); |
||
113 | -MODULE_LICENSE("Dual BSD/GPL"); |
||
114 | +MODULE_LICENSE("Dual BSD/GPL"); |
||
115 | --- a/include/linux/skbuff.h 2019-02-26 16:00:21.771797316 +0800 |
||
116 | +++ b/include/linux/skbuff.h 2019-02-26 16:01:22.288908959 +0800 |
||
117 | @@ -1922,6 +1922,15 @@ static inline unsigned char *__skb_put(s |
||
118 | return tmp; |
||
119 | } |
||
120 | |||
121 | +static inline void *__skb_put_data(struct sk_buff *skb, const void *data, |
||
122 | + unsigned int len) |
||
123 | +{ |
||
124 | + void *tmp = __skb_put(skb, len); |
||
125 | + |
||
126 | + memcpy(tmp, data, len); |
||
127 | + return tmp; |
||
128 | +} |
||
129 | + |
||
130 | unsigned char *skb_push(struct sk_buff *skb, unsigned int len); |
||
131 | static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len) |
||
132 | { |