usbnet.c (467a3ca5cab64a16b5ec46ebb1895c84c280dcfe) usbnet.c (c7e12ead5f92413234b3d9f4f35ae56734decd21)
1/*
2 * USB Network driver infrastructure
3 * Copyright (C) 2000-2005 by David Brownell
4 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 166 unchanged lines hidden (view full) ---

175 }
176 for (i = tmp = 0; i < 6; i++, tmp += 2)
177 dev->net->dev_addr [i] =
178 (hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
179 return 0;
180}
181EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
182
1/*
2 * USB Network driver infrastructure
3 * Copyright (C) 2000-2005 by David Brownell
4 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 166 unchanged lines hidden (view full) ---

175 }
176 for (i = tmp = 0; i < 6; i++, tmp += 2)
177 dev->net->dev_addr [i] =
178 (hex_to_bin(buf[tmp]) << 4) + hex_to_bin(buf[tmp + 1]);
179 return 0;
180}
181EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
182
183static void intr_complete (struct urb *urb);
183static void intr_complete (struct urb *urb)
184{
185 struct usbnet *dev = urb->context;
186 int status = urb->status;
184
187
188 switch (status) {
189 /* success */
190 case 0:
191 dev->driver_info->status(dev, urb);
192 break;
193
194 /* software-driven interface shutdown */
195 case -ENOENT: /* urb killed */
196 case -ESHUTDOWN: /* hardware gone */
197 netif_dbg(dev, ifdown, dev->net,
198 "intr shutdown, code %d\n", status);
199 return;
200
201 /* NOTE: not throttling like RX/TX, since this endpoint
202 * already polls infrequently
203 */
204 default:
205 netdev_dbg(dev->net, "intr status %d\n", status);
206 break;
207 }
208
209 if (!netif_running (dev->net))
210 return;
211
212 status = usb_submit_urb (urb, GFP_ATOMIC);
213 if (status != 0)
214 netif_err(dev, timer, dev->net,
215 "intr resubmit --> %d\n", status);
216}
217
185static int init_status (struct usbnet *dev, struct usb_interface *intf)
186{
187 char *buf = NULL;
188 unsigned pipe = 0;
189 unsigned maxp;
190 unsigned period;
191
192 if (!dev->driver_info->status)

--- 321 unchanged lines hidden (view full) ---

514 usb_mark_last_busy(dev->udev);
515 return;
516 }
517 usb_free_urb (urb);
518 }
519 netif_dbg(dev, rx_err, dev->net, "no read resubmitted\n");
520}
521
218static int init_status (struct usbnet *dev, struct usb_interface *intf)
219{
220 char *buf = NULL;
221 unsigned pipe = 0;
222 unsigned maxp;
223 unsigned period;
224
225 if (!dev->driver_info->status)

--- 321 unchanged lines hidden (view full) ---

547 usb_mark_last_busy(dev->udev);
548 return;
549 }
550 usb_free_urb (urb);
551 }
552 netif_dbg(dev, rx_err, dev->net, "no read resubmitted\n");
553}
554
522static void intr_complete (struct urb *urb)
523{
524 struct usbnet *dev = urb->context;
525 int status = urb->status;
526
527 switch (status) {
528 /* success */
529 case 0:
530 dev->driver_info->status(dev, urb);
531 break;
532
533 /* software-driven interface shutdown */
534 case -ENOENT: /* urb killed */
535 case -ESHUTDOWN: /* hardware gone */
536 netif_dbg(dev, ifdown, dev->net,
537 "intr shutdown, code %d\n", status);
538 return;
539
540 /* NOTE: not throttling like RX/TX, since this endpoint
541 * already polls infrequently
542 */
543 default:
544 netdev_dbg(dev->net, "intr status %d\n", status);
545 break;
546 }
547
548 if (!netif_running (dev->net))
549 return;
550
551 memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
552 status = usb_submit_urb (urb, GFP_ATOMIC);
553 if (status != 0)
554 netif_err(dev, timer, dev->net,
555 "intr resubmit --> %d\n", status);
556}
557
558/*-------------------------------------------------------------------------*/
559void usbnet_pause_rx(struct usbnet *dev)
560{
561 set_bit(EVENT_RX_PAUSED, &dev->flags);
562
563 netif_dbg(dev, rx_status, dev->net, "paused rx queue enabled\n");
564}
565EXPORT_SYMBOL_GPL(usbnet_pause_rx);

--- 741 unchanged lines hidden (view full) ---

1307
1308 if (dev->driver_info->unbind)
1309 dev->driver_info->unbind (dev, intf);
1310
1311 usb_kill_urb(dev->interrupt);
1312 usb_free_urb(dev->interrupt);
1313
1314 free_netdev(net);
555/*-------------------------------------------------------------------------*/
556void usbnet_pause_rx(struct usbnet *dev)
557{
558 set_bit(EVENT_RX_PAUSED, &dev->flags);
559
560 netif_dbg(dev, rx_status, dev->net, "paused rx queue enabled\n");
561}
562EXPORT_SYMBOL_GPL(usbnet_pause_rx);

--- 741 unchanged lines hidden (view full) ---

1304
1305 if (dev->driver_info->unbind)
1306 dev->driver_info->unbind (dev, intf);
1307
1308 usb_kill_urb(dev->interrupt);
1309 usb_free_urb(dev->interrupt);
1310
1311 free_netdev(net);
1315 usb_put_dev (xdev);
1316}
1317EXPORT_SYMBOL_GPL(usbnet_disconnect);
1318
1319static const struct net_device_ops usbnet_netdev_ops = {
1320 .ndo_open = usbnet_open,
1321 .ndo_stop = usbnet_stop,
1322 .ndo_start_xmit = usbnet_start_xmit,
1323 .ndo_tx_timeout = usbnet_tx_timeout,

--- 39 unchanged lines hidden (view full) ---

1363 info = (struct driver_info *) prod->driver_info;
1364 if (!info) {
1365 dev_dbg (&udev->dev, "blacklisted by %s\n", name);
1366 return -ENODEV;
1367 }
1368 xdev = interface_to_usbdev (udev);
1369 interface = udev->cur_altsetting;
1370
1312}
1313EXPORT_SYMBOL_GPL(usbnet_disconnect);
1314
1315static const struct net_device_ops usbnet_netdev_ops = {
1316 .ndo_open = usbnet_open,
1317 .ndo_stop = usbnet_stop,
1318 .ndo_start_xmit = usbnet_start_xmit,
1319 .ndo_tx_timeout = usbnet_tx_timeout,

--- 39 unchanged lines hidden (view full) ---

1359 info = (struct driver_info *) prod->driver_info;
1360 if (!info) {
1361 dev_dbg (&udev->dev, "blacklisted by %s\n", name);
1362 return -ENODEV;
1363 }
1364 xdev = interface_to_usbdev (udev);
1365 interface = udev->cur_altsetting;
1366
1371 usb_get_dev (xdev);
1372
1373 status = -ENOMEM;
1374
1375 // set up our own records
1376 net = alloc_etherdev(sizeof(*dev));
1377 if (!net)
1378 goto out;
1379
1380 /* netdev_printk() needs this so do it as early as possible */

--- 112 unchanged lines hidden (view full) ---

1493out4:
1494 usb_free_urb(dev->interrupt);
1495out3:
1496 if (info->unbind)
1497 info->unbind (dev, udev);
1498out1:
1499 free_netdev(net);
1500out:
1367 status = -ENOMEM;
1368
1369 // set up our own records
1370 net = alloc_etherdev(sizeof(*dev));
1371 if (!net)
1372 goto out;
1373
1374 /* netdev_printk() needs this so do it as early as possible */

--- 112 unchanged lines hidden (view full) ---

1487out4:
1488 usb_free_urb(dev->interrupt);
1489out3:
1490 if (info->unbind)
1491 info->unbind (dev, udev);
1492out1:
1493 free_netdev(net);
1494out:
1501 usb_put_dev(xdev);
1502 return status;
1503}
1504EXPORT_SYMBOL_GPL(usbnet_probe);
1505
1506/*-------------------------------------------------------------------------*/
1507
1508/*
1509 * suspend the whole driver as soon as the first interface is suspended

--- 85 unchanged lines hidden (view full) ---

1595/*-------------------------------------------------------------------------*/
1596
1597static int __init usbnet_init(void)
1598{
1599 /* Compiler should optimize this out. */
1600 BUILD_BUG_ON(
1601 FIELD_SIZEOF(struct sk_buff, cb) < sizeof(struct skb_data));
1602
1495 return status;
1496}
1497EXPORT_SYMBOL_GPL(usbnet_probe);
1498
1499/*-------------------------------------------------------------------------*/
1500
1501/*
1502 * suspend the whole driver as soon as the first interface is suspended

--- 85 unchanged lines hidden (view full) ---

1588/*-------------------------------------------------------------------------*/
1589
1590static int __init usbnet_init(void)
1591{
1592 /* Compiler should optimize this out. */
1593 BUILD_BUG_ON(
1594 FIELD_SIZEOF(struct sk_buff, cb) < sizeof(struct skb_data));
1595
1603 random_ether_addr(node_id);
1596 eth_random_addr(node_id);
1604 return 0;
1605}
1606module_init(usbnet_init);
1607
1608static void __exit usbnet_exit(void)
1609{
1610}
1611module_exit(usbnet_exit);
1612
1613MODULE_AUTHOR("David Brownell");
1614MODULE_DESCRIPTION("USB network driver framework");
1615MODULE_LICENSE("GPL");
1597 return 0;
1598}
1599module_init(usbnet_init);
1600
1601static void __exit usbnet_exit(void)
1602{
1603}
1604module_exit(usbnet_exit);
1605
1606MODULE_AUTHOR("David Brownell");
1607MODULE_DESCRIPTION("USB network driver framework");
1608MODULE_LICENSE("GPL");