Return-Path: X-Original-To: colinomail@colino.net Delivered-To: colinomail@colino.net Received: by paperstreet.colino.net (Postfix, from userid 1015) id 4CAA9101D9; Tue, 5 Apr 2005 23:02:50 +0200 (CEST) Received: from ylpvm43.prodigy.net (ylpvm43-ext.prodigy.net [207.115.57.74]) by paperstreet.colino.net (Postfix) with ESMTP id 1F9B0101D8 for ; Tue, 5 Apr 2005 23:02:43 +0200 (CEST) Received: from pimout5-ext.prodigy.net (pimout5-ext.prodigy.net [207.115.63.73]) by ylpvm43.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id j35L2gtF032114 for ; Tue, 5 Apr 2005 17:02:42 -0400 X-ORBL: [69.107.61.180] Received: from ascent (adsl-69-107-61-180.dsl.pltn13.pacbell.net [69.107.61.180]) by pimout5-ext.prodigy.net (8.12.10 milter /8.12.10) with ESMTP id j35L2fnG052152; Tue, 5 Apr 2005 17:02:41 -0400 From: David Brownell To: linux-usb-devel@lists.sourceforge.net Subject: [patch 2.6.12-rc2] usb interface suspend signatures/fixes Date: Tue, 5 Apr 2005 14:02:41 -0700 User-Agent: KMail/1.7.1 Cc: Colin Leroy References: <20050405204449.5ab0cdea@jack.colino.net> In-Reply-To: <20050405204449.5ab0cdea@jack.colino.net> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_xzvUCeQ4K7fhx09" Message-Id: <200504051402.41888.david-b@pacbell.net> X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on paperstreet.colino.net X-Spam-Level: X-Spam-Status: No, hits=0.2 required=5.0 tests=AWL autolearn=no version=2.64 X-UIDL: )6H"!D6$"!I0@"!L7a"! --Boundary-00=_xzvUCeQ4K7fhx09 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline This is another resend, patch already in 2.6.12-rc2-mm1. - Dave --Boundary-00=_xzvUCeQ4K7fhx09 Content-Type: text/x-diff; charset="us-ascii"; name="susp-0330b.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="susp-0330b.patch" This is the first of a few installments of PM API updates to match the recent switch to "pm_message_t". This installment primarily affects USB device drivers (for USB interfaces), and it changes the handful of drivers which currently implement suspend methods: - and usbcore, signature change - Some drivers only changed the signature, net effect this just shuts up "sparse -Wbitwise": * hid-core * stir4200 - Two network drivers did that, and also grew slightly more featureful suspend code ... they now properly shut down their activities. (As should stir4200...) * pegasus * usbnet Note that the Wake-On-Lan (WOL) support in pegasus doesn't yet work; looks to me like it's missing a request to turn it on, vs just configuring it. The ASIX code in usbnet also has WOL hooks that are ready to use; untested. Signed-off-by: David Brownell Signed-off-by: Andrew Morton 25-akpm/drivers/net/irda/stir4200.c | 4 ++-- 25-akpm/drivers/usb/core/hub.c | 4 ++-- 25-akpm/drivers/usb/core/usb.c | 6 +++--- 25-akpm/drivers/usb/input/hid-core.c | 6 +++--- 25-akpm/drivers/usb/net/pegasus.c | 22 +++++++++++++++++++++- 25-akpm/drivers/usb/net/usbnet.c | 10 +++++++++- 25-akpm/include/linux/usb.h | 4 ++-- 7 files changed, 42 insertions(+), 14 deletions(-) --- 25/drivers/net/irda/stir4200.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/net/irda/stir4200.c Wed Mar 30 13:26:31 2005 @@ -1128,8 +1128,8 @@ static void stir_disconnect(struct usb_i } #ifdef CONFIG_PM -/* Power management suspend, so power off the transmitter/receiver */ -static int stir_suspend(struct usb_interface *intf, u32 state) +/* USB suspend, so power off the transmitter/receiver */ +static int stir_suspend(struct usb_interface *intf, pm_message_t message) { struct stir_cb *stir = usb_get_intfdata(intf); --- 25/drivers/usb/core/hub.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/usb/core/hub.c Wed Mar 30 13:26:31 2005 @@ -1731,7 +1731,7 @@ static int finish_port_resume(struct usb struct usb_driver *driver; intf = udev->actconfig->interface[i]; - if (intf->dev.power.power_state == PM_SUSPEND_ON) + if (intf->dev.power.power_state == PMSG_SUSPEND) continue; if (!intf->dev.driver) { /* FIXME maybe force to alt 0 */ @@ -1745,7 +1745,7 @@ static int finish_port_resume(struct usb /* can we do better than just logging errors? */ status = driver->resume(intf); - if (intf->dev.power.power_state != PM_SUSPEND_ON + if (intf->dev.power.power_state != PMSG_ON || status) dev_dbg(&intf->dev, "resume fail, state %d code %d\n", --- 25/drivers/usb/core/usb.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/usb/core/usb.c Wed Mar 30 13:26:31 2005 @@ -1387,13 +1387,13 @@ void usb_buffer_unmap_sg (struct usb_dev usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } -static int usb_generic_suspend(struct device *dev, u32 state) +static int usb_generic_suspend(struct device *dev, pm_message_t message) { struct usb_interface *intf; struct usb_driver *driver; if (dev->driver == &usb_generic_driver) - return usb_suspend_device (to_usb_device(dev), state); + return usb_suspend_device (to_usb_device(dev), message); if ((dev->driver == NULL) || (dev->driver_data == &usb_generic_driver_data)) @@ -1407,7 +1407,7 @@ static int usb_generic_suspend(struct de return 0; if (driver->suspend) - return driver->suspend(intf, state); + return driver->suspend(intf, message); return 0; } --- 25/drivers/usb/input/hid-core.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/usb/input/hid-core.c Wed Mar 30 13:26:31 2005 @@ -1801,12 +1801,12 @@ static int hid_probe(struct usb_interfac return 0; } -static int hid_suspend(struct usb_interface *intf, u32 state) +static int hid_suspend(struct usb_interface *intf, pm_message_t message) { struct hid_device *hid = usb_get_intfdata (intf); usb_kill_urb(hid->urbin); - intf->dev.power.power_state = state; + intf->dev.power.power_state = PMSG_SUSPEND; dev_dbg(&intf->dev, "suspend\n"); return 0; } @@ -1816,7 +1816,7 @@ static int hid_resume(struct usb_interfa struct hid_device *hid = usb_get_intfdata (intf); int status; - intf->dev.power.power_state = PM_SUSPEND_ON; + intf->dev.power.power_state = PMSG_ON; if (hid->open) status = usb_submit_urb(hid->urbin, GFP_NOIO); else --- 25/drivers/usb/net/pegasus.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/usb/net/pegasus.c Wed Mar 30 13:26:31 2005 @@ -1364,11 +1364,18 @@ static void pegasus_disconnect(struct us free_netdev(pegasus->net); } -static int pegasus_suspend (struct usb_interface *intf, pm_message_t state) +static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) { struct pegasus *pegasus = usb_get_intfdata(intf); netif_device_detach (pegasus->net); + if (netif_running(pegasus->net)) { + cancel_delayed_work(&pegasus->carrier_check); + + usb_kill_urb(pegasus->rx_urb); + usb_kill_urb(pegasus->intr_urb); + } + intf->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -1376,7 +1383,20 @@ static int pegasus_resume (struct usb_in { struct pegasus *pegasus = usb_get_intfdata(intf); + intf->dev.power.power_state = PMSG_ON; netif_device_attach (pegasus->net); + if (netif_running(pegasus->net)) { + pegasus->rx_urb->status = 0; + pegasus->rx_urb->actual_length = 0; + read_bulk_callback(pegasus->rx_urb, 0); + + pegasus->intr_urb->status = 0; + pegasus->intr_urb->actual_length = 0; + intr_callback(pegasus->intr_urb, 0); + + queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, + CARRIER_CHECK_DELAY); + } return 0; } --- 25/drivers/usb/net/usbnet.c~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/drivers/usb/net/usbnet.c Wed Mar 30 13:26:31 2005 @@ -3732,11 +3732,17 @@ out: #ifdef CONFIG_PM -static int usbnet_suspend (struct usb_interface *intf, u32 state) +static int usbnet_suspend (struct usb_interface *intf, pm_message_t message) { struct usbnet *dev = usb_get_intfdata(intf); + /* accelerate emptying of the rx and queues, to avoid + * having everything error out. + */ netif_device_detach (dev->net); + (void) unlink_urbs (dev, &dev->rxq); + (void) unlink_urbs (dev, &dev->txq); + intf->dev.power.power_state = PMSG_SUSPEND; return 0; } @@ -3744,7 +3750,9 @@ static int usbnet_resume (struct usb_int { struct usbnet *dev = usb_get_intfdata(intf); + intf->dev.power.power_state = PMSG_ON; netif_device_attach (dev->net); + tasklet_schedule (&dev->bh); return 0; } --- 25/include/linux/usb.h~usb-suspend-updates-interface-suspend Wed Mar 30 13:26:31 2005 +++ 25-akpm/include/linux/usb.h Wed Mar 30 13:26:31 2005 @@ -557,7 +557,7 @@ struct usb_driver { int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); - int (*suspend) (struct usb_interface *intf, u32 state); + int (*suspend) (struct usb_interface *intf, pm_message_t message); int (*resume) (struct usb_interface *intf); const struct usb_device_id *id_table; @@ -976,7 +976,7 @@ extern int usb_bulk_msg(struct usb_devic int timeout); /* selective suspend/resume */ -extern int usb_suspend_device(struct usb_device *dev, u32 state); +extern int usb_suspend_device(struct usb_device *dev, pm_message_t message); extern int usb_resume_device(struct usb_device *dev); --Boundary-00=_xzvUCeQ4K7fhx09--