compat: backport usb_autopm_[get|put]_interface_no_[resume|suspend]()
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Thu, 18 Oct 2012 21:06:36 +0000 (14:06 -0700)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Thu, 18 Oct 2012 22:14:04 +0000 (15:14 -0700)
This backports these two routines:

  * usb_autopm_get_interface_no_resume()
  * usb_autopm_put_interface_no_suspend()

These routines simply increment or decrement the USB
pm usage counter without trying to either suspend or
resume.

mcgrof@garbanzo ~/compat (git::master)$ time ckmake
Trying kernel 3.5.0-030500-generic [OK]
Trying kernel 3.4.4-030404-generic [OK]
Trying kernel 3.3.7-030307-generic [OK]
Trying kernel 3.2.2-030202-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.18-030018-generic [OK]
Trying kernel 2.6.39-02063904-generic [OK]
Trying kernel 2.6.38-02063808-generic [OK]
Trying kernel 2.6.37-02063706-generic [OK]
Trying kernel 2.6.36-02063604-generic [OK]
Trying kernel 2.6.35-02063512-generic [OK]
Trying kernel 2.6.34-02063410-generic [OK]
Trying kernel 2.6.33-02063305-generic [OK]
Trying kernel 2.6.32-02063255-generic [OK]
Trying kernel 2.6.31-02063113-generic [OK]
Trying kernel 2.6.30-02063010-generic [OK]
Trying kernel 2.6.29-02062906-generic [OK]
Trying kernel 2.6.28-02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]

real    1m2.113s
user    3m30.573s
sys     0m31.922s

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
compat/compat-2.6.33.c
include/linux/compat-2.6.33.h

index 365a1a6ca91d55421f436f5f0eb6f76af2b85212..6e68db4b2ad990da5cd94662959e7bdd12eb2eb6 100644 (file)
@@ -9,6 +9,49 @@
  */
 
 #include <linux/compat.h>
+#include <linux/device.h>
+#include <linux/usb.h>
+#include <linux/pm_runtime.h>
+
+#ifdef CONFIG_USB_SUSPEND
+/**
+ * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter
+ * @intf: the usb_interface whose counter should be incremented
+ *
+ * This routine increments @intf's usage counter but does not carry out an
+ * autoresume.
+ *
+ * This routine can run in atomic context.
+ */
+void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
+{
+       struct usb_device       *udev = interface_to_usbdev(intf);
+
+       usb_mark_last_busy(udev);
+       atomic_inc(&intf->pm_usage_cnt);
+       pm_runtime_get_noresume(&intf->dev);
+}
+EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume);
+
+/**
+ * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter
+ * @intf: the usb_interface whose counter should be decremented
+ *
+ * This routine decrements @intf's usage counter but does not carry out an
+ * autosuspend.
+ *
+ * This routine can run in atomic context.
+ */
+void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
+{
+       struct usb_device       *udev = interface_to_usbdev(intf);
+
+       usb_mark_last_busy(udev);
+       atomic_dec(&intf->pm_usage_cnt);
+       pm_runtime_put_noidle(&intf->dev);
+}
+EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend);
+#endif /* CONFIG_USB_SUSPEND */
 
 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
 
index 60caab0ab80661511f411b804309bd1600f83acc..307834adf1e83db157d939acde5e52f38fd155e0 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/skbuff.h>
 #include <linux/pci.h>
+#include <linux/usb.h>
 #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cistpl.h>
 #include <linux/firmware.h>
 #include <linux/input.h>
 
+#ifdef CONFIG_USB_SUSPEND
+extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
+extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
+#else
+static inline void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
+{
+       atomic_inc(&intf->pm_usage_cnt);
+}
+static inline void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
+{
+       atomic_dec(&intf->pm_usage_cnt);
+}
+#endif /* CONFIG_USB_SUSPEND */
+
 #if defined(CONFIG_COMPAT_FIRMWARE_CLASS)
 #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE)
 #define release_firmware compat_release_firmware