aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
commitaecdc33e111b2c447b622e287c6003726daa1426 (patch)
tree3e7657eae4b785e1a1fb5dfb225dbae0b2f0cfc6 /drivers/net/usb
parenta20acf99f75e49271381d65db097c9763060a1e8 (diff)
parenta3a6cab5ea10cca64d036851fe0d932448f2fe4f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller: 1) GRE now works over ipv6, from Dmitry Kozlov. 2) Make SCTP more network namespace aware, from Eric Biederman. 3) TEAM driver now works with non-ethernet devices, from Jiri Pirko. 4) Make openvswitch network namespace aware, from Pravin B Shelar. 5) IPV6 NAT implementation, from Patrick McHardy. 6) Server side support for TCP Fast Open, from Jerry Chu and others. 7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel Borkmann. 8) Increate the loopback default MTU to 64K, from Eric Dumazet. 9) Use a per-task rather than per-socket page fragment allocator for outgoing networking traffic. This benefits processes that have very many mostly idle sockets, which is quite common. From Eric Dumazet. 10) Use up to 32K for page fragment allocations, with fallbacks to smaller sizes when higher order page allocations fail. Benefits are a) less segments for driver to process b) less calls to page allocator c) less waste of space. From Eric Dumazet. 11) Allow GRO to be used on GRE tunnels, from Eric Dumazet. 12) VXLAN device driver, one way to handle VLAN issues such as the limitation of 4096 VLAN IDs yet still have some level of isolation. From Stephen Hemminger. 13) As usual there is a large boatload of driver changes, with the scale perhaps tilted towards the wireless side this time around. Fix up various fairly trivial conflicts, mostly caused by the user namespace changes. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits) hyperv: Add buffer for extended info after the RNDIS response message. hyperv: Report actual status in receive completion packet hyperv: Remove extra allocated space for recv_pkt_list elements hyperv: Fix page buffer handling in rndis_filter_send_request() hyperv: Fix the missing return value in rndis_filter_set_packet_filter() hyperv: Fix the max_xfer_size in RNDIS initialization vxlan: put UDP socket in correct namespace vxlan: Depend on CONFIG_INET sfc: Fix the reported priorities of different filter types sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP sfc: Fix loopback self-test with separate_tx_channels=1 sfc: Fix MCDI structure field lookup sfc: Add parentheses around use of bitfield macro arguments sfc: Fix null function pointer in efx_sriov_channel_type vxlan: virtual extensible lan igmp: export symbol ip_mc_leave_group netlink: add attributes to fdb interface tg3: unconditionally select HWMON support when tg3 is enabled. Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT" gre: fix sparse warning ...
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/asix_devices.c40
-rw-r--r--drivers/net/usb/catc.c55
-rw-r--r--drivers/net/usb/cx82310_eth.c11
-rw-r--r--drivers/net/usb/gl620a.c10
-rw-r--r--drivers/net/usb/kaweth.c134
-rw-r--r--drivers/net/usb/net1080.c51
-rw-r--r--drivers/net/usb/qmi_wwan.c47
-rw-r--r--drivers/net/usb/rtl8150.c6
-rw-r--r--drivers/net/usb/sierra_net.c25
-rw-r--r--drivers/net/usb/smsc75xx.c240
-rw-r--r--drivers/net/usb/smsc95xx.c560
-rw-r--r--drivers/net/usb/smsc95xx.h12
12 files changed, 785 insertions, 406 deletions
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 32e31c5c5dc..33ab824773c 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -221,7 +221,8 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
221 /* Get the MAC address */ 221 /* Get the MAC address */
222 ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 222 ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
223 if (ret < 0) { 223 if (ret < 0) {
224 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); 224 netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n",
225 ret);
225 goto out; 226 goto out;
226 } 227 }
227 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 228 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@@ -303,7 +304,7 @@ static int ax88772_reset(struct usbnet *dev)
303 304
304 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); 305 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
305 if (ret < 0) { 306 if (ret < 0) {
306 dbg("Select PHY #1 failed: %d", ret); 307 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
307 goto out; 308 goto out;
308 } 309 }
309 310
@@ -331,13 +332,13 @@ static int ax88772_reset(struct usbnet *dev)
331 332
332 msleep(150); 333 msleep(150);
333 rx_ctl = asix_read_rx_ctl(dev); 334 rx_ctl = asix_read_rx_ctl(dev);
334 dbg("RX_CTL is 0x%04x after software reset", rx_ctl); 335 netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
335 ret = asix_write_rx_ctl(dev, 0x0000); 336 ret = asix_write_rx_ctl(dev, 0x0000);
336 if (ret < 0) 337 if (ret < 0)
337 goto out; 338 goto out;
338 339
339 rx_ctl = asix_read_rx_ctl(dev); 340 rx_ctl = asix_read_rx_ctl(dev);
340 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl); 341 netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
341 342
342 ret = asix_sw_reset(dev, AX_SWRESET_PRL); 343 ret = asix_sw_reset(dev, AX_SWRESET_PRL);
343 if (ret < 0) 344 if (ret < 0)
@@ -364,7 +365,7 @@ static int ax88772_reset(struct usbnet *dev)
364 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 365 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
365 AX88772_IPG2_DEFAULT, 0, NULL); 366 AX88772_IPG2_DEFAULT, 0, NULL);
366 if (ret < 0) { 367 if (ret < 0) {
367 dbg("Write IPG,IPG1,IPG2 failed: %d", ret); 368 netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
368 goto out; 369 goto out;
369 } 370 }
370 371
@@ -381,10 +382,13 @@ static int ax88772_reset(struct usbnet *dev)
381 goto out; 382 goto out;
382 383
383 rx_ctl = asix_read_rx_ctl(dev); 384 rx_ctl = asix_read_rx_ctl(dev);
384 dbg("RX_CTL is 0x%04x after all initializations", rx_ctl); 385 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
386 rx_ctl);
385 387
386 rx_ctl = asix_read_medium_status(dev); 388 rx_ctl = asix_read_medium_status(dev);
387 dbg("Medium Status is 0x%04x after all initializations", rx_ctl); 389 netdev_dbg(dev->net,
390 "Medium Status is 0x%04x after all initializations\n",
391 rx_ctl);
388 392
389 return 0; 393 return 0;
390 394
@@ -416,7 +420,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
416 /* Get the MAC address */ 420 /* Get the MAC address */
417 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 421 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
418 if (ret < 0) { 422 if (ret < 0) {
419 dbg("Failed to read MAC address: %d", ret); 423 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
420 return ret; 424 return ret;
421 } 425 }
422 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 426 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@@ -439,7 +443,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
439 /* Reset the PHY to normal operation mode */ 443 /* Reset the PHY to normal operation mode */
440 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); 444 ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
441 if (ret < 0) { 445 if (ret < 0) {
442 dbg("Select PHY #1 failed: %d", ret); 446 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
443 return ret; 447 return ret;
444 } 448 }
445 449
@@ -459,7 +463,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
459 463
460 /* Read PHYID register *AFTER* the PHY was reset properly */ 464 /* Read PHYID register *AFTER* the PHY was reset properly */
461 phyid = asix_get_phyid(dev); 465 phyid = asix_get_phyid(dev);
462 dbg("PHYID=0x%08x", phyid); 466 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
463 467
464 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ 468 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
465 if (dev->driver_info->flags & FLAG_FRAMING_AX) { 469 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
@@ -575,13 +579,13 @@ static int ax88178_reset(struct usbnet *dev)
575 u32 phyid; 579 u32 phyid;
576 580
577 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status); 581 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status);
578 dbg("GPIO Status: 0x%04x", status); 582 netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status);
579 583
580 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL); 584 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
581 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom); 585 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
582 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL); 586 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);
583 587
584 dbg("EEPROM index 0x17 is 0x%04x", eeprom); 588 netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom);
585 589
586 if (eeprom == cpu_to_le16(0xffff)) { 590 if (eeprom == cpu_to_le16(0xffff)) {
587 data->phymode = PHY_MODE_MARVELL; 591 data->phymode = PHY_MODE_MARVELL;
@@ -592,7 +596,7 @@ static int ax88178_reset(struct usbnet *dev)
592 data->ledmode = le16_to_cpu(eeprom) >> 8; 596 data->ledmode = le16_to_cpu(eeprom) >> 8;
593 gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1; 597 gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
594 } 598 }
595 dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode); 599 netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode);
596 600
597 /* Power up external GigaPHY through AX88178 GPIO pin */ 601 /* Power up external GigaPHY through AX88178 GPIO pin */
598 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40); 602 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
@@ -601,14 +605,14 @@ static int ax88178_reset(struct usbnet *dev)
601 asix_write_gpio(dev, 0x001c, 300); 605 asix_write_gpio(dev, 0x001c, 300);
602 asix_write_gpio(dev, 0x003c, 30); 606 asix_write_gpio(dev, 0x003c, 30);
603 } else { 607 } else {
604 dbg("gpio phymode == 1 path"); 608 netdev_dbg(dev->net, "gpio phymode == 1 path\n");
605 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30); 609 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
606 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30); 610 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
607 } 611 }
608 612
609 /* Read PHYID register *AFTER* powering up PHY */ 613 /* Read PHYID register *AFTER* powering up PHY */
610 phyid = asix_get_phyid(dev); 614 phyid = asix_get_phyid(dev);
611 dbg("PHYID=0x%08x", phyid); 615 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
612 616
613 /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */ 617 /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */
614 asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL); 618 asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL);
@@ -770,7 +774,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
770 /* Get the MAC address */ 774 /* Get the MAC address */
771 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 775 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
772 if (ret < 0) { 776 if (ret < 0) {
773 dbg("Failed to read MAC address: %d", ret); 777 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
774 return ret; 778 return ret;
775 } 779 }
776 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 780 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
@@ -930,6 +934,10 @@ static const struct usb_device_id products [] = {
930 USB_DEVICE (0x04f1, 0x3008), 934 USB_DEVICE (0x04f1, 0x3008),
931 .driver_info = (unsigned long) &ax8817x_info, 935 .driver_info = (unsigned long) &ax8817x_info,
932}, { 936}, {
937 // Lenovo U2L100P 10/100
938 USB_DEVICE (0x17ef, 0x7203),
939 .driver_info = (unsigned long) &ax88772_info,
940}, {
933 // ASIX AX88772B 10/100 941 // ASIX AX88772B 10/100
934 USB_DEVICE (0x0b95, 0x772b), 942 USB_DEVICE (0x0b95, 0x772b),
935 .driver_info = (unsigned long) &ax88772_info, 943 .driver_info = (unsigned long) &ax88772_info,
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 26c5bebd9ec..18d9579123e 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -236,7 +236,8 @@ static void catc_rx_done(struct urb *urb)
236 } 236 }
237 237
238 if (status) { 238 if (status) {
239 dbg("rx_done, status %d, length %d", status, urb->actual_length); 239 dev_dbg(&urb->dev->dev, "rx_done, status %d, length %d\n",
240 status, urb->actual_length);
240 return; 241 return;
241 } 242 }
242 243
@@ -275,10 +276,11 @@ static void catc_rx_done(struct urb *urb)
275 if (atomic_read(&catc->recq_sz)) { 276 if (atomic_read(&catc->recq_sz)) {
276 int state; 277 int state;
277 atomic_dec(&catc->recq_sz); 278 atomic_dec(&catc->recq_sz);
278 dbg("getting extra packet"); 279 netdev_dbg(catc->netdev, "getting extra packet\n");
279 urb->dev = catc->usbdev; 280 urb->dev = catc->usbdev;
280 if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 281 if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
281 dbg("submit(rx_urb) status %d", state); 282 netdev_dbg(catc->netdev,
283 "submit(rx_urb) status %d\n", state);
282 } 284 }
283 } else { 285 } else {
284 clear_bit(RX_RUNNING, &catc->flags); 286 clear_bit(RX_RUNNING, &catc->flags);
@@ -317,18 +319,20 @@ static void catc_irq_done(struct urb *urb)
317 return; 319 return;
318 /* -EPIPE: should clear the halt */ 320 /* -EPIPE: should clear the halt */
319 default: /* error */ 321 default: /* error */
320 dbg("irq_done, status %d, data %02x %02x.", status, data[0], data[1]); 322 dev_dbg(&urb->dev->dev,
323 "irq_done, status %d, data %02x %02x.\n",
324 status, data[0], data[1]);
321 goto resubmit; 325 goto resubmit;
322 } 326 }
323 327
324 if (linksts == LinkGood) { 328 if (linksts == LinkGood) {
325 netif_carrier_on(catc->netdev); 329 netif_carrier_on(catc->netdev);
326 dbg("link ok"); 330 netdev_dbg(catc->netdev, "link ok\n");
327 } 331 }
328 332
329 if (linksts == LinkBad) { 333 if (linksts == LinkBad) {
330 netif_carrier_off(catc->netdev); 334 netif_carrier_off(catc->netdev);
331 dbg("link bad"); 335 netdev_dbg(catc->netdev, "link bad\n");
332 } 336 }
333 337
334 if (hasdata) { 338 if (hasdata) {
@@ -385,7 +389,7 @@ static void catc_tx_done(struct urb *urb)
385 int r, status = urb->status; 389 int r, status = urb->status;
386 390
387 if (status == -ECONNRESET) { 391 if (status == -ECONNRESET) {
388 dbg("Tx Reset."); 392 dev_dbg(&urb->dev->dev, "Tx Reset.\n");
389 urb->status = 0; 393 urb->status = 0;
390 catc->netdev->trans_start = jiffies; 394 catc->netdev->trans_start = jiffies;
391 catc->netdev->stats.tx_errors++; 395 catc->netdev->stats.tx_errors++;
@@ -395,7 +399,8 @@ static void catc_tx_done(struct urb *urb)
395 } 399 }
396 400
397 if (status) { 401 if (status) {
398 dbg("tx_done, status %d, length %d", status, urb->actual_length); 402 dev_dbg(&urb->dev->dev, "tx_done, status %d, length %d\n",
403 status, urb->actual_length);
399 return; 404 return;
400 } 405 }
401 406
@@ -511,7 +516,8 @@ static void catc_ctrl_done(struct urb *urb)
511 int status = urb->status; 516 int status = urb->status;
512 517
513 if (status) 518 if (status)
514 dbg("ctrl_done, status %d, len %d.", status, urb->actual_length); 519 dev_dbg(&urb->dev->dev, "ctrl_done, status %d, len %d.\n",
520 status, urb->actual_length);
515 521
516 spin_lock_irqsave(&catc->ctrl_lock, flags); 522 spin_lock_irqsave(&catc->ctrl_lock, flags);
517 523
@@ -667,7 +673,9 @@ static void catc_set_multicast_list(struct net_device *netdev)
667 f5u011_mchash_async(catc, catc->multicast); 673 f5u011_mchash_async(catc, catc->multicast);
668 if (catc->rxmode[0] != rx) { 674 if (catc->rxmode[0] != rx) {
669 catc->rxmode[0] = rx; 675 catc->rxmode[0] = rx;
670 dbg("Setting RX mode to %2.2X %2.2X", catc->rxmode[0], catc->rxmode[1]); 676 netdev_dbg(catc->netdev,
677 "Setting RX mode to %2.2X %2.2X\n",
678 catc->rxmode[0], catc->rxmode[1]);
671 f5u011_rxmode_async(catc, catc->rxmode); 679 f5u011_rxmode_async(catc, catc->rxmode);
672 } 680 }
673 } 681 }
@@ -766,6 +774,7 @@ static const struct net_device_ops catc_netdev_ops = {
766 774
767static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id) 775static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id)
768{ 776{
777 struct device *dev = &intf->dev;
769 struct usb_device *usbdev = interface_to_usbdev(intf); 778 struct usb_device *usbdev = interface_to_usbdev(intf);
770 struct net_device *netdev; 779 struct net_device *netdev;
771 struct catc *catc; 780 struct catc *catc;
@@ -774,7 +783,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
774 783
775 if (usb_set_interface(usbdev, 784 if (usb_set_interface(usbdev,
776 intf->altsetting->desc.bInterfaceNumber, 1)) { 785 intf->altsetting->desc.bInterfaceNumber, 1)) {
777 dev_err(&intf->dev, "Can't set altsetting 1.\n"); 786 dev_err(dev, "Can't set altsetting 1.\n");
778 return -EIO; 787 return -EIO;
779 } 788 }
780 789
@@ -817,7 +826,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
817 if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 && 826 if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 &&
818 le16_to_cpu(usbdev->descriptor.idProduct) == 0xa && 827 le16_to_cpu(usbdev->descriptor.idProduct) == 0xa &&
819 le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) { 828 le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) {
820 dbg("Testing for f5u011"); 829 dev_dbg(dev, "Testing for f5u011\n");
821 catc->is_f5u011 = 1; 830 catc->is_f5u011 = 1;
822 atomic_set(&catc->recq_sz, 0); 831 atomic_set(&catc->recq_sz, 0);
823 pktsz = RX_PKT_SZ; 832 pktsz = RX_PKT_SZ;
@@ -838,7 +847,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
838 catc->irq_buf, 2, catc_irq_done, catc, 1); 847 catc->irq_buf, 2, catc_irq_done, catc, 1);
839 848
840 if (!catc->is_f5u011) { 849 if (!catc->is_f5u011) {
841 dbg("Checking memory size\n"); 850 dev_dbg(dev, "Checking memory size\n");
842 851
843 i = 0x12345678; 852 i = 0x12345678;
844 catc_write_mem(catc, 0x7a80, &i, 4); 853 catc_write_mem(catc, 0x7a80, &i, 4);
@@ -850,7 +859,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
850 case 0x12345678: 859 case 0x12345678:
851 catc_set_reg(catc, TxBufCount, 8); 860 catc_set_reg(catc, TxBufCount, 8);
852 catc_set_reg(catc, RxBufCount, 32); 861 catc_set_reg(catc, RxBufCount, 32);
853 dbg("64k Memory\n"); 862 dev_dbg(dev, "64k Memory\n");
854 break; 863 break;
855 default: 864 default:
856 dev_warn(&intf->dev, 865 dev_warn(&intf->dev,
@@ -858,49 +867,49 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
858 case 0x87654321: 867 case 0x87654321:
859 catc_set_reg(catc, TxBufCount, 4); 868 catc_set_reg(catc, TxBufCount, 4);
860 catc_set_reg(catc, RxBufCount, 16); 869 catc_set_reg(catc, RxBufCount, 16);
861 dbg("32k Memory\n"); 870 dev_dbg(dev, "32k Memory\n");
862 break; 871 break;
863 } 872 }
864 873
865 dbg("Getting MAC from SEEROM."); 874 dev_dbg(dev, "Getting MAC from SEEROM.\n");
866 875
867 catc_get_mac(catc, netdev->dev_addr); 876 catc_get_mac(catc, netdev->dev_addr);
868 877
869 dbg("Setting MAC into registers."); 878 dev_dbg(dev, "Setting MAC into registers.\n");
870 879
871 for (i = 0; i < 6; i++) 880 for (i = 0; i < 6; i++)
872 catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]); 881 catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]);
873 882
874 dbg("Filling the multicast list."); 883 dev_dbg(dev, "Filling the multicast list.\n");
875 884
876 memset(broadcast, 0xff, 6); 885 memset(broadcast, 0xff, 6);
877 catc_multicast(broadcast, catc->multicast); 886 catc_multicast(broadcast, catc->multicast);
878 catc_multicast(netdev->dev_addr, catc->multicast); 887 catc_multicast(netdev->dev_addr, catc->multicast);
879 catc_write_mem(catc, 0xfa80, catc->multicast, 64); 888 catc_write_mem(catc, 0xfa80, catc->multicast, 64);
880 889
881 dbg("Clearing error counters."); 890 dev_dbg(dev, "Clearing error counters.\n");
882 891
883 for (i = 0; i < 8; i++) 892 for (i = 0; i < 8; i++)
884 catc_set_reg(catc, EthStats + i, 0); 893 catc_set_reg(catc, EthStats + i, 0);
885 catc->last_stats = jiffies; 894 catc->last_stats = jiffies;
886 895
887 dbg("Enabling."); 896 dev_dbg(dev, "Enabling.\n");
888 897
889 catc_set_reg(catc, MaxBurst, RX_MAX_BURST); 898 catc_set_reg(catc, MaxBurst, RX_MAX_BURST);
890 catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits); 899 catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits);
891 catc_set_reg(catc, LEDCtrl, LEDLink); 900 catc_set_reg(catc, LEDCtrl, LEDLink);
892 catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast); 901 catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast);
893 } else { 902 } else {
894 dbg("Performing reset\n"); 903 dev_dbg(dev, "Performing reset\n");
895 catc_reset(catc); 904 catc_reset(catc);
896 catc_get_mac(catc, netdev->dev_addr); 905 catc_get_mac(catc, netdev->dev_addr);
897 906
898 dbg("Setting RX Mode"); 907 dev_dbg(dev, "Setting RX Mode\n");
899 catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast; 908 catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast;
900 catc->rxmode[1] = 0; 909 catc->rxmode[1] = 0;
901 f5u011_rxmode(catc, catc->rxmode); 910 f5u011_rxmode(catc, catc->rxmode);
902 } 911 }
903 dbg("Init done."); 912 dev_dbg(dev, "Init done.\n");
904 printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n", 913 printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n",
905 netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate", 914 netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate",
906 usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr); 915 usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr);
diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c
index 49ab45e17fe..1e207f086b7 100644
--- a/drivers/net/usb/cx82310_eth.c
+++ b/drivers/net/usb/cx82310_eth.c
@@ -302,18 +302,9 @@ static const struct driver_info cx82310_info = {
302 .tx_fixup = cx82310_tx_fixup, 302 .tx_fixup = cx82310_tx_fixup,
303}; 303};
304 304
305#define USB_DEVICE_CLASS(vend, prod, cl, sc, pr) \
306 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
307 USB_DEVICE_ID_MATCH_DEV_INFO, \
308 .idVendor = (vend), \
309 .idProduct = (prod), \
310 .bDeviceClass = (cl), \
311 .bDeviceSubClass = (sc), \
312 .bDeviceProtocol = (pr)
313
314static const struct usb_device_id products[] = { 305static const struct usb_device_id products[] = {
315 { 306 {
316 USB_DEVICE_CLASS(0x0572, 0xcb01, 0xff, 0, 0), 307 USB_DEVICE_AND_INTERFACE_INFO(0x0572, 0xcb01, 0xff, 0, 0),
317 .driver_info = (unsigned long) &cx82310_info 308 .driver_info = (unsigned long) &cx82310_info
318 }, 309 },
319 { }, 310 { },
diff --git a/drivers/net/usb/gl620a.c b/drivers/net/usb/gl620a.c
index db3c8021f2a..a7e3f4e55bf 100644
--- a/drivers/net/usb/gl620a.c
+++ b/drivers/net/usb/gl620a.c
@@ -91,7 +91,9 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
91 // get the packet count of the received skb 91 // get the packet count of the received skb
92 count = le32_to_cpu(header->packet_count); 92 count = le32_to_cpu(header->packet_count);
93 if (count > GL_MAX_TRANSMIT_PACKETS) { 93 if (count > GL_MAX_TRANSMIT_PACKETS) {
94 dbg("genelink: invalid received packet count %u", count); 94 netdev_dbg(dev->net,
95 "genelink: invalid received packet count %u\n",
96 count);
95 return 0; 97 return 0;
96 } 98 }
97 99
@@ -107,7 +109,8 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
107 109
108 // this may be a broken packet 110 // this may be a broken packet
109 if (size > GL_MAX_PACKET_LEN) { 111 if (size > GL_MAX_PACKET_LEN) {
110 dbg("genelink: invalid rx length %d", size); 112 netdev_dbg(dev->net, "genelink: invalid rx length %d\n",
113 size);
111 return 0; 114 return 0;
112 } 115 }
113 116
@@ -133,7 +136,8 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
133 skb_pull(skb, 4); 136 skb_pull(skb, 4);
134 137
135 if (skb->len > GL_MAX_PACKET_LEN) { 138 if (skb->len > GL_MAX_PACKET_LEN) {
136 dbg("genelink: invalid rx length %d", skb->len); 139 netdev_dbg(dev->net, "genelink: invalid rx length %d\n",
140 skb->len);
137 return 0; 141 return 0;
138 } 142 }
139 return 1; 143 return 1;
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index c3d03490c97..c75e11e1b38 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -267,19 +267,16 @@ static int kaweth_control(struct kaweth_device *kaweth,
267 struct usb_ctrlrequest *dr; 267 struct usb_ctrlrequest *dr;
268 int retval; 268 int retval;
269 269
270 dbg("kaweth_control()"); 270 netdev_dbg(kaweth->net, "kaweth_control()\n");
271 271
272 if(in_interrupt()) { 272 if(in_interrupt()) {
273 dbg("in_interrupt()"); 273 netdev_dbg(kaweth->net, "in_interrupt()\n");
274 return -EBUSY; 274 return -EBUSY;
275 } 275 }
276 276
277 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); 277 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
278 278 if (!dr)
279 if (!dr) {
280 dbg("kmalloc() failed");
281 return -ENOMEM; 279 return -ENOMEM;
282 }
283 280
284 dr->bRequestType = requesttype; 281 dr->bRequestType = requesttype;
285 dr->bRequest = request; 282 dr->bRequest = request;
@@ -305,7 +302,7 @@ static int kaweth_read_configuration(struct kaweth_device *kaweth)
305{ 302{
306 int retval; 303 int retval;
307 304
308 dbg("Reading kaweth configuration"); 305 netdev_dbg(kaweth->net, "Reading kaweth configuration\n");
309 306
310 retval = kaweth_control(kaweth, 307 retval = kaweth_control(kaweth,
311 usb_rcvctrlpipe(kaweth->dev, 0), 308 usb_rcvctrlpipe(kaweth->dev, 0),
@@ -327,7 +324,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size)
327{ 324{
328 int retval; 325 int retval;
329 326
330 dbg("Setting URB size to %d", (unsigned)urb_size); 327 netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size);
331 328
332 retval = kaweth_control(kaweth, 329 retval = kaweth_control(kaweth,
333 usb_sndctrlpipe(kaweth->dev, 0), 330 usb_sndctrlpipe(kaweth->dev, 0),
@@ -349,7 +346,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait)
349{ 346{
350 int retval; 347 int retval;
351 348
352 dbg("Set SOFS wait to %d", (unsigned)sofs_wait); 349 netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait);
353 350
354 retval = kaweth_control(kaweth, 351 retval = kaweth_control(kaweth,
355 usb_sndctrlpipe(kaweth->dev, 0), 352 usb_sndctrlpipe(kaweth->dev, 0),
@@ -372,7 +369,8 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
372{ 369{
373 int retval; 370 int retval;
374 371
375 dbg("Set receive filter to %d", (unsigned)receive_filter); 372 netdev_dbg(kaweth->net, "Set receive filter to %d\n",
373 (unsigned)receive_filter);
376 374
377 retval = kaweth_control(kaweth, 375 retval = kaweth_control(kaweth,
378 usb_sndctrlpipe(kaweth->dev, 0), 376 usb_sndctrlpipe(kaweth->dev, 0),
@@ -421,12 +419,13 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
421 kaweth->firmware_buf[4] = type; 419 kaweth->firmware_buf[4] = type;
422 kaweth->firmware_buf[5] = interrupt; 420 kaweth->firmware_buf[5] = interrupt;
423 421
424 dbg("High: %i, Low:%i", kaweth->firmware_buf[3], 422 netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3],
425 kaweth->firmware_buf[2]); 423 kaweth->firmware_buf[2]);
426 424
427 dbg("Downloading firmware at %p to kaweth device at %p", 425 netdev_dbg(kaweth->net,
428 fw->data, kaweth); 426 "Downloading firmware at %p to kaweth device at %p\n",
429 dbg("Firmware length: %d", data_len); 427 fw->data, kaweth);
428 netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len);
430 429
431 return kaweth_control(kaweth, 430 return kaweth_control(kaweth,
432 usb_sndctrlpipe(kaweth->dev, 0), 431 usb_sndctrlpipe(kaweth->dev, 0),
@@ -454,7 +453,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth,
454 kaweth->firmware_buf[6] = 0x00; 453 kaweth->firmware_buf[6] = 0x00;
455 kaweth->firmware_buf[7] = 0x00; 454 kaweth->firmware_buf[7] = 0x00;
456 455
457 dbg("Triggering firmware"); 456 netdev_dbg(kaweth->net, "Triggering firmware\n");
458 457
459 return kaweth_control(kaweth, 458 return kaweth_control(kaweth,
460 usb_sndctrlpipe(kaweth->dev, 0), 459 usb_sndctrlpipe(kaweth->dev, 0),
@@ -474,11 +473,11 @@ static int kaweth_reset(struct kaweth_device *kaweth)
474{ 473{
475 int result; 474 int result;
476 475
477 dbg("kaweth_reset(%p)", kaweth); 476 netdev_dbg(kaweth->net, "kaweth_reset(%p)\n", kaweth);
478 result = usb_reset_configuration(kaweth->dev); 477 result = usb_reset_configuration(kaweth->dev);
479 mdelay(10); 478 mdelay(10);
480 479
481 dbg("kaweth_reset() returns %d.",result); 480 netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result);
482 481
483 return result; 482 return result;
484} 483}
@@ -595,6 +594,7 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth);
595 ****************************************************************/ 594 ****************************************************************/
596static void kaweth_usb_receive(struct urb *urb) 595static void kaweth_usb_receive(struct urb *urb)
597{ 596{
597 struct device *dev = &urb->dev->dev;
598 struct kaweth_device *kaweth = urb->context; 598 struct kaweth_device *kaweth = urb->context;
599 struct net_device *net = kaweth->net; 599 struct net_device *net = kaweth->net;
600 int status = urb->status; 600 int status = urb->status;
@@ -610,25 +610,25 @@ static void kaweth_usb_receive(struct urb *urb)
610 kaweth->stats.rx_errors++; 610 kaweth->stats.rx_errors++;
611 kaweth->end = 1; 611 kaweth->end = 1;
612 wake_up(&kaweth->term_wait); 612 wake_up(&kaweth->term_wait);
613 dbg("Status was -EPIPE."); 613 dev_dbg(dev, "Status was -EPIPE.\n");
614 return; 614 return;
615 } 615 }
616 if (unlikely(status == -ECONNRESET || status == -ESHUTDOWN)) { 616 if (unlikely(status == -ECONNRESET || status == -ESHUTDOWN)) {
617 /* we are killed - set a flag and wake the disconnect handler */ 617 /* we are killed - set a flag and wake the disconnect handler */
618 kaweth->end = 1; 618 kaweth->end = 1;
619 wake_up(&kaweth->term_wait); 619 wake_up(&kaweth->term_wait);
620 dbg("Status was -ECONNRESET or -ESHUTDOWN."); 620 dev_dbg(dev, "Status was -ECONNRESET or -ESHUTDOWN.\n");
621 return; 621 return;
622 } 622 }
623 if (unlikely(status == -EPROTO || status == -ETIME || 623 if (unlikely(status == -EPROTO || status == -ETIME ||
624 status == -EILSEQ)) { 624 status == -EILSEQ)) {
625 kaweth->stats.rx_errors++; 625 kaweth->stats.rx_errors++;
626 dbg("Status was -EPROTO, -ETIME, or -EILSEQ."); 626 dev_dbg(dev, "Status was -EPROTO, -ETIME, or -EILSEQ.\n");
627 return; 627 return;
628 } 628 }
629 if (unlikely(status == -EOVERFLOW)) { 629 if (unlikely(status == -EOVERFLOW)) {
630 kaweth->stats.rx_errors++; 630 kaweth->stats.rx_errors++;
631 dbg("Status was -EOVERFLOW."); 631 dev_dbg(dev, "Status was -EOVERFLOW.\n");
632 } 632 }
633 spin_lock(&kaweth->device_lock); 633 spin_lock(&kaweth->device_lock);
634 if (IS_BLOCKED(kaweth->status)) { 634 if (IS_BLOCKED(kaweth->status)) {
@@ -687,7 +687,7 @@ static int kaweth_open(struct net_device *net)
687 struct kaweth_device *kaweth = netdev_priv(net); 687 struct kaweth_device *kaweth = netdev_priv(net);
688 int res; 688 int res;
689 689
690 dbg("Opening network device."); 690 netdev_dbg(kaweth->net, "Opening network device.\n");
691 691
692 res = usb_autopm_get_interface(kaweth->intf); 692 res = usb_autopm_get_interface(kaweth->intf);
693 if (res) { 693 if (res) {
@@ -787,7 +787,8 @@ static void kaweth_usb_transmit_complete(struct urb *urb)
787 787
788 if (unlikely(status != 0)) 788 if (unlikely(status != 0))
789 if (status != -ENOENT) 789 if (status != -ENOENT)
790 dbg("%s: TX status %d.", kaweth->net->name, status); 790 dev_dbg(&urb->dev->dev, "%s: TX status %d.\n",
791 kaweth->net->name, status);
791 792
792 netif_wake_queue(kaweth->net); 793 netif_wake_queue(kaweth->net);
793 dev_kfree_skb_irq(skb); 794 dev_kfree_skb_irq(skb);
@@ -871,7 +872,7 @@ static void kaweth_set_rx_mode(struct net_device *net)
871 KAWETH_PACKET_FILTER_BROADCAST | 872 KAWETH_PACKET_FILTER_BROADCAST |
872 KAWETH_PACKET_FILTER_MULTICAST; 873 KAWETH_PACKET_FILTER_MULTICAST;
873 874
874 dbg("Setting Rx mode to %d", packet_filter_bitmap); 875 netdev_dbg(net, "Setting Rx mode to %d\n", packet_filter_bitmap);
875 876
876 netif_stop_queue(net); 877 netif_stop_queue(net);
877 878
@@ -916,7 +917,8 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
916 result); 917 result);
917 } 918 }
918 else { 919 else {
919 dbg("Set Rx mode to %d", packet_filter_bitmap); 920 netdev_dbg(kaweth->net, "Set Rx mode to %d\n",
921 packet_filter_bitmap);
920 } 922 }
921} 923}
922 924
@@ -951,7 +953,7 @@ static int kaweth_suspend(struct usb_interface *intf, pm_message_t message)
951 struct kaweth_device *kaweth = usb_get_intfdata(intf); 953 struct kaweth_device *kaweth = usb_get_intfdata(intf);
952 unsigned long flags; 954 unsigned long flags;
953 955
954 dbg("Suspending device"); 956 dev_dbg(&intf->dev, "Suspending device\n");
955 spin_lock_irqsave(&kaweth->device_lock, flags); 957 spin_lock_irqsave(&kaweth->device_lock, flags);
956 kaweth->status |= KAWETH_STATUS_SUSPENDING; 958 kaweth->status |= KAWETH_STATUS_SUSPENDING;
957 spin_unlock_irqrestore(&kaweth->device_lock, flags); 959 spin_unlock_irqrestore(&kaweth->device_lock, flags);
@@ -968,7 +970,7 @@ static int kaweth_resume(struct usb_interface *intf)
968 struct kaweth_device *kaweth = usb_get_intfdata(intf); 970 struct kaweth_device *kaweth = usb_get_intfdata(intf);
969 unsigned long flags; 971 unsigned long flags;
970 972
971 dbg("Resuming device"); 973 dev_dbg(&intf->dev, "Resuming device\n");
972 spin_lock_irqsave(&kaweth->device_lock, flags); 974 spin_lock_irqsave(&kaweth->device_lock, flags);
973 kaweth->status &= ~KAWETH_STATUS_SUSPENDING; 975 kaweth->status &= ~KAWETH_STATUS_SUSPENDING;
974 spin_unlock_irqrestore(&kaweth->device_lock, flags); 976 spin_unlock_irqrestore(&kaweth->device_lock, flags);
@@ -1003,36 +1005,37 @@ static int kaweth_probe(
1003 const struct usb_device_id *id /* from id_table */ 1005 const struct usb_device_id *id /* from id_table */
1004 ) 1006 )
1005{ 1007{
1006 struct usb_device *dev = interface_to_usbdev(intf); 1008 struct device *dev = &intf->dev;
1009 struct usb_device *udev = interface_to_usbdev(intf);
1007 struct kaweth_device *kaweth; 1010 struct kaweth_device *kaweth;
1008 struct net_device *netdev; 1011 struct net_device *netdev;
1009 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 1012 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1010 int result = 0; 1013 int result = 0;
1011 1014
1012 dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", 1015 dev_dbg(dev,
1013 dev->devnum, 1016 "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n",
1014 le16_to_cpu(dev->descriptor.idVendor), 1017 udev->devnum, le16_to_cpu(udev->descriptor.idVendor),
1015 le16_to_cpu(dev->descriptor.idProduct), 1018 le16_to_cpu(udev->descriptor.idProduct),
1016 le16_to_cpu(dev->descriptor.bcdDevice)); 1019 le16_to_cpu(udev->descriptor.bcdDevice));
1017 1020
1018 dbg("Device at %p", dev); 1021 dev_dbg(dev, "Device at %p\n", udev);
1019 1022
1020 dbg("Descriptor length: %x type: %x", 1023 dev_dbg(dev, "Descriptor length: %x type: %x\n",
1021 (int)dev->descriptor.bLength, 1024 (int)udev->descriptor.bLength,
1022 (int)dev->descriptor.bDescriptorType); 1025 (int)udev->descriptor.bDescriptorType);
1023 1026
1024 netdev = alloc_etherdev(sizeof(*kaweth)); 1027 netdev = alloc_etherdev(sizeof(*kaweth));
1025 if (!netdev) 1028 if (!netdev)
1026 return -ENOMEM; 1029 return -ENOMEM;
1027 1030
1028 kaweth = netdev_priv(netdev); 1031 kaweth = netdev_priv(netdev);
1029 kaweth->dev = dev; 1032 kaweth->dev = udev;
1030 kaweth->net = netdev; 1033 kaweth->net = netdev;
1031 1034
1032 spin_lock_init(&kaweth->device_lock); 1035 spin_lock_init(&kaweth->device_lock);
1033 init_waitqueue_head(&kaweth->term_wait); 1036 init_waitqueue_head(&kaweth->term_wait);
1034 1037
1035 dbg("Resetting."); 1038 dev_dbg(dev, "Resetting.\n");
1036 1039
1037 kaweth_reset(kaweth); 1040 kaweth_reset(kaweth);
1038 1041
@@ -1041,17 +1044,17 @@ static int kaweth_probe(
1041 * downloaded. Don't try to do it again, or we'll hang the device. 1044 * downloaded. Don't try to do it again, or we'll hang the device.
1042 */ 1045 */
1043 1046
1044 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { 1047 if (le16_to_cpu(udev->descriptor.bcdDevice) >> 8) {
1045 dev_info(&intf->dev, "Firmware present in device.\n"); 1048 dev_info(dev, "Firmware present in device.\n");
1046 } else { 1049 } else {
1047 /* Download the firmware */ 1050 /* Download the firmware */
1048 dev_info(&intf->dev, "Downloading firmware...\n"); 1051 dev_info(dev, "Downloading firmware...\n");
1049 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 1052 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
1050 if ((result = kaweth_download_firmware(kaweth, 1053 if ((result = kaweth_download_firmware(kaweth,
1051 "kaweth/new_code.bin", 1054 "kaweth/new_code.bin",
1052 100, 1055 100,
1053 2)) < 0) { 1056 2)) < 0) {
1054 dev_err(&intf->dev, "Error downloading firmware (%d)\n", 1057 dev_err(dev, "Error downloading firmware (%d)\n",
1055 result); 1058 result);
1056 goto err_fw; 1059 goto err_fw;
1057 } 1060 }
@@ -1060,8 +1063,7 @@ static int kaweth_probe(
1060 "kaweth/new_code_fix.bin", 1063 "kaweth/new_code_fix.bin",
1061 100, 1064 100,
1062 3)) < 0) { 1065 3)) < 0) {
1063 dev_err(&intf->dev, 1066 dev_err(dev, "Error downloading firmware fix (%d)\n",
1064 "Error downloading firmware fix (%d)\n",
1065 result); 1067 result);
1066 goto err_fw; 1068 goto err_fw;
1067 } 1069 }
@@ -1070,8 +1072,7 @@ static int kaweth_probe(
1070 "kaweth/trigger_code.bin", 1072 "kaweth/trigger_code.bin",
1071 126, 1073 126,
1072 2)) < 0) { 1074 2)) < 0) {
1073 dev_err(&intf->dev, 1075 dev_err(dev, "Error downloading trigger code (%d)\n",
1074 "Error downloading trigger code (%d)\n",
1075 result); 1076 result);
1076 goto err_fw; 1077 goto err_fw;
1077 1078
@@ -1081,19 +1082,18 @@ static int kaweth_probe(
1081 "kaweth/trigger_code_fix.bin", 1082 "kaweth/trigger_code_fix.bin",
1082 126, 1083 126,
1083 3)) < 0) { 1084 3)) < 0) {
1084 dev_err(&intf->dev, "Error downloading trigger code fix (%d)\n", result); 1085 dev_err(dev, "Error downloading trigger code fix (%d)\n", result);
1085 goto err_fw; 1086 goto err_fw;
1086 } 1087 }
1087 1088
1088 1089
1089 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { 1090 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
1090 dev_err(&intf->dev, "Error triggering firmware (%d)\n", 1091 dev_err(dev, "Error triggering firmware (%d)\n", result);
1091 result);
1092 goto err_fw; 1092 goto err_fw;
1093 } 1093 }
1094 1094
1095 /* Device will now disappear for a moment... */ 1095 /* Device will now disappear for a moment... */
1096 dev_info(&intf->dev, "Firmware loaded. I'll be back...\n"); 1096 dev_info(dev, "Firmware loaded. I'll be back...\n");
1097err_fw: 1097err_fw:
1098 free_page((unsigned long)kaweth->firmware_buf); 1098 free_page((unsigned long)kaweth->firmware_buf);
1099 free_netdev(netdev); 1099 free_netdev(netdev);
@@ -1103,29 +1103,29 @@ err_fw:
1103 result = kaweth_read_configuration(kaweth); 1103 result = kaweth_read_configuration(kaweth);
1104 1104
1105 if(result < 0) { 1105 if(result < 0) {
1106 dev_err(&intf->dev, "Error reading configuration (%d), no net device created\n", result); 1106 dev_err(dev, "Error reading configuration (%d), no net device created\n", result);
1107 goto err_free_netdev; 1107 goto err_free_netdev;
1108 } 1108 }
1109 1109
1110 dev_info(&intf->dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); 1110 dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask);
1111 dev_info(&intf->dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1111 dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1));
1112 dev_info(&intf->dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); 1112 dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size));
1113 dev_info(&intf->dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); 1113 dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr);
1114 1114
1115 if(!memcmp(&kaweth->configuration.hw_addr, 1115 if(!memcmp(&kaweth->configuration.hw_addr,
1116 &bcast_addr, 1116 &bcast_addr,
1117 sizeof(bcast_addr))) { 1117 sizeof(bcast_addr))) {
1118 dev_err(&intf->dev, "Firmware not functioning properly, no net device created\n"); 1118 dev_err(dev, "Firmware not functioning properly, no net device created\n");
1119 goto err_free_netdev; 1119 goto err_free_netdev;
1120 } 1120 }
1121 1121
1122 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { 1122 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) {
1123 dbg("Error setting URB size"); 1123 dev_dbg(dev, "Error setting URB size\n");
1124 goto err_free_netdev; 1124 goto err_free_netdev;
1125 } 1125 }
1126 1126
1127 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { 1127 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) {
1128 dev_err(&intf->dev, "Error setting SOFS wait\n"); 1128 dev_err(dev, "Error setting SOFS wait\n");
1129 goto err_free_netdev; 1129 goto err_free_netdev;
1130 } 1130 }
1131 1131
@@ -1135,11 +1135,11 @@ err_fw:
1135 KAWETH_PACKET_FILTER_MULTICAST); 1135 KAWETH_PACKET_FILTER_MULTICAST);
1136 1136
1137 if(result < 0) { 1137 if(result < 0) {
1138 dev_err(&intf->dev, "Error setting receive filter\n"); 1138 dev_err(dev, "Error setting receive filter\n");
1139 goto err_free_netdev; 1139 goto err_free_netdev;
1140 } 1140 }
1141 1141
1142 dbg("Initializing net device."); 1142 dev_dbg(dev, "Initializing net device.\n");
1143 1143
1144 kaweth->intf = intf; 1144 kaweth->intf = intf;
1145 1145
@@ -1181,20 +1181,20 @@ err_fw:
1181 1181
1182#if 0 1182#if 0
1183// dma_supported() is deeply broken on almost all architectures 1183// dma_supported() is deeply broken on almost all architectures
1184 if (dma_supported (&intf->dev, 0xffffffffffffffffULL)) 1184 if (dma_supported (dev, 0xffffffffffffffffULL))
1185 kaweth->net->features |= NETIF_F_HIGHDMA; 1185 kaweth->net->features |= NETIF_F_HIGHDMA;
1186#endif 1186#endif
1187 1187
1188 SET_NETDEV_DEV(netdev, &intf->dev); 1188 SET_NETDEV_DEV(netdev, dev);
1189 if (register_netdev(netdev) != 0) { 1189 if (register_netdev(netdev) != 0) {
1190 dev_err(&intf->dev, "Error registering netdev.\n"); 1190 dev_err(dev, "Error registering netdev.\n");
1191 goto err_intfdata; 1191 goto err_intfdata;
1192 } 1192 }
1193 1193
1194 dev_info(&intf->dev, "kaweth interface created at %s\n", 1194 dev_info(dev, "kaweth interface created at %s\n",
1195 kaweth->net->name); 1195 kaweth->net->name);
1196 1196
1197 dbg("Kaweth probe returning."); 1197 dev_dbg(dev, "Kaweth probe returning.\n");
1198 1198
1199 return 0; 1199 return 0;
1200 1200
@@ -1232,7 +1232,7 @@ static void kaweth_disconnect(struct usb_interface *intf)
1232 } 1232 }
1233 netdev = kaweth->net; 1233 netdev = kaweth->net;
1234 1234
1235 dbg("Unregistering net device"); 1235 netdev_dbg(kaweth->net, "Unregistering net device\n");
1236 unregister_netdev(netdev); 1236 unregister_netdev(netdev);
1237 1237
1238 usb_free_urb(kaweth->rx_urb); 1238 usb_free_urb(kaweth->rx_urb);
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index 28c4d513ba8..c062a3e8295 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -155,12 +155,10 @@ static void nc_dump_registers(struct usbnet *dev)
155 u8 reg; 155 u8 reg;
156 u16 *vp = kmalloc(sizeof (u16)); 156 u16 *vp = kmalloc(sizeof (u16));
157 157
158 if (!vp) { 158 if (!vp)
159 dbg("no memory?");
160 return; 159 return;
161 }
162 160
163 dbg("%s registers:", dev->net->name); 161 netdev_dbg(dev->net, "registers:\n");
164 for (reg = 0; reg < 0x20; reg++) { 162 for (reg = 0; reg < 0x20; reg++) {
165 int retval; 163 int retval;
166 164
@@ -172,11 +170,10 @@ static void nc_dump_registers(struct usbnet *dev)
172 170
173 retval = nc_register_read(dev, reg, vp); 171 retval = nc_register_read(dev, reg, vp);
174 if (retval < 0) 172 if (retval < 0)
175 dbg("%s reg [0x%x] ==> error %d", 173 netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n",
176 dev->net->name, reg, retval); 174 reg, retval);
177 else 175 else
178 dbg("%s reg [0x%x] = 0x%x", 176 netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp);
179 dev->net->name, reg, *vp);
180 } 177 }
181 kfree(vp); 178 kfree(vp);
182} 179}
@@ -300,15 +297,15 @@ static int net1080_reset(struct usbnet *dev)
300 // nc_dump_registers(dev); 297 // nc_dump_registers(dev);
301 298
302 if ((retval = nc_register_read(dev, REG_STATUS, vp)) < 0) { 299 if ((retval = nc_register_read(dev, REG_STATUS, vp)) < 0) {
303 dbg("can't read %s-%s status: %d", 300 netdev_dbg(dev->net, "can't read %s-%s status: %d\n",
304 dev->udev->bus->bus_name, dev->udev->devpath, retval); 301 dev->udev->bus->bus_name, dev->udev->devpath, retval);
305 goto done; 302 goto done;
306 } 303 }
307 status = *vp; 304 status = *vp;
308 nc_dump_status(dev, status); 305 nc_dump_status(dev, status);
309 306
310 if ((retval = nc_register_read(dev, REG_USBCTL, vp)) < 0) { 307 if ((retval = nc_register_read(dev, REG_USBCTL, vp)) < 0) {
311 dbg("can't read USBCTL, %d", retval); 308 netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval);
312 goto done; 309 goto done;
313 } 310 }
314 usbctl = *vp; 311 usbctl = *vp;
@@ -318,7 +315,7 @@ static int net1080_reset(struct usbnet *dev)
318 USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); 315 USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER);
319 316
320 if ((retval = nc_register_read(dev, REG_TTL, vp)) < 0) { 317 if ((retval = nc_register_read(dev, REG_TTL, vp)) < 0) {
321 dbg("can't read TTL, %d", retval); 318 netdev_dbg(dev->net, "can't read TTL, %d\n", retval);
322 goto done; 319 goto done;
323 } 320 }
324 ttl = *vp; 321 ttl = *vp;
@@ -326,7 +323,7 @@ static int net1080_reset(struct usbnet *dev)
326 323
327 nc_register_write(dev, REG_TTL, 324 nc_register_write(dev, REG_TTL,
328 MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) ); 325 MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) );
329 dbg("%s: assigned TTL, %d ms", dev->net->name, NC_READ_TTL_MS); 326 netdev_dbg(dev->net, "assigned TTL, %d ms\n", NC_READ_TTL_MS);
330 327
331 netif_info(dev, link, dev->net, "port %c, peer %sconnected\n", 328 netif_info(dev, link, dev->net, "port %c, peer %sconnected\n",
332 (status & STATUS_PORT_A) ? 'A' : 'B', 329 (status & STATUS_PORT_A) ? 'A' : 'B',
@@ -350,7 +347,7 @@ static int net1080_check_connect(struct usbnet *dev)
350 status = *vp; 347 status = *vp;
351 kfree(vp); 348 kfree(vp);
352 if (retval != 0) { 349 if (retval != 0) {
353 dbg("%s net1080_check_conn read - %d", dev->net->name, retval); 350 netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval);
354 return retval; 351 return retval;
355 } 352 }
356 if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) 353 if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER)
@@ -420,11 +417,9 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
420 u16 hdr_len, packet_len; 417 u16 hdr_len, packet_len;
421 418
422 if (!(skb->len & 0x01)) { 419 if (!(skb->len & 0x01)) {
423#ifdef DEBUG 420 netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n",
424 struct net_device *net = dev->net; 421 skb->len, dev->net->hard_header_len, dev->hard_mtu,
425 dbg("rx framesize %d range %d..%d mtu %d", skb->len, 422 dev->net->mtu);
426 net->hard_header_len, dev->hard_mtu, net->mtu);
427#endif
428 dev->net->stats.rx_frame_errors++; 423 dev->net->stats.rx_frame_errors++;
429 nc_ensure_sync(dev); 424 nc_ensure_sync(dev);
430 return 0; 425 return 0;
@@ -435,17 +430,17 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
435 packet_len = le16_to_cpup(&header->packet_len); 430 packet_len = le16_to_cpup(&header->packet_len);
436 if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { 431 if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) {
437 dev->net->stats.rx_frame_errors++; 432 dev->net->stats.rx_frame_errors++;
438 dbg("packet too big, %d", packet_len); 433 netdev_dbg(dev->net, "packet too big, %d\n", packet_len);
439 nc_ensure_sync(dev); 434 nc_ensure_sync(dev);
440 return 0; 435 return 0;
441 } else if (hdr_len < MIN_HEADER) { 436 } else if (hdr_len < MIN_HEADER) {
442 dev->net->stats.rx_frame_errors++; 437 dev->net->stats.rx_frame_errors++;
443 dbg("header too short, %d", hdr_len); 438 netdev_dbg(dev->net, "header too short, %d\n", hdr_len);
444 nc_ensure_sync(dev); 439 nc_ensure_sync(dev);
445 return 0; 440 return 0;
446 } else if (hdr_len > MIN_HEADER) { 441 } else if (hdr_len > MIN_HEADER) {
447 // out of band data for us? 442 // out of band data for us?
448 dbg("header OOB, %d bytes", hdr_len - MIN_HEADER); 443 netdev_dbg(dev->net, "header OOB, %d bytes\n", hdr_len - MIN_HEADER);
449 nc_ensure_sync(dev); 444 nc_ensure_sync(dev);
450 // switch (vendor/product ids) { ... } 445 // switch (vendor/product ids) { ... }
451 } 446 }
@@ -458,23 +453,23 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
458 if ((packet_len & 0x01) == 0) { 453 if ((packet_len & 0x01) == 0) {
459 if (skb->data [packet_len] != PAD_BYTE) { 454 if (skb->data [packet_len] != PAD_BYTE) {
460 dev->net->stats.rx_frame_errors++; 455 dev->net->stats.rx_frame_errors++;
461 dbg("bad pad"); 456 netdev_dbg(dev->net, "bad pad\n");
462 return 0; 457 return 0;
463 } 458 }
464 skb_trim(skb, skb->len - 1); 459 skb_trim(skb, skb->len - 1);
465 } 460 }
466 if (skb->len != packet_len) { 461 if (skb->len != packet_len) {
467 dev->net->stats.rx_frame_errors++; 462 dev->net->stats.rx_frame_errors++;
468 dbg("bad packet len %d (expected %d)", 463 netdev_dbg(dev->net, "bad packet len %d (expected %d)\n",
469 skb->len, packet_len); 464 skb->len, packet_len);
470 nc_ensure_sync(dev); 465 nc_ensure_sync(dev);
471 return 0; 466 return 0;
472 } 467 }
473 if (header->packet_id != get_unaligned(&trailer->packet_id)) { 468 if (header->packet_id != get_unaligned(&trailer->packet_id)) {
474 dev->net->stats.rx_fifo_errors++; 469 dev->net->stats.rx_fifo_errors++;
475 dbg("(2+ dropped) rx packet_id mismatch 0x%x 0x%x", 470 netdev_dbg(dev->net, "(2+ dropped) rx packet_id mismatch 0x%x 0x%x\n",
476 le16_to_cpu(header->packet_id), 471 le16_to_cpu(header->packet_id),
477 le16_to_cpu(trailer->packet_id)); 472 le16_to_cpu(trailer->packet_id));
478 return 0; 473 return 0;
479 } 474 }
480#if 0 475#if 0
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 3543c9e5782..6883c371c59 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -108,7 +108,7 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev)
108 atomic_set(&info->pmcount, 0); 108 atomic_set(&info->pmcount, 0);
109 109
110 /* register subdriver */ 110 /* register subdriver */
111 subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power); 111 subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, 4096, &qmi_wwan_cdc_wdm_manage_power);
112 if (IS_ERR(subdriver)) { 112 if (IS_ERR(subdriver)) {
113 dev_err(&info->control->dev, "subdriver registration failed\n"); 113 dev_err(&info->control->dev, "subdriver registration failed\n");
114 rv = PTR_ERR(subdriver); 114 rv = PTR_ERR(subdriver);
@@ -139,10 +139,18 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
139 139
140 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state))); 140 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < sizeof(struct qmi_wwan_state)));
141 141
142 /* require a single interrupt status endpoint for subdriver */ 142 /* control and data is shared? */
143 if (intf->cur_altsetting->desc.bNumEndpoints == 3) {
144 info->control = intf;
145 info->data = intf;
146 goto shared;
147 }
148
149 /* else require a single interrupt status endpoint on control intf */
143 if (intf->cur_altsetting->desc.bNumEndpoints != 1) 150 if (intf->cur_altsetting->desc.bNumEndpoints != 1)
144 goto err; 151 goto err;
145 152
153 /* and a number of CDC descriptors */
146 while (len > 3) { 154 while (len > 3) {
147 struct usb_descriptor_header *h = (void *)buf; 155 struct usb_descriptor_header *h = (void *)buf;
148 156
@@ -231,8 +239,9 @@ next_desc:
231 if (status < 0) 239 if (status < 0)
232 goto err; 240 goto err;
233 241
242shared:
234 status = qmi_wwan_register_subdriver(dev); 243 status = qmi_wwan_register_subdriver(dev);
235 if (status < 0) { 244 if (status < 0 && info->control != info->data) {
236 usb_set_intfdata(info->data, NULL); 245 usb_set_intfdata(info->data, NULL);
237 usb_driver_release_interface(driver, info->data); 246 usb_driver_release_interface(driver, info->data);
238 } 247 }
@@ -241,20 +250,6 @@ err:
241 return status; 250 return status;
242} 251}
243 252
244/* Some devices combine the "control" and "data" functions into a
245 * single interface with all three endpoints: interrupt + bulk in and
246 * out
247 */
248static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf)
249{
250 struct qmi_wwan_state *info = (void *)&dev->data;
251
252 /* control and data is shared */
253 info->control = intf;
254 info->data = intf;
255 return qmi_wwan_register_subdriver(dev);
256}
257
258static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf) 253static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
259{ 254{
260 struct qmi_wwan_state *info = (void *)&dev->data; 255 struct qmi_wwan_state *info = (void *)&dev->data;
@@ -331,20 +326,12 @@ static const struct driver_info qmi_wwan_info = {
331 .manage_power = qmi_wwan_manage_power, 326 .manage_power = qmi_wwan_manage_power,
332}; 327};
333 328
334static const struct driver_info qmi_wwan_shared = {
335 .description = "WWAN/QMI device",
336 .flags = FLAG_WWAN,
337 .bind = qmi_wwan_bind_shared,
338 .unbind = qmi_wwan_unbind,
339 .manage_power = qmi_wwan_manage_power,
340};
341
342#define HUAWEI_VENDOR_ID 0x12D1 329#define HUAWEI_VENDOR_ID 0x12D1
343 330
344/* map QMI/wwan function by a fixed interface number */ 331/* map QMI/wwan function by a fixed interface number */
345#define QMI_FIXED_INTF(vend, prod, num) \ 332#define QMI_FIXED_INTF(vend, prod, num) \
346 USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ 333 USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
347 .driver_info = (unsigned long)&qmi_wwan_shared 334 .driver_info = (unsigned long)&qmi_wwan_info
348 335
349/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */ 336/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
350#define QMI_GOBI1K_DEVICE(vend, prod) \ 337#define QMI_GOBI1K_DEVICE(vend, prod) \
@@ -372,15 +359,15 @@ static const struct usb_device_id products[] = {
372 }, 359 },
373 { /* Huawei E392, E398 and possibly others in "Windows mode" */ 360 { /* Huawei E392, E398 and possibly others in "Windows mode" */
374 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17), 361 USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
375 .driver_info = (unsigned long)&qmi_wwan_shared, 362 .driver_info = (unsigned long)&qmi_wwan_info,
376 }, 363 },
377 { /* Pantech UML290, P4200 and more */ 364 { /* Pantech UML290, P4200 and more */
378 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff), 365 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
379 .driver_info = (unsigned long)&qmi_wwan_shared, 366 .driver_info = (unsigned long)&qmi_wwan_info,
380 }, 367 },
381 { /* Pantech UML290 - newer firmware */ 368 { /* Pantech UML290 - newer firmware */
382 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff), 369 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
383 .driver_info = (unsigned long)&qmi_wwan_shared, 370 .driver_info = (unsigned long)&qmi_wwan_info,
384 }, 371 },
385 372
386 /* 3. Combined interface devices matching on interface number */ 373 /* 3. Combined interface devices matching on interface number */
@@ -467,7 +454,7 @@ static int qmi_wwan_probe(struct usb_interface *intf, const struct usb_device_id
467 */ 454 */
468 if (!id->driver_info) { 455 if (!id->driver_info) {
469 dev_dbg(&intf->dev, "setting defaults for dynamic device id\n"); 456 dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
470 id->driver_info = (unsigned long)&qmi_wwan_shared; 457 id->driver_info = (unsigned long)&qmi_wwan_info;
471 } 458 }
472 459
473 return usbnet_probe(intf, id); 460 return usbnet_probe(intf, id);
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 0e2c92e0e53..5f39a3b225e 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -275,7 +275,7 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
275 return -EBUSY; 275 return -EBUSY;
276 276
277 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 277 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
278 dbg("%s: Setting MAC address to %pM\n", netdev->name, netdev->dev_addr); 278 netdev_dbg(netdev, "Setting MAC address to %pM\n", netdev->dev_addr);
279 /* Set the IDR registers. */ 279 /* Set the IDR registers. */
280 set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr); 280 set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr);
281#ifdef EEPROM_WRITE 281#ifdef EEPROM_WRITE
@@ -503,12 +503,12 @@ static void intr_callback(struct urb *urb)
503 if ((d[INT_MSR] & MSR_LINK) == 0) { 503 if ((d[INT_MSR] & MSR_LINK) == 0) {
504 if (netif_carrier_ok(dev->netdev)) { 504 if (netif_carrier_ok(dev->netdev)) {
505 netif_carrier_off(dev->netdev); 505 netif_carrier_off(dev->netdev);
506 dbg("%s: LINK LOST\n", __func__); 506 netdev_dbg(dev->netdev, "%s: LINK LOST\n", __func__);
507 } 507 }
508 } else { 508 } else {
509 if (!netif_carrier_ok(dev->netdev)) { 509 if (!netif_carrier_ok(dev->netdev)) {
510 netif_carrier_on(dev->netdev); 510 netif_carrier_on(dev->netdev);
511 dbg("%s: LINK CAME BACK\n", __func__); 511 netdev_dbg(dev->netdev, "%s: LINK CAME BACK\n", __func__);
512 } 512 }
513 } 513 }
514 514
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 8e22417fa6c..c27d27701ae 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -68,9 +68,8 @@ static atomic_t iface_counter = ATOMIC_INIT(0);
68 */ 68 */
69#define SIERRA_NET_USBCTL_BUF_LEN 1024 69#define SIERRA_NET_USBCTL_BUF_LEN 1024
70 70
71struct sierra_net_info_data { 71/* Overriding the default usbnet rx_urb_size */
72 u16 rx_urb_size; 72#define SIERRA_NET_RX_URB_SIZE (8 * 1024)
73};
74 73
75/* Private data structure */ 74/* Private data structure */
76struct sierra_net_data { 75struct sierra_net_data {
@@ -560,7 +559,7 @@ static void sierra_net_defer_kevent(struct usbnet *dev, int work)
560/* 559/*
561 * Sync Retransmit Timer Handler. On expiry, kick the work queue 560 * Sync Retransmit Timer Handler. On expiry, kick the work queue
562 */ 561 */
563void sierra_sync_timer(unsigned long syncdata) 562static void sierra_sync_timer(unsigned long syncdata)
564{ 563{
565 struct usbnet *dev = (struct usbnet *)syncdata; 564 struct usbnet *dev = (struct usbnet *)syncdata;
566 565
@@ -678,9 +677,6 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
678 static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = { 677 static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
679 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00}; 678 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00};
680 679
681 struct sierra_net_info_data *data =
682 (struct sierra_net_info_data *)dev->driver_info->data;
683
684 dev_dbg(&dev->udev->dev, "%s", __func__); 680 dev_dbg(&dev->udev->dev, "%s", __func__);
685 681
686 ifacenum = intf->cur_altsetting->desc.bInterfaceNumber; 682 ifacenum = intf->cur_altsetting->desc.bInterfaceNumber;
@@ -725,9 +721,9 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
725 sierra_net_set_ctx_index(priv, 0); 721 sierra_net_set_ctx_index(priv, 0);
726 722
727 /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */ 723 /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */
728 dev->rx_urb_size = data->rx_urb_size; 724 dev->rx_urb_size = SIERRA_NET_RX_URB_SIZE;
729 if (dev->udev->speed != USB_SPEED_HIGH) 725 if (dev->udev->speed != USB_SPEED_HIGH)
730 dev->rx_urb_size = min_t(size_t, 4096, data->rx_urb_size); 726 dev->rx_urb_size = min_t(size_t, 4096, SIERRA_NET_RX_URB_SIZE);
731 727
732 dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN; 728 dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN;
733 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; 729 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
@@ -842,7 +838,7 @@ static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
842 netdev_err(dev->net, "HIP/ETH: Invalid pkt\n"); 838 netdev_err(dev->net, "HIP/ETH: Invalid pkt\n");
843 839
844 dev->net->stats.rx_frame_errors++; 840 dev->net->stats.rx_frame_errors++;
845 /* dev->net->stats.rx_errors incremented by caller */; 841 /* dev->net->stats.rx_errors incremented by caller */
846 return 0; 842 return 0;
847 } 843 }
848 844
@@ -866,8 +862,8 @@ static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
866} 862}
867 863
868/* ---------------------------- Transmit data path ----------------------*/ 864/* ---------------------------- Transmit data path ----------------------*/
869struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb, 865static struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev,
870 gfp_t flags) 866 struct sk_buff *skb, gfp_t flags)
871{ 867{
872 struct sierra_net_data *priv = sierra_net_get_private(dev); 868 struct sierra_net_data *priv = sierra_net_get_private(dev);
873 u16 len; 869 u16 len;
@@ -918,10 +914,6 @@ struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
918 return NULL; 914 return NULL;
919} 915}
920 916
921static const struct sierra_net_info_data sierra_net_info_data_direct_ip = {
922 .rx_urb_size = 8 * 1024,
923};
924
925static const struct driver_info sierra_net_info_direct_ip = { 917static const struct driver_info sierra_net_info_direct_ip = {
926 .description = "Sierra Wireless USB-to-WWAN Modem", 918 .description = "Sierra Wireless USB-to-WWAN Modem",
927 .flags = FLAG_WWAN | FLAG_SEND_ZLP, 919 .flags = FLAG_WWAN | FLAG_SEND_ZLP,
@@ -930,7 +922,6 @@ static const struct driver_info sierra_net_info_direct_ip = {
930 .status = sierra_net_status, 922 .status = sierra_net_status,
931 .rx_fixup = sierra_net_rx_fixup, 923 .rx_fixup = sierra_net_rx_fixup,
932 .tx_fixup = sierra_net_tx_fixup, 924 .tx_fixup = sierra_net_tx_fixup,
933 .data = (unsigned long)&sierra_net_info_data_direct_ip,
934}; 925};
935 926
936#define DIRECT_IP_DEVICE(vend, prod) \ 927#define DIRECT_IP_DEVICE(vend, prod) \
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 376143e8a1a..b77ae76f4aa 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -52,6 +52,7 @@
52#define USB_PRODUCT_ID_LAN7500 (0x7500) 52#define USB_PRODUCT_ID_LAN7500 (0x7500)
53#define USB_PRODUCT_ID_LAN7505 (0x7505) 53#define USB_PRODUCT_ID_LAN7505 (0x7505)
54#define RXW_PADDING 2 54#define RXW_PADDING 2
55#define SUPPORTED_WAKE (WAKE_MAGIC)
55 56
56#define check_warn(ret, fmt, args...) \ 57#define check_warn(ret, fmt, args...) \
57 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); }) 58 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); })
@@ -65,6 +66,7 @@
65struct smsc75xx_priv { 66struct smsc75xx_priv {
66 struct usbnet *dev; 67 struct usbnet *dev;
67 u32 rfe_ctl; 68 u32 rfe_ctl;
69 u32 wolopts;
68 u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; 70 u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN];
69 struct mutex dataport_mutex; 71 struct mutex dataport_mutex;
70 spinlock_t rfe_ctl_lock; 72 spinlock_t rfe_ctl_lock;
@@ -135,6 +137,30 @@ static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
135 return ret; 137 return ret;
136} 138}
137 139
140static int smsc75xx_set_feature(struct usbnet *dev, u32 feature)
141{
142 if (WARN_ON_ONCE(!dev))
143 return -EINVAL;
144
145 cpu_to_le32s(&feature);
146
147 return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
148 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
149 USB_CTRL_SET_TIMEOUT);
150}
151
152static int smsc75xx_clear_feature(struct usbnet *dev, u32 feature)
153{
154 if (WARN_ON_ONCE(!dev))
155 return -EINVAL;
156
157 cpu_to_le32s(&feature);
158
159 return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
160 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
161 USB_CTRL_SET_TIMEOUT);
162}
163
138/* Loop until the read is completed with timeout 164/* Loop until the read is completed with timeout
139 * called with phy_mutex held */ 165 * called with phy_mutex held */
140static int smsc75xx_phy_wait_not_busy(struct usbnet *dev) 166static int smsc75xx_phy_wait_not_busy(struct usbnet *dev)
@@ -578,6 +604,26 @@ static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev,
578 return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); 604 return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data);
579} 605}
580 606
607static void smsc75xx_ethtool_get_wol(struct net_device *net,
608 struct ethtool_wolinfo *wolinfo)
609{
610 struct usbnet *dev = netdev_priv(net);
611 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
612
613 wolinfo->supported = SUPPORTED_WAKE;
614 wolinfo->wolopts = pdata->wolopts;
615}
616
617static int smsc75xx_ethtool_set_wol(struct net_device *net,
618 struct ethtool_wolinfo *wolinfo)
619{
620 struct usbnet *dev = netdev_priv(net);
621 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
622
623 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
624 return 0;
625}
626
581static const struct ethtool_ops smsc75xx_ethtool_ops = { 627static const struct ethtool_ops smsc75xx_ethtool_ops = {
582 .get_link = usbnet_get_link, 628 .get_link = usbnet_get_link,
583 .nway_reset = usbnet_nway_reset, 629 .nway_reset = usbnet_nway_reset,
@@ -589,6 +635,8 @@ static const struct ethtool_ops smsc75xx_ethtool_ops = {
589 .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, 635 .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len,
590 .get_eeprom = smsc75xx_ethtool_get_eeprom, 636 .get_eeprom = smsc75xx_ethtool_get_eeprom,
591 .set_eeprom = smsc75xx_ethtool_set_eeprom, 637 .set_eeprom = smsc75xx_ethtool_set_eeprom,
638 .get_wol = smsc75xx_ethtool_get_wol,
639 .set_wol = smsc75xx_ethtool_set_wol,
592}; 640};
593 641
594static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) 642static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
@@ -756,6 +804,26 @@ static int smsc75xx_set_features(struct net_device *netdev,
756 return 0; 804 return 0;
757} 805}
758 806
807static int smsc75xx_wait_ready(struct usbnet *dev)
808{
809 int timeout = 0;
810
811 do {
812 u32 buf;
813 int ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
814 check_warn_return(ret, "Failed to read PMT_CTL: %d", ret);
815
816 if (buf & PMT_CTL_DEV_RDY)
817 return 0;
818
819 msleep(10);
820 timeout++;
821 } while (timeout < 100);
822
823 netdev_warn(dev->net, "timeout waiting for device ready");
824 return -EIO;
825}
826
759static int smsc75xx_reset(struct usbnet *dev) 827static int smsc75xx_reset(struct usbnet *dev)
760{ 828{
761 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); 829 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
@@ -764,6 +832,9 @@ static int smsc75xx_reset(struct usbnet *dev)
764 832
765 netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset"); 833 netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset");
766 834
835 ret = smsc75xx_wait_ready(dev);
836 check_warn_return(ret, "device not ready in smsc75xx_reset");
837
767 ret = smsc75xx_read_reg(dev, HW_CFG, &buf); 838 ret = smsc75xx_read_reg(dev, HW_CFG, &buf);
768 check_warn_return(ret, "Failed to read HW_CFG: %d", ret); 839 check_warn_return(ret, "Failed to read HW_CFG: %d", ret);
769 840
@@ -1083,6 +1154,169 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
1083 } 1154 }
1084} 1155}
1085 1156
1157static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message)
1158{
1159 struct usbnet *dev = usb_get_intfdata(intf);
1160 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1161 int ret;
1162 u32 val;
1163
1164 ret = usbnet_suspend(intf, message);
1165 check_warn_return(ret, "usbnet_suspend error");
1166
1167 /* if no wol options set, enter lowest power SUSPEND2 mode */
1168 if (!(pdata->wolopts & SUPPORTED_WAKE)) {
1169 netdev_info(dev->net, "entering SUSPEND2 mode");
1170
1171 /* disable energy detect (link up) & wake up events */
1172 ret = smsc75xx_read_reg(dev, WUCSR, &val);
1173 check_warn_return(ret, "Error reading WUCSR");
1174
1175 val &= ~(WUCSR_MPEN | WUCSR_WUEN);
1176
1177 ret = smsc75xx_write_reg(dev, WUCSR, val);
1178 check_warn_return(ret, "Error writing WUCSR");
1179
1180 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1181 check_warn_return(ret, "Error reading PMT_CTL");
1182
1183 val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN);
1184
1185 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1186 check_warn_return(ret, "Error writing PMT_CTL");
1187
1188 /* enter suspend2 mode */
1189 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1190 check_warn_return(ret, "Error reading PMT_CTL");
1191
1192 val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST);
1193 val |= PMT_CTL_SUS_MODE_2;
1194
1195 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1196 check_warn_return(ret, "Error writing PMT_CTL");
1197
1198 return 0;
1199 }
1200
1201 if (pdata->wolopts & WAKE_MAGIC) {
1202 /* clear any pending magic packet status */
1203 ret = smsc75xx_read_reg(dev, WUCSR, &val);
1204 check_warn_return(ret, "Error reading WUCSR");
1205
1206 val |= WUCSR_MPR;
1207
1208 ret = smsc75xx_write_reg(dev, WUCSR, val);
1209 check_warn_return(ret, "Error writing WUCSR");
1210 }
1211
1212 /* enable/disable magic packup wake */
1213 ret = smsc75xx_read_reg(dev, WUCSR, &val);
1214 check_warn_return(ret, "Error reading WUCSR");
1215
1216 if (pdata->wolopts & WAKE_MAGIC) {
1217 netdev_info(dev->net, "enabling magic packet wakeup");
1218 val |= WUCSR_MPEN;
1219 } else {
1220 netdev_info(dev->net, "disabling magic packet wakeup");
1221 val &= ~WUCSR_MPEN;
1222 }
1223
1224 ret = smsc75xx_write_reg(dev, WUCSR, val);
1225 check_warn_return(ret, "Error writing WUCSR");
1226
1227 /* enable wol wakeup source */
1228 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1229 check_warn_return(ret, "Error reading PMT_CTL");
1230
1231 val |= PMT_CTL_WOL_EN;
1232
1233 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1234 check_warn_return(ret, "Error writing PMT_CTL");
1235
1236 /* enable receiver */
1237 ret = smsc75xx_read_reg(dev, MAC_RX, &val);
1238 check_warn_return(ret, "Failed to read MAC_RX: %d", ret);
1239
1240 val |= MAC_RX_RXEN;
1241
1242 ret = smsc75xx_write_reg(dev, MAC_RX, val);
1243 check_warn_return(ret, "Failed to write MAC_RX: %d", ret);
1244
1245 /* some wol options are enabled, so enter SUSPEND0 */
1246 netdev_info(dev->net, "entering SUSPEND0 mode");
1247
1248 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1249 check_warn_return(ret, "Error reading PMT_CTL");
1250
1251 val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST));
1252 val |= PMT_CTL_SUS_MODE_0;
1253
1254 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1255 check_warn_return(ret, "Error writing PMT_CTL");
1256
1257 /* clear wol status */
1258 val &= ~PMT_CTL_WUPS;
1259 val |= PMT_CTL_WUPS_WOL;
1260 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1261 check_warn_return(ret, "Error writing PMT_CTL");
1262
1263 /* read back PMT_CTL */
1264 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1265 check_warn_return(ret, "Error reading PMT_CTL");
1266
1267 smsc75xx_set_feature(dev, USB_DEVICE_REMOTE_WAKEUP);
1268
1269 return 0;
1270}
1271
1272static int smsc75xx_resume(struct usb_interface *intf)
1273{
1274 struct usbnet *dev = usb_get_intfdata(intf);
1275 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
1276 int ret;
1277 u32 val;
1278
1279 if (pdata->wolopts & WAKE_MAGIC) {
1280 netdev_info(dev->net, "resuming from SUSPEND0");
1281
1282 smsc75xx_clear_feature(dev, USB_DEVICE_REMOTE_WAKEUP);
1283
1284 /* Disable magic packup wake */
1285 ret = smsc75xx_read_reg(dev, WUCSR, &val);
1286 check_warn_return(ret, "Error reading WUCSR");
1287
1288 val &= ~WUCSR_MPEN;
1289
1290 ret = smsc75xx_write_reg(dev, WUCSR, val);
1291 check_warn_return(ret, "Error writing WUCSR");
1292
1293 /* clear wake-up status */
1294 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1295 check_warn_return(ret, "Error reading PMT_CTL");
1296
1297 val &= ~PMT_CTL_WOL_EN;
1298 val |= PMT_CTL_WUPS;
1299
1300 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1301 check_warn_return(ret, "Error writing PMT_CTL");
1302 } else {
1303 netdev_info(dev->net, "resuming from SUSPEND2");
1304
1305 ret = smsc75xx_read_reg(dev, PMT_CTL, &val);
1306 check_warn_return(ret, "Error reading PMT_CTL");
1307
1308 val |= PMT_CTL_PHY_PWRUP;
1309
1310 ret = smsc75xx_write_reg(dev, PMT_CTL, val);
1311 check_warn_return(ret, "Error writing PMT_CTL");
1312 }
1313
1314 ret = smsc75xx_wait_ready(dev);
1315 check_warn_return(ret, "device not ready in smsc75xx_resume");
1316
1317 return usbnet_resume(intf);
1318}
1319
1086static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb, 1320static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb,
1087 u32 rx_cmd_a, u32 rx_cmd_b) 1321 u32 rx_cmd_a, u32 rx_cmd_b)
1088{ 1322{
@@ -1251,9 +1485,9 @@ static struct usb_driver smsc75xx_driver = {
1251 .name = SMSC_CHIPNAME, 1485 .name = SMSC_CHIPNAME,
1252 .id_table = products, 1486 .id_table = products,
1253 .probe = usbnet_probe, 1487 .probe = usbnet_probe,
1254 .suspend = usbnet_suspend, 1488 .suspend = smsc75xx_suspend,
1255 .resume = usbnet_resume, 1489 .resume = smsc75xx_resume,
1256 .reset_resume = usbnet_resume, 1490 .reset_resume = smsc75xx_resume,
1257 .disconnect = usbnet_disconnect, 1491 .disconnect = usbnet_disconnect,
1258 .disable_hub_initiated_lpm = 1, 1492 .disable_hub_initiated_lpm = 1,
1259}; 1493};
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index d45e539a84b..7479a5761d0 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -46,11 +46,22 @@
46#define SMSC95XX_INTERNAL_PHY_ID (1) 46#define SMSC95XX_INTERNAL_PHY_ID (1)
47#define SMSC95XX_TX_OVERHEAD (8) 47#define SMSC95XX_TX_OVERHEAD (8)
48#define SMSC95XX_TX_OVERHEAD_CSUM (12) 48#define SMSC95XX_TX_OVERHEAD_CSUM (12)
49#define SUPPORTED_WAKE (WAKE_MAGIC)
50
51#define check_warn(ret, fmt, args...) \
52 ({ if (ret < 0) netdev_warn(dev->net, fmt, ##args); })
53
54#define check_warn_return(ret, fmt, args...) \
55 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); return ret; } })
56
57#define check_warn_goto_done(ret, fmt, args...) \
58 ({ if (ret < 0) { netdev_warn(dev->net, fmt, ##args); goto done; } })
49 59
50struct smsc95xx_priv { 60struct smsc95xx_priv {
51 u32 mac_cr; 61 u32 mac_cr;
52 u32 hash_hi; 62 u32 hash_hi;
53 u32 hash_lo; 63 u32 hash_lo;
64 u32 wolopts;
54 spinlock_t mac_cr_lock; 65 spinlock_t mac_cr_lock;
55}; 66};
56 67
@@ -63,7 +74,8 @@ static bool turbo_mode = true;
63module_param(turbo_mode, bool, 0644); 74module_param(turbo_mode, bool, 0644);
64MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); 75MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
65 76
66static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data) 77static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
78 u32 *data)
67{ 79{
68 u32 *buf = kmalloc(4, GFP_KERNEL); 80 u32 *buf = kmalloc(4, GFP_KERNEL);
69 int ret; 81 int ret;
@@ -88,7 +100,8 @@ static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data)
88 return ret; 100 return ret;
89} 101}
90 102
91static int smsc95xx_write_reg(struct usbnet *dev, u32 index, u32 data) 103static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
104 u32 data)
92{ 105{
93 u32 *buf = kmalloc(4, GFP_KERNEL); 106 u32 *buf = kmalloc(4, GFP_KERNEL);
94 int ret; 107 int ret;
@@ -114,15 +127,41 @@ static int smsc95xx_write_reg(struct usbnet *dev, u32 index, u32 data)
114 return ret; 127 return ret;
115} 128}
116 129
130static int smsc95xx_set_feature(struct usbnet *dev, u32 feature)
131{
132 if (WARN_ON_ONCE(!dev))
133 return -EINVAL;
134
135 cpu_to_le32s(&feature);
136
137 return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
138 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
139 USB_CTRL_SET_TIMEOUT);
140}
141
142static int smsc95xx_clear_feature(struct usbnet *dev, u32 feature)
143{
144 if (WARN_ON_ONCE(!dev))
145 return -EINVAL;
146
147 cpu_to_le32s(&feature);
148
149 return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
150 USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
151 USB_CTRL_SET_TIMEOUT);
152}
153
117/* Loop until the read is completed with timeout 154/* Loop until the read is completed with timeout
118 * called with phy_mutex held */ 155 * called with phy_mutex held */
119static int smsc95xx_phy_wait_not_busy(struct usbnet *dev) 156static int __must_check smsc95xx_phy_wait_not_busy(struct usbnet *dev)
120{ 157{
121 unsigned long start_time = jiffies; 158 unsigned long start_time = jiffies;
122 u32 val; 159 u32 val;
160 int ret;
123 161
124 do { 162 do {
125 smsc95xx_read_reg(dev, MII_ADDR, &val); 163 ret = smsc95xx_read_reg(dev, MII_ADDR, &val);
164 check_warn_return(ret, "Error reading MII_ACCESS");
126 if (!(val & MII_BUSY_)) 165 if (!(val & MII_BUSY_))
127 return 0; 166 return 0;
128 } while (!time_after(jiffies, start_time + HZ)); 167 } while (!time_after(jiffies, start_time + HZ));
@@ -134,33 +173,32 @@ static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
134{ 173{
135 struct usbnet *dev = netdev_priv(netdev); 174 struct usbnet *dev = netdev_priv(netdev);
136 u32 val, addr; 175 u32 val, addr;
176 int ret;
137 177
138 mutex_lock(&dev->phy_mutex); 178 mutex_lock(&dev->phy_mutex);
139 179
140 /* confirm MII not busy */ 180 /* confirm MII not busy */
141 if (smsc95xx_phy_wait_not_busy(dev)) { 181 ret = smsc95xx_phy_wait_not_busy(dev);
142 netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_read\n"); 182 check_warn_goto_done(ret, "MII is busy in smsc95xx_mdio_read");
143 mutex_unlock(&dev->phy_mutex);
144 return -EIO;
145 }
146 183
147 /* set the address, index & direction (read from PHY) */ 184 /* set the address, index & direction (read from PHY) */
148 phy_id &= dev->mii.phy_id_mask; 185 phy_id &= dev->mii.phy_id_mask;
149 idx &= dev->mii.reg_num_mask; 186 idx &= dev->mii.reg_num_mask;
150 addr = (phy_id << 11) | (idx << 6) | MII_READ_; 187 addr = (phy_id << 11) | (idx << 6) | MII_READ_;
151 smsc95xx_write_reg(dev, MII_ADDR, addr); 188 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
189 check_warn_goto_done(ret, "Error writing MII_ADDR");
152 190
153 if (smsc95xx_phy_wait_not_busy(dev)) { 191 ret = smsc95xx_phy_wait_not_busy(dev);
154 netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); 192 check_warn_goto_done(ret, "Timed out reading MII reg %02X", idx);
155 mutex_unlock(&dev->phy_mutex);
156 return -EIO;
157 }
158 193
159 smsc95xx_read_reg(dev, MII_DATA, &val); 194 ret = smsc95xx_read_reg(dev, MII_DATA, &val);
195 check_warn_goto_done(ret, "Error reading MII_DATA");
160 196
161 mutex_unlock(&dev->phy_mutex); 197 ret = (u16)(val & 0xFFFF);
162 198
163 return (u16)(val & 0xFFFF); 199done:
200 mutex_unlock(&dev->phy_mutex);
201 return ret;
164} 202}
165 203
166static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, 204static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
@@ -168,38 +206,41 @@ static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
168{ 206{
169 struct usbnet *dev = netdev_priv(netdev); 207 struct usbnet *dev = netdev_priv(netdev);
170 u32 val, addr; 208 u32 val, addr;
209 int ret;
171 210
172 mutex_lock(&dev->phy_mutex); 211 mutex_lock(&dev->phy_mutex);
173 212
174 /* confirm MII not busy */ 213 /* confirm MII not busy */
175 if (smsc95xx_phy_wait_not_busy(dev)) { 214 ret = smsc95xx_phy_wait_not_busy(dev);
176 netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_write\n"); 215 check_warn_goto_done(ret, "MII is busy in smsc95xx_mdio_write");
177 mutex_unlock(&dev->phy_mutex);
178 return;
179 }
180 216
181 val = regval; 217 val = regval;
182 smsc95xx_write_reg(dev, MII_DATA, val); 218 ret = smsc95xx_write_reg(dev, MII_DATA, val);
219 check_warn_goto_done(ret, "Error writing MII_DATA");
183 220
184 /* set the address, index & direction (write to PHY) */ 221 /* set the address, index & direction (write to PHY) */
185 phy_id &= dev->mii.phy_id_mask; 222 phy_id &= dev->mii.phy_id_mask;
186 idx &= dev->mii.reg_num_mask; 223 idx &= dev->mii.reg_num_mask;
187 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_; 224 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_;
188 smsc95xx_write_reg(dev, MII_ADDR, addr); 225 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
226 check_warn_goto_done(ret, "Error writing MII_ADDR");
189 227
190 if (smsc95xx_phy_wait_not_busy(dev)) 228 ret = smsc95xx_phy_wait_not_busy(dev);
191 netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); 229 check_warn_goto_done(ret, "Timed out writing MII reg %02X", idx);
192 230
231done:
193 mutex_unlock(&dev->phy_mutex); 232 mutex_unlock(&dev->phy_mutex);
194} 233}
195 234
196static int smsc95xx_wait_eeprom(struct usbnet *dev) 235static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev)
197{ 236{
198 unsigned long start_time = jiffies; 237 unsigned long start_time = jiffies;
199 u32 val; 238 u32 val;
239 int ret;
200 240
201 do { 241 do {
202 smsc95xx_read_reg(dev, E2P_CMD, &val); 242 ret = smsc95xx_read_reg(dev, E2P_CMD, &val);
243 check_warn_return(ret, "Error reading E2P_CMD");
203 if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_)) 244 if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_))
204 break; 245 break;
205 udelay(40); 246 udelay(40);
@@ -213,13 +254,15 @@ static int smsc95xx_wait_eeprom(struct usbnet *dev)
213 return 0; 254 return 0;
214} 255}
215 256
216static int smsc95xx_eeprom_confirm_not_busy(struct usbnet *dev) 257static int __must_check smsc95xx_eeprom_confirm_not_busy(struct usbnet *dev)
217{ 258{
218 unsigned long start_time = jiffies; 259 unsigned long start_time = jiffies;
219 u32 val; 260 u32 val;
261 int ret;
220 262
221 do { 263 do {
222 smsc95xx_read_reg(dev, E2P_CMD, &val); 264 ret = smsc95xx_read_reg(dev, E2P_CMD, &val);
265 check_warn_return(ret, "Error reading E2P_CMD");
223 266
224 if (!(val & E2P_CMD_BUSY_)) 267 if (!(val & E2P_CMD_BUSY_))
225 return 0; 268 return 0;
@@ -246,13 +289,15 @@ static int smsc95xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length,
246 289
247 for (i = 0; i < length; i++) { 290 for (i = 0; i < length; i++) {
248 val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_); 291 val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_);
249 smsc95xx_write_reg(dev, E2P_CMD, val); 292 ret = smsc95xx_write_reg(dev, E2P_CMD, val);
293 check_warn_return(ret, "Error writing E2P_CMD");
250 294
251 ret = smsc95xx_wait_eeprom(dev); 295 ret = smsc95xx_wait_eeprom(dev);
252 if (ret < 0) 296 if (ret < 0)
253 return ret; 297 return ret;
254 298
255 smsc95xx_read_reg(dev, E2P_DATA, &val); 299 ret = smsc95xx_read_reg(dev, E2P_DATA, &val);
300 check_warn_return(ret, "Error reading E2P_DATA");
256 301
257 data[i] = val & 0xFF; 302 data[i] = val & 0xFF;
258 offset++; 303 offset++;
@@ -276,7 +321,8 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
276 321
277 /* Issue write/erase enable command */ 322 /* Issue write/erase enable command */
278 val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_; 323 val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_;
279 smsc95xx_write_reg(dev, E2P_CMD, val); 324 ret = smsc95xx_write_reg(dev, E2P_CMD, val);
325 check_warn_return(ret, "Error writing E2P_DATA");
280 326
281 ret = smsc95xx_wait_eeprom(dev); 327 ret = smsc95xx_wait_eeprom(dev);
282 if (ret < 0) 328 if (ret < 0)
@@ -286,11 +332,13 @@ static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length,
286 332
287 /* Fill data register */ 333 /* Fill data register */
288 val = data[i]; 334 val = data[i];
289 smsc95xx_write_reg(dev, E2P_DATA, val); 335 ret = smsc95xx_write_reg(dev, E2P_DATA, val);
336 check_warn_return(ret, "Error writing E2P_DATA");
290 337
291 /* Send "write" command */ 338 /* Send "write" command */
292 val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_); 339 val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_);
293 smsc95xx_write_reg(dev, E2P_CMD, val); 340 ret = smsc95xx_write_reg(dev, E2P_CMD, val);
341 check_warn_return(ret, "Error writing E2P_CMD");
294 342
295 ret = smsc95xx_wait_eeprom(dev); 343 ret = smsc95xx_wait_eeprom(dev);
296 if (ret < 0) 344 if (ret < 0)
@@ -308,14 +356,14 @@ static void smsc95xx_async_cmd_callback(struct urb *urb)
308 struct usbnet *dev = usb_context->dev; 356 struct usbnet *dev = usb_context->dev;
309 int status = urb->status; 357 int status = urb->status;
310 358
311 if (status < 0) 359 check_warn(status, "async callback failed with %d\n", status);
312 netdev_warn(dev->net, "async callback failed with %d\n", status);
313 360
314 kfree(usb_context); 361 kfree(usb_context);
315 usb_free_urb(urb); 362 usb_free_urb(urb);
316} 363}
317 364
318static int smsc95xx_write_reg_async(struct usbnet *dev, u16 index, u32 *data) 365static int __must_check smsc95xx_write_reg_async(struct usbnet *dev, u16 index,
366 u32 *data)
319{ 367{
320 struct usb_context *usb_context; 368 struct usb_context *usb_context;
321 int status; 369 int status;
@@ -371,6 +419,7 @@ static void smsc95xx_set_multicast(struct net_device *netdev)
371 struct usbnet *dev = netdev_priv(netdev); 419 struct usbnet *dev = netdev_priv(netdev);
372 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 420 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
373 unsigned long flags; 421 unsigned long flags;
422 int ret;
374 423
375 pdata->hash_hi = 0; 424 pdata->hash_hi = 0;
376 pdata->hash_lo = 0; 425 pdata->hash_lo = 0;
@@ -411,21 +460,23 @@ static void smsc95xx_set_multicast(struct net_device *netdev)
411 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); 460 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
412 461
413 /* Initiate async writes, as we can't wait for completion here */ 462 /* Initiate async writes, as we can't wait for completion here */
414 smsc95xx_write_reg_async(dev, HASHH, &pdata->hash_hi); 463 ret = smsc95xx_write_reg_async(dev, HASHH, &pdata->hash_hi);
415 smsc95xx_write_reg_async(dev, HASHL, &pdata->hash_lo); 464 check_warn(ret, "failed to initiate async write to HASHH");
416 smsc95xx_write_reg_async(dev, MAC_CR, &pdata->mac_cr); 465
466 ret = smsc95xx_write_reg_async(dev, HASHL, &pdata->hash_lo);
467 check_warn(ret, "failed to initiate async write to HASHL");
468
469 ret = smsc95xx_write_reg_async(dev, MAC_CR, &pdata->mac_cr);
470 check_warn(ret, "failed to initiate async write to MAC_CR");
417} 471}
418 472
419static void smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, 473static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
420 u16 lcladv, u16 rmtadv) 474 u16 lcladv, u16 rmtadv)
421{ 475{
422 u32 flow, afc_cfg = 0; 476 u32 flow, afc_cfg = 0;
423 477
424 int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg); 478 int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg);
425 if (ret < 0) { 479 check_warn_return(ret, "Error reading AFC_CFG");
426 netdev_warn(dev->net, "error reading AFC_CFG\n");
427 return;
428 }
429 480
430 if (duplex == DUPLEX_FULL) { 481 if (duplex == DUPLEX_FULL) {
431 u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); 482 u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
@@ -449,8 +500,13 @@ static void smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,
449 afc_cfg |= 0xF; 500 afc_cfg |= 0xF;
450 } 501 }
451 502
452 smsc95xx_write_reg(dev, FLOW, flow); 503 ret = smsc95xx_write_reg(dev, FLOW, flow);
453 smsc95xx_write_reg(dev, AFC_CFG, afc_cfg); 504 check_warn_return(ret, "Error writing FLOW");
505
506 ret = smsc95xx_write_reg(dev, AFC_CFG, afc_cfg);
507 check_warn_return(ret, "Error writing AFC_CFG");
508
509 return 0;
454} 510}
455 511
456static int smsc95xx_link_reset(struct usbnet *dev) 512static int smsc95xx_link_reset(struct usbnet *dev)
@@ -460,12 +516,14 @@ static int smsc95xx_link_reset(struct usbnet *dev)
460 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; 516 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
461 unsigned long flags; 517 unsigned long flags;
462 u16 lcladv, rmtadv; 518 u16 lcladv, rmtadv;
463 u32 intdata; 519 int ret;
464 520
465 /* clear interrupt status */ 521 /* clear interrupt status */
466 smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); 522 ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC);
467 intdata = 0xFFFFFFFF; 523 check_warn_return(ret, "Error reading PHY_INT_SRC");
468 smsc95xx_write_reg(dev, INT_STS, intdata); 524
525 ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_);
526 check_warn_return(ret, "Error writing INT_STS");
469 527
470 mii_check_media(mii, 1, 1); 528 mii_check_media(mii, 1, 1);
471 mii_ethtool_gset(&dev->mii, &ecmd); 529 mii_ethtool_gset(&dev->mii, &ecmd);
@@ -486,9 +544,11 @@ static int smsc95xx_link_reset(struct usbnet *dev)
486 } 544 }
487 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); 545 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
488 546
489 smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); 547 ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
548 check_warn_return(ret, "Error writing MAC_CR");
490 549
491 smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); 550 ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv);
551 check_warn_return(ret, "Error updating PHY flow control");
492 552
493 return 0; 553 return 0;
494} 554}
@@ -524,10 +584,7 @@ static int smsc95xx_set_features(struct net_device *netdev,
524 int ret; 584 int ret;
525 585
526 ret = smsc95xx_read_reg(dev, COE_CR, &read_buf); 586 ret = smsc95xx_read_reg(dev, COE_CR, &read_buf);
527 if (ret < 0) { 587 check_warn_return(ret, "Failed to read COE_CR: %d\n", ret);
528 netdev_warn(dev->net, "Failed to read COE_CR: %d\n", ret);
529 return ret;
530 }
531 588
532 if (features & NETIF_F_HW_CSUM) 589 if (features & NETIF_F_HW_CSUM)
533 read_buf |= Tx_COE_EN_; 590 read_buf |= Tx_COE_EN_;
@@ -540,10 +597,7 @@ static int smsc95xx_set_features(struct net_device *netdev,
540 read_buf &= ~Rx_COE_EN_; 597 read_buf &= ~Rx_COE_EN_;
541 598
542 ret = smsc95xx_write_reg(dev, COE_CR, read_buf); 599 ret = smsc95xx_write_reg(dev, COE_CR, read_buf);
543 if (ret < 0) { 600 check_warn_return(ret, "Failed to write COE_CR: %d\n", ret);
544 netdev_warn(dev->net, "Failed to write COE_CR: %d\n", ret);
545 return ret;
546 }
547 601
548 netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf); 602 netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf);
549 return 0; 603 return 0;
@@ -608,6 +662,26 @@ smsc95xx_ethtool_getregs(struct net_device *netdev, struct ethtool_regs *regs,
608 } 662 }
609} 663}
610 664
665static void smsc95xx_ethtool_get_wol(struct net_device *net,
666 struct ethtool_wolinfo *wolinfo)
667{
668 struct usbnet *dev = netdev_priv(net);
669 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
670
671 wolinfo->supported = SUPPORTED_WAKE;
672 wolinfo->wolopts = pdata->wolopts;
673}
674
675static int smsc95xx_ethtool_set_wol(struct net_device *net,
676 struct ethtool_wolinfo *wolinfo)
677{
678 struct usbnet *dev = netdev_priv(net);
679 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
680
681 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
682 return 0;
683}
684
611static const struct ethtool_ops smsc95xx_ethtool_ops = { 685static const struct ethtool_ops smsc95xx_ethtool_ops = {
612 .get_link = usbnet_get_link, 686 .get_link = usbnet_get_link,
613 .nway_reset = usbnet_nway_reset, 687 .nway_reset = usbnet_nway_reset,
@@ -621,6 +695,8 @@ static const struct ethtool_ops smsc95xx_ethtool_ops = {
621 .set_eeprom = smsc95xx_ethtool_set_eeprom, 695 .set_eeprom = smsc95xx_ethtool_set_eeprom,
622 .get_regs_len = smsc95xx_ethtool_getregslen, 696 .get_regs_len = smsc95xx_ethtool_getregslen,
623 .get_regs = smsc95xx_ethtool_getregs, 697 .get_regs = smsc95xx_ethtool_getregs,
698 .get_wol = smsc95xx_ethtool_get_wol,
699 .set_wol = smsc95xx_ethtool_set_wol,
624}; 700};
625 701
626static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) 702static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
@@ -658,55 +734,56 @@ static int smsc95xx_set_mac_address(struct usbnet *dev)
658 int ret; 734 int ret;
659 735
660 ret = smsc95xx_write_reg(dev, ADDRL, addr_lo); 736 ret = smsc95xx_write_reg(dev, ADDRL, addr_lo);
661 if (ret < 0) { 737 check_warn_return(ret, "Failed to write ADDRL: %d\n", ret);
662 netdev_warn(dev->net, "Failed to write ADDRL: %d\n", ret);
663 return ret;
664 }
665 738
666 ret = smsc95xx_write_reg(dev, ADDRH, addr_hi); 739 ret = smsc95xx_write_reg(dev, ADDRH, addr_hi);
667 if (ret < 0) { 740 check_warn_return(ret, "Failed to write ADDRH: %d\n", ret);
668 netdev_warn(dev->net, "Failed to write ADDRH: %d\n", ret);
669 return ret;
670 }
671 741
672 return 0; 742 return 0;
673} 743}
674 744
675/* starts the TX path */ 745/* starts the TX path */
676static void smsc95xx_start_tx_path(struct usbnet *dev) 746static int smsc95xx_start_tx_path(struct usbnet *dev)
677{ 747{
678 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 748 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
679 unsigned long flags; 749 unsigned long flags;
680 u32 reg_val; 750 int ret;
681 751
682 /* Enable Tx at MAC */ 752 /* Enable Tx at MAC */
683 spin_lock_irqsave(&pdata->mac_cr_lock, flags); 753 spin_lock_irqsave(&pdata->mac_cr_lock, flags);
684 pdata->mac_cr |= MAC_CR_TXEN_; 754 pdata->mac_cr |= MAC_CR_TXEN_;
685 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); 755 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
686 756
687 smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); 757 ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
758 check_warn_return(ret, "Failed to write MAC_CR: %d\n", ret);
688 759
689 /* Enable Tx at SCSRs */ 760 /* Enable Tx at SCSRs */
690 reg_val = TX_CFG_ON_; 761 ret = smsc95xx_write_reg(dev, TX_CFG, TX_CFG_ON_);
691 smsc95xx_write_reg(dev, TX_CFG, reg_val); 762 check_warn_return(ret, "Failed to write TX_CFG: %d\n", ret);
763
764 return 0;
692} 765}
693 766
694/* Starts the Receive path */ 767/* Starts the Receive path */
695static void smsc95xx_start_rx_path(struct usbnet *dev) 768static int smsc95xx_start_rx_path(struct usbnet *dev)
696{ 769{
697 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 770 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
698 unsigned long flags; 771 unsigned long flags;
772 int ret;
699 773
700 spin_lock_irqsave(&pdata->mac_cr_lock, flags); 774 spin_lock_irqsave(&pdata->mac_cr_lock, flags);
701 pdata->mac_cr |= MAC_CR_RXEN_; 775 pdata->mac_cr |= MAC_CR_RXEN_;
702 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); 776 spin_unlock_irqrestore(&pdata->mac_cr_lock, flags);
703 777
704 smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); 778 ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr);
779 check_warn_return(ret, "Failed to write MAC_CR: %d\n", ret);
780
781 return 0;
705} 782}
706 783
707static int smsc95xx_phy_initialize(struct usbnet *dev) 784static int smsc95xx_phy_initialize(struct usbnet *dev)
708{ 785{
709 int bmcr, timeout = 0; 786 int bmcr, ret, timeout = 0;
710 787
711 /* Initialize MII structure */ 788 /* Initialize MII structure */
712 dev->mii.dev = dev->net; 789 dev->mii.dev = dev->net;
@@ -735,7 +812,8 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
735 ADVERTISE_PAUSE_ASYM); 812 ADVERTISE_PAUSE_ASYM);
736 813
737 /* read to clear */ 814 /* read to clear */
738 smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); 815 ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
816 check_warn_return(ret, "Failed to read PHY_INT_SRC during init");
739 817
740 smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, 818 smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK,
741 PHY_INT_MASK_DEFAULT_); 819 PHY_INT_MASK_DEFAULT_);
@@ -753,22 +831,14 @@ static int smsc95xx_reset(struct usbnet *dev)
753 831
754 netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); 832 netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n");
755 833
756 write_buf = HW_CFG_LRST_; 834 ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_);
757 ret = smsc95xx_write_reg(dev, HW_CFG, write_buf); 835 check_warn_return(ret, "Failed to write HW_CFG_LRST_ bit in HW_CFG\n");
758 if (ret < 0) {
759 netdev_warn(dev->net, "Failed to write HW_CFG_LRST_ bit in HW_CFG register, ret = %d\n",
760 ret);
761 return ret;
762 }
763 836
764 timeout = 0; 837 timeout = 0;
765 do { 838 do {
766 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
767 if (ret < 0) {
768 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
769 return ret;
770 }
771 msleep(10); 839 msleep(10);
840 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
841 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret);
772 timeout++; 842 timeout++;
773 } while ((read_buf & HW_CFG_LRST_) && (timeout < 100)); 843 } while ((read_buf & HW_CFG_LRST_) && (timeout < 100));
774 844
@@ -777,21 +847,14 @@ static int smsc95xx_reset(struct usbnet *dev)
777 return ret; 847 return ret;
778 } 848 }
779 849
780 write_buf = PM_CTL_PHY_RST_; 850 ret = smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_);
781 ret = smsc95xx_write_reg(dev, PM_CTRL, write_buf); 851 check_warn_return(ret, "Failed to write PM_CTRL: %d\n", ret);
782 if (ret < 0) {
783 netdev_warn(dev->net, "Failed to write PM_CTRL: %d\n", ret);
784 return ret;
785 }
786 852
787 timeout = 0; 853 timeout = 0;
788 do { 854 do {
789 ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf);
790 if (ret < 0) {
791 netdev_warn(dev->net, "Failed to read PM_CTRL: %d\n", ret);
792 return ret;
793 }
794 msleep(10); 855 msleep(10);
856 ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf);
857 check_warn_return(ret, "Failed to read PM_CTRL: %d\n", ret);
795 timeout++; 858 timeout++;
796 } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100)); 859 } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100));
797 860
@@ -808,10 +871,7 @@ static int smsc95xx_reset(struct usbnet *dev)
808 "MAC Address: %pM\n", dev->net->dev_addr); 871 "MAC Address: %pM\n", dev->net->dev_addr);
809 872
810 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); 873 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
811 if (ret < 0) { 874 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret);
812 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
813 return ret;
814 }
815 875
816 netif_dbg(dev, ifup, dev->net, 876 netif_dbg(dev, ifup, dev->net,
817 "Read Value from HW_CFG : 0x%08x\n", read_buf); 877 "Read Value from HW_CFG : 0x%08x\n", read_buf);
@@ -819,17 +879,10 @@ static int smsc95xx_reset(struct usbnet *dev)
819 read_buf |= HW_CFG_BIR_; 879 read_buf |= HW_CFG_BIR_;
820 880
821 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); 881 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
822 if (ret < 0) { 882 check_warn_return(ret, "Failed to write HW_CFG_BIR_ bit in HW_CFG\n");
823 netdev_warn(dev->net, "Failed to write HW_CFG_BIR_ bit in HW_CFG register, ret = %d\n",
824 ret);
825 return ret;
826 }
827 883
828 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); 884 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
829 if (ret < 0) { 885 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret);
830 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret);
831 return ret;
832 }
833 netif_dbg(dev, ifup, dev->net, 886 netif_dbg(dev, ifup, dev->net,
834 "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n", 887 "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n",
835 read_buf); 888 read_buf);
@@ -849,41 +902,28 @@ static int smsc95xx_reset(struct usbnet *dev)
849 "rx_urb_size=%ld\n", (ulong)dev->rx_urb_size); 902 "rx_urb_size=%ld\n", (ulong)dev->rx_urb_size);
850 903
851 ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap); 904 ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap);
852 if (ret < 0) { 905 check_warn_return(ret, "Failed to write BURST_CAP: %d\n", ret);
853 netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret);
854 return ret;
855 }
856 906
857 ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf); 907 ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf);
858 if (ret < 0) { 908 check_warn_return(ret, "Failed to read BURST_CAP: %d\n", ret);
859 netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret); 909
860 return ret;
861 }
862 netif_dbg(dev, ifup, dev->net, 910 netif_dbg(dev, ifup, dev->net,
863 "Read Value from BURST_CAP after writing: 0x%08x\n", 911 "Read Value from BURST_CAP after writing: 0x%08x\n",
864 read_buf); 912 read_buf);
865 913
866 read_buf = DEFAULT_BULK_IN_DELAY; 914 ret = smsc95xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY);
867 ret = smsc95xx_write_reg(dev, BULK_IN_DLY, read_buf); 915 check_warn_return(ret, "Failed to write BULK_IN_DLY: %d\n", ret);
868 if (ret < 0) {
869 netdev_warn(dev->net, "ret = %d\n", ret);
870 return ret;
871 }
872 916
873 ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf); 917 ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf);
874 if (ret < 0) { 918 check_warn_return(ret, "Failed to read BULK_IN_DLY: %d\n", ret);
875 netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret); 919
876 return ret;
877 }
878 netif_dbg(dev, ifup, dev->net, 920 netif_dbg(dev, ifup, dev->net,
879 "Read Value from BULK_IN_DLY after writing: 0x%08x\n", 921 "Read Value from BULK_IN_DLY after writing: 0x%08x\n",
880 read_buf); 922 read_buf);
881 923
882 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); 924 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
883 if (ret < 0) { 925 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret);
884 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); 926
885 return ret;
886 }
887 netif_dbg(dev, ifup, dev->net, 927 netif_dbg(dev, ifup, dev->net,
888 "Read Value from HW_CFG: 0x%08x\n", read_buf); 928 "Read Value from HW_CFG: 0x%08x\n", read_buf);
889 929
@@ -896,101 +936,66 @@ static int smsc95xx_reset(struct usbnet *dev)
896 read_buf |= NET_IP_ALIGN << 9; 936 read_buf |= NET_IP_ALIGN << 9;
897 937
898 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); 938 ret = smsc95xx_write_reg(dev, HW_CFG, read_buf);
899 if (ret < 0) { 939 check_warn_return(ret, "Failed to write HW_CFG: %d\n", ret);
900 netdev_warn(dev->net, "Failed to write HW_CFG register, ret=%d\n",
901 ret);
902 return ret;
903 }
904 940
905 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); 941 ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf);
906 if (ret < 0) { 942 check_warn_return(ret, "Failed to read HW_CFG: %d\n", ret);
907 netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); 943
908 return ret;
909 }
910 netif_dbg(dev, ifup, dev->net, 944 netif_dbg(dev, ifup, dev->net,
911 "Read Value from HW_CFG after writing: 0x%08x\n", read_buf); 945 "Read Value from HW_CFG after writing: 0x%08x\n", read_buf);
912 946
913 write_buf = 0xFFFFFFFF; 947 ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_);
914 ret = smsc95xx_write_reg(dev, INT_STS, write_buf); 948 check_warn_return(ret, "Failed to write INT_STS: %d\n", ret);
915 if (ret < 0) {
916 netdev_warn(dev->net, "Failed to write INT_STS register, ret=%d\n",
917 ret);
918 return ret;
919 }
920 949
921 ret = smsc95xx_read_reg(dev, ID_REV, &read_buf); 950 ret = smsc95xx_read_reg(dev, ID_REV, &read_buf);
922 if (ret < 0) { 951 check_warn_return(ret, "Failed to read ID_REV: %d\n", ret);
923 netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret);
924 return ret;
925 }
926 netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf); 952 netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf);
927 953
928 /* Configure GPIO pins as LED outputs */ 954 /* Configure GPIO pins as LED outputs */
929 write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED | 955 write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
930 LED_GPIO_CFG_FDX_LED; 956 LED_GPIO_CFG_FDX_LED;
931 ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf); 957 ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf);
932 if (ret < 0) { 958 check_warn_return(ret, "Failed to write LED_GPIO_CFG: %d\n", ret);
933 netdev_warn(dev->net, "Failed to write LED_GPIO_CFG register, ret=%d\n",
934 ret);
935 return ret;
936 }
937 959
938 /* Init Tx */ 960 /* Init Tx */
939 write_buf = 0; 961 ret = smsc95xx_write_reg(dev, FLOW, 0);
940 ret = smsc95xx_write_reg(dev, FLOW, write_buf); 962 check_warn_return(ret, "Failed to write FLOW: %d\n", ret);
941 if (ret < 0) {
942 netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret);
943 return ret;
944 }
945 963
946 read_buf = AFC_CFG_DEFAULT; 964 ret = smsc95xx_write_reg(dev, AFC_CFG, AFC_CFG_DEFAULT);
947 ret = smsc95xx_write_reg(dev, AFC_CFG, read_buf); 965 check_warn_return(ret, "Failed to write AFC_CFG: %d\n", ret);
948 if (ret < 0) {
949 netdev_warn(dev->net, "Failed to write AFC_CFG: %d\n", ret);
950 return ret;
951 }
952 966
953 /* Don't need mac_cr_lock during initialisation */ 967 /* Don't need mac_cr_lock during initialisation */
954 ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr); 968 ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr);
955 if (ret < 0) { 969 check_warn_return(ret, "Failed to read MAC_CR: %d\n", ret);
956 netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret);
957 return ret;
958 }
959 970
960 /* Init Rx */ 971 /* Init Rx */
961 /* Set Vlan */ 972 /* Set Vlan */
962 write_buf = (u32)ETH_P_8021Q; 973 ret = smsc95xx_write_reg(dev, VLAN1, (u32)ETH_P_8021Q);
963 ret = smsc95xx_write_reg(dev, VLAN1, write_buf); 974 check_warn_return(ret, "Failed to write VLAN1: %d\n", ret);
964 if (ret < 0) {
965 netdev_warn(dev->net, "Failed to write VAN1: %d\n", ret);
966 return ret;
967 }
968 975
969 /* Enable or disable checksum offload engines */ 976 /* Enable or disable checksum offload engines */
970 smsc95xx_set_features(dev->net, dev->net->features); 977 ret = smsc95xx_set_features(dev->net, dev->net->features);
978 check_warn_return(ret, "Failed to set checksum offload features");
971 979
972 smsc95xx_set_multicast(dev->net); 980 smsc95xx_set_multicast(dev->net);
973 981
974 if (smsc95xx_phy_initialize(dev) < 0) 982 ret = smsc95xx_phy_initialize(dev);
975 return -EIO; 983 check_warn_return(ret, "Failed to init PHY");
976 984
977 ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf); 985 ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf);
978 if (ret < 0) { 986 check_warn_return(ret, "Failed to read INT_EP_CTL: %d\n", ret);
979 netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret);
980 return ret;
981 }
982 987
983 /* enable PHY interrupts */ 988 /* enable PHY interrupts */
984 read_buf |= INT_EP_CTL_PHY_INT_; 989 read_buf |= INT_EP_CTL_PHY_INT_;
985 990
986 ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf); 991 ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf);
987 if (ret < 0) { 992 check_warn_return(ret, "Failed to write INT_EP_CTL: %d\n", ret);
988 netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret);
989 return ret;
990 }
991 993
992 smsc95xx_start_tx_path(dev); 994 ret = smsc95xx_start_tx_path(dev);
993 smsc95xx_start_rx_path(dev); 995 check_warn_return(ret, "Failed to start TX path");
996
997 ret = smsc95xx_start_rx_path(dev);
998 check_warn_return(ret, "Failed to start RX path");
994 999
995 netif_dbg(dev, ifup, dev->net, "smsc95xx_reset, return 0\n"); 1000 netif_dbg(dev, ifup, dev->net, "smsc95xx_reset, return 0\n");
996 return 0; 1001 return 0;
@@ -1017,10 +1022,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
1017 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); 1022 printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n");
1018 1023
1019 ret = usbnet_get_endpoints(dev, intf); 1024 ret = usbnet_get_endpoints(dev, intf);
1020 if (ret < 0) { 1025 check_warn_return(ret, "usbnet_get_endpoints failed: %d\n", ret);
1021 netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret);
1022 return ret;
1023 }
1024 1026
1025 dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv), 1027 dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv),
1026 GFP_KERNEL); 1028 GFP_KERNEL);
@@ -1064,6 +1066,153 @@ static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf)
1064 } 1066 }
1065} 1067}
1066 1068
1069static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1070{
1071 struct usbnet *dev = usb_get_intfdata(intf);
1072 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
1073 int ret;
1074 u32 val;
1075
1076 ret = usbnet_suspend(intf, message);
1077 check_warn_return(ret, "usbnet_suspend error");
1078
1079 /* if no wol options set, enter lowest power SUSPEND2 mode */
1080 if (!(pdata->wolopts & SUPPORTED_WAKE)) {
1081 netdev_info(dev->net, "entering SUSPEND2 mode");
1082
1083 /* disable energy detect (link up) & wake up events */
1084 ret = smsc95xx_read_reg(dev, WUCSR, &val);
1085 check_warn_return(ret, "Error reading WUCSR");
1086
1087 val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_);
1088
1089 ret = smsc95xx_write_reg(dev, WUCSR, val);
1090 check_warn_return(ret, "Error writing WUCSR");
1091
1092 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1093 check_warn_return(ret, "Error reading PM_CTRL");
1094
1095 val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_);
1096
1097 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1098 check_warn_return(ret, "Error writing PM_CTRL");
1099
1100 /* enter suspend2 mode */
1101 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1102 check_warn_return(ret, "Error reading PM_CTRL");
1103
1104 val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_);
1105 val |= PM_CTL_SUS_MODE_2;
1106
1107 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1108 check_warn_return(ret, "Error writing PM_CTRL");
1109
1110 return 0;
1111 }
1112
1113 if (pdata->wolopts & WAKE_MAGIC) {
1114 /* clear any pending magic packet status */
1115 ret = smsc95xx_read_reg(dev, WUCSR, &val);
1116 check_warn_return(ret, "Error reading WUCSR");
1117
1118 val |= WUCSR_MPR_;
1119
1120 ret = smsc95xx_write_reg(dev, WUCSR, val);
1121 check_warn_return(ret, "Error writing WUCSR");
1122 }
1123
1124 /* enable/disable magic packup wake */
1125 ret = smsc95xx_read_reg(dev, WUCSR, &val);
1126 check_warn_return(ret, "Error reading WUCSR");
1127
1128 if (pdata->wolopts & WAKE_MAGIC) {
1129 netdev_info(dev->net, "enabling magic packet wakeup");
1130 val |= WUCSR_MPEN_;
1131 } else {
1132 netdev_info(dev->net, "disabling magic packet wakeup");
1133 val &= ~WUCSR_MPEN_;
1134 }
1135
1136 ret = smsc95xx_write_reg(dev, WUCSR, val);
1137 check_warn_return(ret, "Error writing WUCSR");
1138
1139 /* enable wol wakeup source */
1140 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1141 check_warn_return(ret, "Error reading PM_CTRL");
1142
1143 val |= PM_CTL_WOL_EN_;
1144
1145 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1146 check_warn_return(ret, "Error writing PM_CTRL");
1147
1148 /* enable receiver */
1149 smsc95xx_start_rx_path(dev);
1150
1151 /* some wol options are enabled, so enter SUSPEND0 */
1152 netdev_info(dev->net, "entering SUSPEND0 mode");
1153
1154 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1155 check_warn_return(ret, "Error reading PM_CTRL");
1156
1157 val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_));
1158 val |= PM_CTL_SUS_MODE_0;
1159
1160 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1161 check_warn_return(ret, "Error writing PM_CTRL");
1162
1163 /* clear wol status */
1164 val &= ~PM_CTL_WUPS_;
1165 val |= PM_CTL_WUPS_WOL_;
1166 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1167 check_warn_return(ret, "Error writing PM_CTRL");
1168
1169 /* read back PM_CTRL */
1170 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1171 check_warn_return(ret, "Error reading PM_CTRL");
1172
1173 smsc95xx_set_feature(dev, USB_DEVICE_REMOTE_WAKEUP);
1174
1175 return 0;
1176}
1177
1178static int smsc95xx_resume(struct usb_interface *intf)
1179{
1180 struct usbnet *dev = usb_get_intfdata(intf);
1181 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
1182 int ret;
1183 u32 val;
1184
1185 BUG_ON(!dev);
1186
1187 if (pdata->wolopts & WAKE_MAGIC) {
1188 smsc95xx_clear_feature(dev, USB_DEVICE_REMOTE_WAKEUP);
1189
1190 /* Disable magic packup wake */
1191 ret = smsc95xx_read_reg(dev, WUCSR, &val);
1192 check_warn_return(ret, "Error reading WUCSR");
1193
1194 val &= ~WUCSR_MPEN_;
1195
1196 ret = smsc95xx_write_reg(dev, WUCSR, val);
1197 check_warn_return(ret, "Error writing WUCSR");
1198
1199 /* clear wake-up status */
1200 ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
1201 check_warn_return(ret, "Error reading PM_CTRL");
1202
1203 val &= ~PM_CTL_WOL_EN_;
1204 val |= PM_CTL_WUPS_;
1205
1206 ret = smsc95xx_write_reg(dev, PM_CTRL, val);
1207 check_warn_return(ret, "Error writing PM_CTRL");
1208 }
1209
1210 return usbnet_resume(intf);
1211 check_warn_return(ret, "usbnet_resume error");
1212
1213 return 0;
1214}
1215
1067static void smsc95xx_rx_csum_offload(struct sk_buff *skb) 1216static void smsc95xx_rx_csum_offload(struct sk_buff *skb)
1068{ 1217{
1069 skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); 1218 skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2);
@@ -1326,8 +1475,9 @@ static struct usb_driver smsc95xx_driver = {
1326 .name = "smsc95xx", 1475 .name = "smsc95xx",
1327 .id_table = products, 1476 .id_table = products,
1328 .probe = usbnet_probe, 1477 .probe = usbnet_probe,
1329 .suspend = usbnet_suspend, 1478 .suspend = smsc95xx_suspend,
1330 .resume = usbnet_resume, 1479 .resume = smsc95xx_resume,
1480 .reset_resume = smsc95xx_resume,
1331 .disconnect = usbnet_disconnect, 1481 .disconnect = usbnet_disconnect,
1332 .disable_hub_initiated_lpm = 1, 1482 .disable_hub_initiated_lpm = 1,
1333}; 1483};
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index 86bc44977fb..2ff9815aa27 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -63,6 +63,7 @@
63#define INT_STS_TDFO_ (0x00001000) 63#define INT_STS_TDFO_ (0x00001000)
64#define INT_STS_RXDF_ (0x00000800) 64#define INT_STS_RXDF_ (0x00000800)
65#define INT_STS_GPIOS_ (0x000007FF) 65#define INT_STS_GPIOS_ (0x000007FF)
66#define INT_STS_CLEAR_ALL_ (0xFFFFFFFF)
66 67
67#define RX_CFG (0x0C) 68#define RX_CFG (0x0C)
68#define RX_FIFO_FLUSH_ (0x00000001) 69#define RX_FIFO_FLUSH_ (0x00000001)
@@ -83,12 +84,16 @@
83#define HW_CFG_BCE_ (0x00000002) 84#define HW_CFG_BCE_ (0x00000002)
84#define HW_CFG_SRST_ (0x00000001) 85#define HW_CFG_SRST_ (0x00000001)
85 86
87#define RX_FIFO_INF (0x18)
88
86#define PM_CTRL (0x20) 89#define PM_CTRL (0x20)
90#define PM_CTL_RES_CLR_WKP_STS (0x00000200)
87#define PM_CTL_DEV_RDY_ (0x00000080) 91#define PM_CTL_DEV_RDY_ (0x00000080)
88#define PM_CTL_SUS_MODE_ (0x00000060) 92#define PM_CTL_SUS_MODE_ (0x00000060)
89#define PM_CTL_SUS_MODE_0 (0x00000000) 93#define PM_CTL_SUS_MODE_0 (0x00000000)
90#define PM_CTL_SUS_MODE_1 (0x00000020) 94#define PM_CTL_SUS_MODE_1 (0x00000020)
91#define PM_CTL_SUS_MODE_2 (0x00000060) 95#define PM_CTL_SUS_MODE_2 (0x00000040)
96#define PM_CTL_SUS_MODE_3 (0x00000060)
92#define PM_CTL_PHY_RST_ (0x00000010) 97#define PM_CTL_PHY_RST_ (0x00000010)
93#define PM_CTL_WOL_EN_ (0x00000008) 98#define PM_CTL_WOL_EN_ (0x00000008)
94#define PM_CTL_ED_EN_ (0x00000004) 99#define PM_CTL_ED_EN_ (0x00000004)
@@ -200,6 +205,11 @@
200#define WUFF (0x128) 205#define WUFF (0x128)
201 206
202#define WUCSR (0x12C) 207#define WUCSR (0x12C)
208#define WUCSR_GUE_ (0x00000200)
209#define WUCSR_WUFR_ (0x00000040)
210#define WUCSR_MPR_ (0x00000020)
211#define WUCSR_WAKE_EN_ (0x00000004)
212#define WUCSR_MPEN_ (0x00000002)
203 213
204#define COE_CR (0x130) 214#define COE_CR (0x130)
205#define Tx_COE_EN_ (0x00010000) 215#define Tx_COE_EN_ (0x00010000)