aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/core/driver.c22
-rw-r--r--include/linux/usb.h29
2 files changed, 48 insertions, 3 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index ca0e40ed2b72..204495fa6b3d 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1322,6 +1322,28 @@ int usb_autopm_get_interface(struct usb_interface *intf)
1322} 1322}
1323EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1323EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1324 1324
1325/**
1326 * usb_autopm_set_interface - set a USB interface's autosuspend state
1327 * @intf: the usb_interface whose state should be set
1328 *
1329 * This routine sets the autosuspend state of @intf's device according
1330 * to @intf's usage counter, which the caller must have set previously.
1331 * If the counter is <= 0, the device is autosuspended (if it isn't
1332 * already suspended and if nothing else prevents the autosuspend). If
1333 * the counter is > 0, the device is autoresumed (if it isn't already
1334 * awake).
1335 */
1336int usb_autopm_set_interface(struct usb_interface *intf)
1337{
1338 int status;
1339
1340 status = usb_autopm_do_interface(intf, 0);
1341 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1342 // __FUNCTION__, status, intf->pm_usage_cnt);
1343 return status;
1344}
1345EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
1346
1325#endif /* CONFIG_USB_SUSPEND */ 1347#endif /* CONFIG_USB_SUSPEND */
1326 1348
1327static int usb_suspend(struct device *dev, pm_message_t message) 1349static int usb_suspend(struct device *dev, pm_message_t message)
diff --git a/include/linux/usb.h b/include/linux/usb.h
index e732e024a141..864c6c21c21e 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -415,14 +415,37 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
415 415
416/* USB autosuspend and autoresume */ 416/* USB autosuspend and autoresume */
417#ifdef CONFIG_USB_SUSPEND 417#ifdef CONFIG_USB_SUSPEND
418extern int usb_autopm_set_interface(struct usb_interface *intf);
418extern int usb_autopm_get_interface(struct usb_interface *intf); 419extern int usb_autopm_get_interface(struct usb_interface *intf);
419extern void usb_autopm_put_interface(struct usb_interface *intf); 420extern void usb_autopm_put_interface(struct usb_interface *intf);
420 421
422static inline void usb_autopm_enable(struct usb_interface *intf)
423{
424 intf->pm_usage_cnt = 0;
425 usb_autopm_set_interface(intf);
426}
427
428static inline void usb_autopm_disable(struct usb_interface *intf)
429{
430 intf->pm_usage_cnt = 1;
431 usb_autopm_set_interface(intf);
432}
433
421#else 434#else
422#define usb_autopm_get_interface(intf) 0
423#define usb_autopm_put_interface(intf) do {} while (0)
424#endif
425 435
436static inline int usb_autopm_set_interface(struct usb_interface *intf)
437{ return 0; }
438
439static inline int usb_autopm_get_interface(struct usb_interface *intf)
440{ return 0; }
441
442static inline void usb_autopm_put_interface(struct usb_interface *intf)
443{ }
444static inline void usb_autopm_enable(struct usb_interface *intf)
445{ }
446static inline void usb_autopm_disable(struct usb_interface *intf)
447{ }
448#endif
426 449
427/*-------------------------------------------------------------------------*/ 450/*-------------------------------------------------------------------------*/
428 451