diff options
Diffstat (limited to 'Documentation/usb')
-rw-r--r-- | Documentation/usb/power-management.txt | 22 |
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 | |||
313 | that it supports autosuspend by setting the .supports_autosuspend flag | 313 | that it supports autosuspend by setting the .supports_autosuspend flag |
314 | in its usb_driver structure. It is then responsible for informing the | 314 | in its usb_driver structure. It is then responsible for informing the |
315 | USB core whenever one of its interfaces becomes busy or idle. The | 315 | USB core whenever one of its interfaces becomes busy or idle. The |
316 | driver does so by calling these three functions: | 316 | driver 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 | ||
322 | The functions work by maintaining a counter in the usb_interface | 324 | The functions work by maintaining a counter in the usb_interface |
323 | structure. When intf->pm_usage_count is > 0 then the interface is | 325 | structure. 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. | |||
330 | This field is used only by the USB core.) | 332 | This field is used only by the USB core.) |
331 | 333 | ||
332 | The driver owns intf->pm_usage_count; it can modify the value however | 334 | The driver owns intf->pm_usage_count; it can modify the value however |
333 | and whenever it likes. A nice aspect of the usb_autopm_* routines is | 335 | and whenever it likes. A nice aspect of the non-async usb_autopm_* |
334 | that the changes they make are protected by the usb_device structure's | 336 | routines is that the changes they make are protected by the usb_device |
335 | PM mutex (udev->pm_mutex); however drivers may change pm_usage_count | 337 | structure's PM mutex (udev->pm_mutex); however drivers may change |
336 | without holding the mutex. | 338 | pm_usage_count without holding the mutex. Drivers using the async |
339 | routines are responsible for their own synchronization and mutual | ||
340 | exclusion. | ||
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 | |||
351 | There also are a couple of utility routines drivers can use: | 363 | There 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 |