ipheth.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * ipheth.c - Apple iPhone USB Ethernet driver
  3. *
  4. * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of GIAGIO.COM nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * Alternatively, provided that this notice is retained in full, this
  20. * software may be distributed under the terms of the GNU General
  21. * Public License ("GPL") version 2, in which case the provisions of the
  22. * GPL apply INSTEAD OF those given above.
  23. *
  24. * The provided data structures and external interfaces from this code
  25. * are not restricted to be used by modules with a GPL compatible license.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  30. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  31. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  34. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  35. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  36. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  37. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  38. * DAMAGE.
  39. *
  40. *
  41. * Attention: iPhone device must be paired, otherwise it won't respond to our
  42. * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
  43. *
  44. */
  45. #include <linux/kernel.h>
  46. #include <linux/errno.h>
  47. #include <linux/init.h>
  48. #include <linux/slab.h>
  49. #include <linux/module.h>
  50. #include <linux/netdevice.h>
  51. #include <linux/etherdevice.h>
  52. #include <linux/ethtool.h>
  53. #include <linux/usb.h>
  54. #include <linux/workqueue.h>
  55. #define USB_VENDOR_APPLE 0x05ac
  56. #define USB_PRODUCT_IPHONE 0x1290
  57. #define USB_PRODUCT_IPHONE_3G 0x1292
  58. #define USB_PRODUCT_IPHONE_3GS 0x1294
  59. #define USB_PRODUCT_IPHONE_4 0x1297
  60. #define USB_PRODUCT_IPAD 0x129a
  61. #define USB_PRODUCT_IPAD_MINI 0x12ab
  62. #define USB_PRODUCT_IPHONE_4_VZW 0x129c
  63. #define USB_PRODUCT_IPHONE_4S 0x12a0
  64. #define USB_PRODUCT_IPHONE_5 0x12a8
  65. #define IPHETH_USBINTF_CLASS 255
  66. #define IPHETH_USBINTF_SUBCLASS 253
  67. #define IPHETH_USBINTF_PROTO 1
  68. #define IPHETH_BUF_SIZE 1516
  69. #define IPHETH_IP_ALIGN 2 /* padding at front of URB */
  70. #define IPHETH_TX_TIMEOUT (5 * HZ)
  71. #define IPHETH_INTFNUM 2
  72. #define IPHETH_ALT_INTFNUM 1
  73. #define IPHETH_CTRL_ENDP 0x00
  74. #define IPHETH_CTRL_BUF_SIZE 0x40
  75. #define IPHETH_CTRL_TIMEOUT (5 * HZ)
  76. #define IPHETH_CMD_GET_MACADDR 0x00
  77. #define IPHETH_CMD_CARRIER_CHECK 0x45
  78. #define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ)
  79. #define IPHETH_CARRIER_ON 0x04
  80. static struct usb_device_id ipheth_table[] = {
  81. { USB_DEVICE_AND_INTERFACE_INFO(
  82. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
  83. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  84. IPHETH_USBINTF_PROTO) },
  85. { USB_DEVICE_AND_INTERFACE_INFO(
  86. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
  87. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  88. IPHETH_USBINTF_PROTO) },
  89. { USB_DEVICE_AND_INTERFACE_INFO(
  90. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
  91. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  92. IPHETH_USBINTF_PROTO) },
  93. { USB_DEVICE_AND_INTERFACE_INFO(
  94. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4,
  95. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  96. IPHETH_USBINTF_PROTO) },
  97. { USB_DEVICE_AND_INTERFACE_INFO(
  98. USB_VENDOR_APPLE, USB_PRODUCT_IPAD,
  99. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  100. IPHETH_USBINTF_PROTO) },
  101. { USB_DEVICE_AND_INTERFACE_INFO(
  102. USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI,
  103. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  104. IPHETH_USBINTF_PROTO) },
  105. { USB_DEVICE_AND_INTERFACE_INFO(
  106. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
  107. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  108. IPHETH_USBINTF_PROTO) },
  109. { USB_DEVICE_AND_INTERFACE_INFO(
  110. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
  111. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  112. IPHETH_USBINTF_PROTO) },
  113. { USB_DEVICE_AND_INTERFACE_INFO(
  114. USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
  115. IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
  116. IPHETH_USBINTF_PROTO) },
  117. { }
  118. };
  119. MODULE_DEVICE_TABLE(usb, ipheth_table);
  120. struct ipheth_device {
  121. struct usb_device *udev;
  122. struct usb_interface *intf;
  123. struct net_device *net;
  124. struct sk_buff *tx_skb;
  125. struct urb *tx_urb;
  126. struct urb *rx_urb;
  127. unsigned char *tx_buf;
  128. unsigned char *rx_buf;
  129. unsigned char *ctrl_buf;
  130. u8 bulk_in;
  131. u8 bulk_out;
  132. struct delayed_work carrier_work;
  133. };
  134. static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags);
  135. static int ipheth_alloc_urbs(struct ipheth_device *iphone)
  136. {
  137. struct urb *tx_urb = NULL;
  138. struct urb *rx_urb = NULL;
  139. u8 *tx_buf = NULL;
  140. u8 *rx_buf = NULL;
  141. tx_urb = usb_alloc_urb(0, GFP_KERNEL);
  142. if (tx_urb == NULL)
  143. goto error_nomem;
  144. rx_urb = usb_alloc_urb(0, GFP_KERNEL);
  145. if (rx_urb == NULL)
  146. goto free_tx_urb;
  147. tx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE,
  148. GFP_KERNEL, &tx_urb->transfer_dma);
  149. if (tx_buf == NULL)
  150. goto free_rx_urb;
  151. rx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE,
  152. GFP_KERNEL, &rx_urb->transfer_dma);
  153. if (rx_buf == NULL)
  154. goto free_tx_buf;
  155. iphone->tx_urb = tx_urb;
  156. iphone->rx_urb = rx_urb;
  157. iphone->tx_buf = tx_buf;
  158. iphone->rx_buf = rx_buf;
  159. return 0;
  160. free_tx_buf:
  161. usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
  162. tx_urb->transfer_dma);
  163. free_rx_urb:
  164. usb_free_urb(rx_urb);
  165. free_tx_urb:
  166. usb_free_urb(tx_urb);
  167. error_nomem:
  168. return -ENOMEM;
  169. }
  170. static void ipheth_free_urbs(struct ipheth_device *iphone)
  171. {
  172. usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf,
  173. iphone->rx_urb->transfer_dma);
  174. usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf,
  175. iphone->tx_urb->transfer_dma);
  176. usb_free_urb(iphone->rx_urb);
  177. usb_free_urb(iphone->tx_urb);
  178. }
  179. static void ipheth_kill_urbs(struct ipheth_device *dev)
  180. {
  181. usb_kill_urb(dev->tx_urb);
  182. usb_kill_urb(dev->rx_urb);
  183. }
  184. static void ipheth_rcvbulk_callback(struct urb *urb)
  185. {
  186. struct ipheth_device *dev;
  187. struct sk_buff *skb;
  188. int status;
  189. char *buf;
  190. int len;
  191. dev = urb->context;
  192. if (dev == NULL)
  193. return;
  194. status = urb->status;
  195. switch (status) {
  196. case -ENOENT:
  197. case -ECONNRESET:
  198. case -ESHUTDOWN:
  199. return;
  200. case 0:
  201. break;
  202. default:
  203. dev_err(&dev->intf->dev, "%s: urb status: %d\n",
  204. __func__, status);
  205. return;
  206. }
  207. if (urb->actual_length <= IPHETH_IP_ALIGN) {
  208. dev->net->stats.rx_length_errors++;
  209. return;
  210. }
  211. len = urb->actual_length - IPHETH_IP_ALIGN;
  212. buf = urb->transfer_buffer + IPHETH_IP_ALIGN;
  213. skb = dev_alloc_skb(len);
  214. if (!skb) {
  215. dev_err(&dev->intf->dev, "%s: dev_alloc_skb: -ENOMEM\n",
  216. __func__);
  217. dev->net->stats.rx_dropped++;
  218. return;
  219. }
  220. memcpy(skb_put(skb, len), buf, len);
  221. skb->dev = dev->net;
  222. skb->protocol = eth_type_trans(skb, dev->net);
  223. dev->net->stats.rx_packets++;
  224. dev->net->stats.rx_bytes += len;
  225. netif_rx(skb);
  226. ipheth_rx_submit(dev, GFP_ATOMIC);
  227. }
  228. static void ipheth_sndbulk_callback(struct urb *urb)
  229. {
  230. struct ipheth_device *dev;
  231. int status = urb->status;
  232. dev = urb->context;
  233. if (dev == NULL)
  234. return;
  235. if (status != 0 &&
  236. status != -ENOENT &&
  237. status != -ECONNRESET &&
  238. status != -ESHUTDOWN)
  239. dev_err(&dev->intf->dev, "%s: urb status: %d\n",
  240. __func__, status);
  241. dev_kfree_skb_irq(dev->tx_skb);
  242. netif_wake_queue(dev->net);
  243. }
  244. static int ipheth_carrier_set(struct ipheth_device *dev)
  245. {
  246. struct usb_device *udev = dev->udev;
  247. int retval;
  248. retval = usb_control_msg(udev,
  249. usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
  250. IPHETH_CMD_CARRIER_CHECK, /* request */
  251. 0xc0, /* request type */
  252. 0x00, /* value */
  253. 0x02, /* index */
  254. dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE,
  255. IPHETH_CTRL_TIMEOUT);
  256. if (retval < 0) {
  257. dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n",
  258. __func__, retval);
  259. return retval;
  260. }
  261. if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON)
  262. netif_carrier_on(dev->net);
  263. else
  264. netif_carrier_off(dev->net);
  265. return 0;
  266. }
  267. static void ipheth_carrier_check_work(struct work_struct *work)
  268. {
  269. struct ipheth_device *dev = container_of(work, struct ipheth_device,
  270. carrier_work.work);
  271. ipheth_carrier_set(dev);
  272. schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
  273. }
  274. static int ipheth_get_macaddr(struct ipheth_device *dev)
  275. {
  276. struct usb_device *udev = dev->udev;
  277. struct net_device *net = dev->net;
  278. int retval;
  279. retval = usb_control_msg(udev,
  280. usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
  281. IPHETH_CMD_GET_MACADDR, /* request */
  282. 0xc0, /* request type */
  283. 0x00, /* value */
  284. 0x02, /* index */
  285. dev->ctrl_buf,
  286. IPHETH_CTRL_BUF_SIZE,
  287. IPHETH_CTRL_TIMEOUT);
  288. if (retval < 0) {
  289. dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n",
  290. __func__, retval);
  291. } else if (retval < ETH_ALEN) {
  292. dev_err(&dev->intf->dev,
  293. "%s: usb_control_msg: short packet: %d bytes\n",
  294. __func__, retval);
  295. retval = -EINVAL;
  296. } else {
  297. memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN);
  298. retval = 0;
  299. }
  300. return retval;
  301. }
  302. static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags)
  303. {
  304. struct usb_device *udev = dev->udev;
  305. int retval;
  306. usb_fill_bulk_urb(dev->rx_urb, udev,
  307. usb_rcvbulkpipe(udev, dev->bulk_in),
  308. dev->rx_buf, IPHETH_BUF_SIZE,
  309. ipheth_rcvbulk_callback,
  310. dev);
  311. dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  312. retval = usb_submit_urb(dev->rx_urb, mem_flags);
  313. if (retval)
  314. dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n",
  315. __func__, retval);
  316. return retval;
  317. }
  318. static int ipheth_open(struct net_device *net)
  319. {
  320. struct ipheth_device *dev = netdev_priv(net);
  321. struct usb_device *udev = dev->udev;
  322. int retval = 0;
  323. usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM);
  324. retval = ipheth_carrier_set(dev);
  325. if (retval)
  326. return retval;
  327. retval = ipheth_rx_submit(dev, GFP_KERNEL);
  328. if (retval)
  329. return retval;
  330. schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
  331. netif_start_queue(net);
  332. return retval;
  333. }
  334. static int ipheth_close(struct net_device *net)
  335. {
  336. struct ipheth_device *dev = netdev_priv(net);
  337. cancel_delayed_work_sync(&dev->carrier_work);
  338. netif_stop_queue(net);
  339. return 0;
  340. }
  341. static int ipheth_tx(struct sk_buff *skb, struct net_device *net)
  342. {
  343. struct ipheth_device *dev = netdev_priv(net);
  344. struct usb_device *udev = dev->udev;
  345. int retval;
  346. /* Paranoid */
  347. if (skb->len > IPHETH_BUF_SIZE) {
  348. WARN(1, "%s: skb too large: %d bytes\n", __func__, skb->len);
  349. dev->net->stats.tx_dropped++;
  350. dev_kfree_skb_irq(skb);
  351. return NETDEV_TX_OK;
  352. }
  353. memcpy(dev->tx_buf, skb->data, skb->len);
  354. if (skb->len < IPHETH_BUF_SIZE)
  355. memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len);
  356. usb_fill_bulk_urb(dev->tx_urb, udev,
  357. usb_sndbulkpipe(udev, dev->bulk_out),
  358. dev->tx_buf, IPHETH_BUF_SIZE,
  359. ipheth_sndbulk_callback,
  360. dev);
  361. dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  362. retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC);
  363. if (retval) {
  364. dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n",
  365. __func__, retval);
  366. dev->net->stats.tx_errors++;
  367. dev_kfree_skb_irq(skb);
  368. } else {
  369. dev->tx_skb = skb;
  370. dev->net->stats.tx_packets++;
  371. dev->net->stats.tx_bytes += skb->len;
  372. netif_stop_queue(net);
  373. }
  374. return NETDEV_TX_OK;
  375. }
  376. static void ipheth_tx_timeout(struct net_device *net)
  377. {
  378. struct ipheth_device *dev = netdev_priv(net);
  379. dev_err(&dev->intf->dev, "%s: TX timeout\n", __func__);
  380. dev->net->stats.tx_errors++;
  381. usb_unlink_urb(dev->tx_urb);
  382. }
  383. static u32 ipheth_ethtool_op_get_link(struct net_device *net)
  384. {
  385. struct ipheth_device *dev = netdev_priv(net);
  386. return netif_carrier_ok(dev->net);
  387. }
  388. static const struct ethtool_ops ops = {
  389. .get_link = ipheth_ethtool_op_get_link
  390. };
  391. static const struct net_device_ops ipheth_netdev_ops = {
  392. .ndo_open = ipheth_open,
  393. .ndo_stop = ipheth_close,
  394. .ndo_start_xmit = ipheth_tx,
  395. .ndo_tx_timeout = ipheth_tx_timeout,
  396. };
  397. static int ipheth_probe(struct usb_interface *intf,
  398. const struct usb_device_id *id)
  399. {
  400. struct usb_device *udev = interface_to_usbdev(intf);
  401. struct usb_host_interface *hintf;
  402. struct usb_endpoint_descriptor *endp;
  403. struct ipheth_device *dev;
  404. struct net_device *netdev;
  405. int i;
  406. int retval;
  407. netdev = alloc_etherdev(sizeof(struct ipheth_device));
  408. if (!netdev)
  409. return -ENOMEM;
  410. netdev->netdev_ops = &ipheth_netdev_ops;
  411. netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
  412. strcpy(netdev->name, "eth%d");
  413. dev = netdev_priv(netdev);
  414. dev->udev = udev;
  415. dev->net = netdev;
  416. dev->intf = intf;
  417. /* Set up endpoints */
  418. hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);
  419. if (hintf == NULL) {
  420. retval = -ENODEV;
  421. dev_err(&intf->dev, "Unable to find alternate settings interface\n");
  422. goto err_endpoints;
  423. }
  424. for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
  425. endp = &hintf->endpoint[i].desc;
  426. if (usb_endpoint_is_bulk_in(endp))
  427. dev->bulk_in = endp->bEndpointAddress;
  428. else if (usb_endpoint_is_bulk_out(endp))
  429. dev->bulk_out = endp->bEndpointAddress;
  430. }
  431. if (!(dev->bulk_in && dev->bulk_out)) {
  432. retval = -ENODEV;
  433. dev_err(&intf->dev, "Unable to find endpoints\n");
  434. goto err_endpoints;
  435. }
  436. dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
  437. if (dev->ctrl_buf == NULL) {
  438. retval = -ENOMEM;
  439. goto err_alloc_ctrl_buf;
  440. }
  441. retval = ipheth_get_macaddr(dev);
  442. if (retval)
  443. goto err_get_macaddr;
  444. INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);
  445. retval = ipheth_alloc_urbs(dev);
  446. if (retval) {
  447. dev_err(&intf->dev, "error allocating urbs: %d\n", retval);
  448. goto err_alloc_urbs;
  449. }
  450. usb_set_intfdata(intf, dev);
  451. SET_NETDEV_DEV(netdev, &intf->dev);
  452. SET_ETHTOOL_OPS(netdev, &ops);
  453. retval = register_netdev(netdev);
  454. if (retval) {
  455. dev_err(&intf->dev, "error registering netdev: %d\n", retval);
  456. retval = -EIO;
  457. goto err_register_netdev;
  458. }
  459. dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n");
  460. return 0;
  461. err_register_netdev:
  462. ipheth_free_urbs(dev);
  463. err_alloc_urbs:
  464. err_get_macaddr:
  465. err_alloc_ctrl_buf:
  466. kfree(dev->ctrl_buf);
  467. err_endpoints:
  468. free_netdev(netdev);
  469. return retval;
  470. }
  471. static void ipheth_disconnect(struct usb_interface *intf)
  472. {
  473. struct ipheth_device *dev;
  474. dev = usb_get_intfdata(intf);
  475. if (dev != NULL) {
  476. unregister_netdev(dev->net);
  477. ipheth_kill_urbs(dev);
  478. ipheth_free_urbs(dev);
  479. kfree(dev->ctrl_buf);
  480. free_netdev(dev->net);
  481. }
  482. usb_set_intfdata(intf, NULL);
  483. dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n");
  484. }
  485. static struct usb_driver ipheth_driver = {
  486. .name = "ipheth",
  487. .probe = ipheth_probe,
  488. .disconnect = ipheth_disconnect,
  489. .id_table = ipheth_table,
  490. .disable_hub_initiated_lpm = 1,
  491. };
  492. module_usb_driver(ipheth_driver);
  493. MODULE_AUTHOR("Diego Giagio <diego@giagio.com>");
  494. MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver");
  495. MODULE_LICENSE("Dual BSD/GPL");