aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/net/kaweth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/net/kaweth.c')
-rw-r--r--drivers/usb/net/kaweth.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index fa78326d0bf0..36a989160a68 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -179,6 +179,7 @@ static struct usb_driver kaweth_driver = {
179 .suspend = kaweth_suspend, 179 .suspend = kaweth_suspend,
180 .resume = kaweth_resume, 180 .resume = kaweth_resume,
181 .id_table = usb_klsi_table, 181 .id_table = usb_klsi_table,
182 .supports_autosuspend = 1,
182}; 183};
183 184
184typedef __u8 eth_addr_t[6]; 185typedef __u8 eth_addr_t[6];
@@ -225,6 +226,7 @@ struct kaweth_device
225 struct delayed_work lowmem_work; 226 struct delayed_work lowmem_work;
226 227
227 struct usb_device *dev; 228 struct usb_device *dev;
229 struct usb_interface *intf;
228 struct net_device *net; 230 struct net_device *net;
229 wait_queue_head_t term_wait; 231 wait_queue_head_t term_wait;
230 232
@@ -662,9 +664,14 @@ static int kaweth_open(struct net_device *net)
662 664
663 dbg("Opening network device."); 665 dbg("Opening network device.");
664 666
667 res = usb_autopm_get_interface(kaweth->intf);
668 if (res) {
669 err("Interface cannot be resumed.");
670 return -EIO;
671 }
665 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); 672 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL);
666 if (res) 673 if (res)
667 return -EIO; 674 goto err_out;
668 675
669 usb_fill_int_urb( 676 usb_fill_int_urb(
670 kaweth->irq_urb, 677 kaweth->irq_urb,
@@ -681,7 +688,7 @@ static int kaweth_open(struct net_device *net)
681 res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); 688 res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL);
682 if (res) { 689 if (res) {
683 usb_kill_urb(kaweth->rx_urb); 690 usb_kill_urb(kaweth->rx_urb);
684 return -EIO; 691 goto err_out;
685 } 692 }
686 kaweth->opened = 1; 693 kaweth->opened = 1;
687 694
@@ -689,10 +696,14 @@ static int kaweth_open(struct net_device *net)
689 696
690 kaweth_async_set_rx_mode(kaweth); 697 kaweth_async_set_rx_mode(kaweth);
691 return 0; 698 return 0;
699
700err_out:
701 usb_autopm_enable(kaweth->intf);
702 return -EIO;
692} 703}
693 704
694/**************************************************************** 705/****************************************************************
695 * kaweth_close 706 * kaweth_kill_urbs
696 ****************************************************************/ 707 ****************************************************************/
697static void kaweth_kill_urbs(struct kaweth_device *kaweth) 708static void kaweth_kill_urbs(struct kaweth_device *kaweth)
698{ 709{
@@ -724,17 +735,29 @@ static int kaweth_close(struct net_device *net)
724 735
725 kaweth->status &= ~KAWETH_STATUS_CLOSING; 736 kaweth->status &= ~KAWETH_STATUS_CLOSING;
726 737
738 usb_autopm_enable(kaweth->intf);
739
727 return 0; 740 return 0;
728} 741}
729 742
730static void kaweth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 743static void kaweth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
731{ 744{
745 struct kaweth_device *kaweth = netdev_priv(dev);
732 746
733 strlcpy(info->driver, driver_name, sizeof(info->driver)); 747 strlcpy(info->driver, driver_name, sizeof(info->driver));
748 usb_make_path(kaweth->dev, info->bus_info, sizeof (info->bus_info));
749}
750
751static u32 kaweth_get_link(struct net_device *dev)
752{
753 struct kaweth_device *kaweth = netdev_priv(dev);
754
755 return kaweth->linkstate;
734} 756}
735 757
736static struct ethtool_ops ops = { 758static struct ethtool_ops ops = {
737 .get_drvinfo = kaweth_get_drvinfo 759 .get_drvinfo = kaweth_get_drvinfo,
760 .get_link = kaweth_get_link
738}; 761};
739 762
740/**************************************************************** 763/****************************************************************
@@ -908,6 +931,7 @@ static int kaweth_suspend(struct usb_interface *intf, pm_message_t message)
908 struct kaweth_device *kaweth = usb_get_intfdata(intf); 931 struct kaweth_device *kaweth = usb_get_intfdata(intf);
909 unsigned long flags; 932 unsigned long flags;
910 933
934 dbg("Suspending device");
911 spin_lock_irqsave(&kaweth->device_lock, flags); 935 spin_lock_irqsave(&kaweth->device_lock, flags);
912 kaweth->status |= KAWETH_STATUS_SUSPENDING; 936 kaweth->status |= KAWETH_STATUS_SUSPENDING;
913 spin_unlock_irqrestore(&kaweth->device_lock, flags); 937 spin_unlock_irqrestore(&kaweth->device_lock, flags);
@@ -924,6 +948,7 @@ static int kaweth_resume(struct usb_interface *intf)
924 struct kaweth_device *kaweth = usb_get_intfdata(intf); 948 struct kaweth_device *kaweth = usb_get_intfdata(intf);
925 unsigned long flags; 949 unsigned long flags;
926 950
951 dbg("Resuming device");
927 spin_lock_irqsave(&kaweth->device_lock, flags); 952 spin_lock_irqsave(&kaweth->device_lock, flags);
928 kaweth->status &= ~KAWETH_STATUS_SUSPENDING; 953 kaweth->status &= ~KAWETH_STATUS_SUSPENDING;
929 spin_unlock_irqrestore(&kaweth->device_lock, flags); 954 spin_unlock_irqrestore(&kaweth->device_lock, flags);
@@ -1086,6 +1111,8 @@ err_fw:
1086 1111
1087 dbg("Initializing net device."); 1112 dbg("Initializing net device.");
1088 1113
1114 kaweth->intf = intf;
1115
1089 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1116 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1090 if (!kaweth->tx_urb) 1117 if (!kaweth->tx_urb)
1091 goto err_free_netdev; 1118 goto err_free_netdev;
@@ -1265,7 +1292,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
1265{ 1292{
1266 struct urb *urb; 1293 struct urb *urb;
1267 int retv; 1294 int retv;
1268 int length; 1295 int length = 0; /* shut up GCC */
1269 1296
1270 urb = usb_alloc_urb(0, GFP_NOIO); 1297 urb = usb_alloc_urb(0, GFP_NOIO);
1271 if (!urb) 1298 if (!urb)