aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-11-12 16:19:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 12:59:53 -0500
commit9ac39f28b5237a629e41ccfc1f73d3a55723045c (patch)
treec161d5b62d11b6e73605a37b2562b90fff689d9e /Documentation
parentd4f373e57d3916814110968c5ea1155a8d972b5a (diff)
USB: add asynchronous autosuspend/autoresume support
This patch (as1160b) adds support routines for asynchronous autosuspend and autoresume, with accompanying documentation updates. There already are several potential users of this interface, and others are likely to arise as autosuspend support becomes more widespread. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/usb/power-management.txt22
1 files changed, 17 insertions, 5 deletions
diff --git a/Documentation/usb/power-management.txt b/Documentation/usb/power-management.txt
index e48ea1d51010..ad642615ad4c 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -313,11 +313,13 @@ three of the methods listed above. In addition, a driver indicates
313that it supports autosuspend by setting the .supports_autosuspend flag 313that it supports autosuspend by setting the .supports_autosuspend flag
314in its usb_driver structure. It is then responsible for informing the 314in its usb_driver structure. It is then responsible for informing the
315USB core whenever one of its interfaces becomes busy or idle. The 315USB core whenever one of its interfaces becomes busy or idle. The
316driver does so by calling these three functions: 316driver does so by calling these five functions:
317 317
318 int usb_autopm_get_interface(struct usb_interface *intf); 318 int usb_autopm_get_interface(struct usb_interface *intf);
319 void usb_autopm_put_interface(struct usb_interface *intf); 319 void usb_autopm_put_interface(struct usb_interface *intf);
320 int usb_autopm_set_interface(struct usb_interface *intf); 320 int usb_autopm_set_interface(struct usb_interface *intf);
321 int usb_autopm_get_interface_async(struct usb_interface *intf);
322 void usb_autopm_put_interface_async(struct usb_interface *intf);
321 323
322The functions work by maintaining a counter in the usb_interface 324The functions work by maintaining a counter in the usb_interface
323structure. When intf->pm_usage_count is > 0 then the interface is 325structure. When intf->pm_usage_count is > 0 then the interface is
@@ -330,10 +332,12 @@ associated with the device itself rather than any of its interfaces.
330This field is used only by the USB core.) 332This field is used only by the USB core.)
331 333
332The driver owns intf->pm_usage_count; it can modify the value however 334The driver owns intf->pm_usage_count; it can modify the value however
333and whenever it likes. A nice aspect of the usb_autopm_* routines is 335and whenever it likes. A nice aspect of the non-async usb_autopm_*
334that the changes they make are protected by the usb_device structure's 336routines is that the changes they make are protected by the usb_device
335PM mutex (udev->pm_mutex); however drivers may change pm_usage_count 337structure's PM mutex (udev->pm_mutex); however drivers may change
336without holding the mutex. 338pm_usage_count without holding the mutex. Drivers using the async
339routines are responsible for their own synchronization and mutual
340exclusion.
337 341
338 usb_autopm_get_interface() increments pm_usage_count and 342 usb_autopm_get_interface() increments pm_usage_count and
339 attempts an autoresume if the new value is > 0 and the 343 attempts an autoresume if the new value is > 0 and the
@@ -348,6 +352,14 @@ without holding the mutex.
348 is suspended, and it attempts an autosuspend if the value is 352 is suspended, and it attempts an autosuspend if the value is
349 <= 0 and the device isn't suspended. 353 <= 0 and the device isn't suspended.
350 354
355 usb_autopm_get_interface_async() and
356 usb_autopm_put_interface_async() do almost the same things as
357 their non-async counterparts. The differences are: they do
358 not acquire the PM mutex, and they use a workqueue to do their
359 jobs. As a result they can be called in an atomic context,
360 such as an URB's completion handler, but when they return the
361 device will not generally not yet be in the desired state.
362
351There also are a couple of utility routines drivers can use: 363There also are a couple of utility routines drivers can use:
352 364
353 usb_autopm_enable() sets pm_usage_cnt to 0 and then calls 365 usb_autopm_enable() sets pm_usage_cnt to 0 and then calls