Jesse Keating 3494df0
commit 7d0d20a25c6f477fb198b85510c78156d7d7c5af
Jesse Keating 3494df0
Author: Matthew Garrett <mjg@redhat.com>
Jesse Keating 3494df0
Date:   Tue Jun 9 20:11:47 2009 +0100
Jesse Keating 3494df0
Jesse Keating 3494df0
    usb: Allow drivers to enable USB autosuspend on a per-device basis
Jesse Keating 3494df0
    
Jesse Keating 3494df0
    USB autosuspend is currently only enabled by default for hubs. On other
Jesse Keating 3494df0
    hardware the decision is made by userspace. This is unnecessary in cases
Jesse Keating 3494df0
    where we know that the hardware supports autosuspend, so this patch adds
Jesse Keating 3494df0
    a function to allow drivers to enable it at probe time.
Jesse Keating 3494df0
    
Jesse Keating 3494df0
    Signed-off-by: Matthew Garrett <mjg@redhat.com>
Jesse Keating 3494df0
Jesse Keating 3494df0
---
Jesse Keating 3494df0
 drivers/usb/core/driver.c |   16 ++++++++++++++++
Jesse Keating 3494df0
 include/linux/usb.h       |    4 ++++
Jesse Keating 3494df0
 2 files changed, 20 insertions(+), 0 deletions(-)
Jesse Keating 3494df0
Jesse Keating 3494df0
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
Jesse Keating 3494df0
index 60a45f1..03e0228 100644
Jesse Keating 3494df0
--- a/drivers/usb/core/driver.c
Jesse Keating 3494df0
+++ b/drivers/usb/core/driver.c
Jesse Keating 3494df0
@@ -1648,6 +1648,21 @@ void usb_autopm_put_interface_async(struct usb_interface *intf)
Jesse Keating 3494df0
 EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async);
Jesse Keating 3494df0
 
Jesse Keating 3494df0
 /**
Jesse Keating 3494df0
+ * usb_device_autosuspend_enable - enable autosuspend on a device
Jesse Keating 3494df0
+ * @udev: the usb_device to be autosuspended
Jesse Keating 3494df0
+ *
Jesse Keating 3494df0
+ * This routine should be called by an interface driver when it knows that
Jesse Keating 3494df0
+ * the device in question supports USB autosuspend.
Jesse Keating 3494df0
+ *
Jesse Keating 3494df0
+ */
Jesse Keating 3494df0
+void usb_device_autosuspend_enable(struct usb_device *udev)
Jesse Keating 3494df0
+{
Jesse Keating 3494df0
+	udev->autosuspend_disabled = 0;
Jesse Keating 3494df0
+	usb_external_suspend_device(udev, PMSG_USER_SUSPEND);
Jesse Keating 3494df0
+}
Jesse Keating 3494df0
+EXPORT_SYMBOL_GPL(usb_device_autosuspend_enable);
Jesse Keating 3494df0
+
Jesse Keating 3494df0
+/**
Jesse Keating 3494df0
  * usb_autopm_get_interface - increment a USB interface's PM-usage counter
Jesse Keating 3494df0
  * @intf: the usb_interface whose counter should be incremented
Jesse Keating 3494df0
  *
Jesse Keating 3494df0
diff --git a/include/linux/usb.h b/include/linux/usb.h
Jesse Keating 3494df0
index e101a2d..dd47590 100644
Jesse Keating 3494df0
--- a/include/linux/usb.h
Jesse Keating 3494df0
+++ b/include/linux/usb.h
Jesse Keating 3494df0
@@ -540,6 +540,7 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
Jesse Keating 3494df0
 
Jesse Keating 3494df0
 /* USB autosuspend and autoresume */
Jesse Keating 3494df0
 #ifdef CONFIG_USB_SUSPEND
Jesse Keating 3494df0
+extern void usb_device_autosuspend_enable(struct usb_device *udev);
Jesse Keating 3494df0
 extern int usb_autopm_get_interface(struct usb_interface *intf);
Jesse Keating 3494df0
 extern void usb_autopm_put_interface(struct usb_interface *intf);
Jesse Keating 3494df0
 extern int usb_autopm_get_interface_async(struct usb_interface *intf);
Jesse Keating 3494df0
@@ -563,6 +564,9 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
Jesse Keating 3494df0
 
Jesse Keating 3494df0
 #else
Jesse Keating 3494df0
 
Jesse Keating 3494df0
+static inline void usb_device_autosuspend_enable(struct usb_device *udev)
Jesse Keating 3494df0
+{ }
Jesse Keating 3494df0
+
Jesse Keating 3494df0
 static inline int usb_autopm_get_interface(struct usb_interface *intf)
Jesse Keating 3494df0
 { return 0; }
Jesse Keating 3494df0
 static inline int usb_autopm_get_interface_async(struct usb_interface *intf)
Jesse Keating 3494df0
-- 
Jesse Keating 3494df0
1.6.5.2
Jesse Keating 3494df0