diff options
author | Oliver Neukum <oneukum@suse.de> | 2007-01-16 03:47:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 18:44:35 -0500 |
commit | b98b98f97c519894c64bf1bee6b7957e687dfc41 (patch) | |
tree | 98b591e3e7a08dfc9d474f1661a3baba2df761ca /drivers/usb/net | |
parent | 511779fd9eb7ed67116e4a1cad802363d2d58b20 (diff) |
USB: power management for kaweth
- implements suspend when the network interface is down
- fixes a typo in comments
- adds debugging output for power management
- fixes a compiler warning
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net')
-rw-r--r-- | drivers/usb/net/kaweth.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index fa78326d0bf0..f29eed30e4f2 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 | ||
184 | typedef __u8 eth_addr_t[6]; | 185 | typedef __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 | |||
700 | err_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 | ****************************************************************/ |
697 | static void kaweth_kill_urbs(struct kaweth_device *kaweth) | 708 | static void kaweth_kill_urbs(struct kaweth_device *kaweth) |
698 | { | 709 | { |
@@ -724,6 +735,8 @@ 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 | ||
@@ -908,6 +921,7 @@ static int kaweth_suspend(struct usb_interface *intf, pm_message_t message) | |||
908 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | 921 | struct kaweth_device *kaweth = usb_get_intfdata(intf); |
909 | unsigned long flags; | 922 | unsigned long flags; |
910 | 923 | ||
924 | dbg("Suspending device"); | ||
911 | spin_lock_irqsave(&kaweth->device_lock, flags); | 925 | spin_lock_irqsave(&kaweth->device_lock, flags); |
912 | kaweth->status |= KAWETH_STATUS_SUSPENDING; | 926 | kaweth->status |= KAWETH_STATUS_SUSPENDING; |
913 | spin_unlock_irqrestore(&kaweth->device_lock, flags); | 927 | spin_unlock_irqrestore(&kaweth->device_lock, flags); |
@@ -924,6 +938,7 @@ static int kaweth_resume(struct usb_interface *intf) | |||
924 | struct kaweth_device *kaweth = usb_get_intfdata(intf); | 938 | struct kaweth_device *kaweth = usb_get_intfdata(intf); |
925 | unsigned long flags; | 939 | unsigned long flags; |
926 | 940 | ||
941 | dbg("Resuming device"); | ||
927 | spin_lock_irqsave(&kaweth->device_lock, flags); | 942 | spin_lock_irqsave(&kaweth->device_lock, flags); |
928 | kaweth->status &= ~KAWETH_STATUS_SUSPENDING; | 943 | kaweth->status &= ~KAWETH_STATUS_SUSPENDING; |
929 | spin_unlock_irqrestore(&kaweth->device_lock, flags); | 944 | spin_unlock_irqrestore(&kaweth->device_lock, flags); |
@@ -1086,6 +1101,8 @@ err_fw: | |||
1086 | 1101 | ||
1087 | dbg("Initializing net device."); | 1102 | dbg("Initializing net device."); |
1088 | 1103 | ||
1104 | kaweth->intf = intf; | ||
1105 | |||
1089 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); | 1106 | kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); |
1090 | if (!kaweth->tx_urb) | 1107 | if (!kaweth->tx_urb) |
1091 | goto err_free_netdev; | 1108 | goto err_free_netdev; |
@@ -1265,7 +1282,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev, | |||
1265 | { | 1282 | { |
1266 | struct urb *urb; | 1283 | struct urb *urb; |
1267 | int retv; | 1284 | int retv; |
1268 | int length; | 1285 | int length = 0; /* shut up GCC */ |
1269 | 1286 | ||
1270 | urb = usb_alloc_urb(0, GFP_NOIO); | 1287 | urb = usb_alloc_urb(0, GFP_NOIO); |
1271 | if (!urb) | 1288 | if (!urb) |