Hi, this is a simpler interface for autosuspend on interfaces. It is needed for autosuspending in the HID driver.
Regards Oliver Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]> commit d4ce896e300c18d3696255ed0a50095dc3e2b547 Author: Oliver Neukum <[EMAIL PROTECTED]> Date: Sun Oct 15 11:17:56 2006 +0200 simplified autosuspend management diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 113e484..aaa1bac 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1228,6 +1228,67 @@ void usb_autopm_put_interface(struct usb EXPORT_SYMBOL_GPL(usb_autopm_put_interface); /** + * usb_autopm_enable - allow the USB subsystem to use autosuspend on your interface + * @intf: the usb_interface autosuspend is activated for + * + * This routine may be called by an interface driver when it is + * finished using @intf and wants to allow it to autosuspend. + * + * If the driver has set @intf->needs_remote_wakeup then autosuspend will + * take place only if the device's remote-wakeup facility is enabled. + * + * Suspend method calls queued by this routine can arrive at any time + * while @intf is resumed and its usage counter is equal to 0. They are + * not protected by the usb_device's lock but only by its pm_mutex. + * Drivers must provide their own synchronization. + * + * This routine can run only in process context. + */ +void usb_autopm_enable(struct usb_interface *intf) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_pm_lock(udev); + intf->pm_usage_cnt = 0; + if (intf->condition != USB_INTERFACE_UNBOUND) { + queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, + USB_AUTOSUSPEND_DELAY); + } + usb_pm_unlock(udev); + // dev_dbg(&intf->dev, "%s: cnt %d\n", + // __FUNCTION__, intf->pm_usage_cnt); +} +EXPORT_SYMBOL_GPL(usb_autopm_enable); + +/** + * usb_autopm_disable - disallow the USB subsystem from autosuspending your interface + * @intf: the usb_interface whose autosuspend is to be disallowed + * + * This routine can run only in process context. + */ + +int usb_autopm_disable(struct usb_interface *intf) +{ + struct usb_device *udev = interface_to_usbdev(intf); + int status; + + usb_pm_lock(udev); + if (intf->condition == USB_INTERFACE_UNBOUND) + status = -ENODEV; + else { + intf->pm_usage_cnt = 1; + udev->auto_pm = 1; + status = usb_resume_both(udev); + if (status != 0) + --intf->pm_usage_cnt; + } + usb_pm_unlock(udev); + // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", + // __FUNCTION__, status, intf->pm_usage_cnt); + return status; +} +EXPORT_SYMBOL_GPL(usb_autopm_disable); +/** * usb_autopm_get_interface - increment a USB interface's PM-usage counter * @intf: the usb_interface whose counter should be incremented * ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel