From 1e9bddfd1d152e2cb133c53fe8b812945896f6d4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 18 Oct 2012 14:06:36 -0700 Subject: [PATCH] compat: backport usb_autopm_[get|put]_interface_no_[resume|suspend]() 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 --- compat/compat-2.6.33.c | 43 +++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.33.h | 15 ++++++++++++ 2 files changed, 58 insertions(+) diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 365a1a6ca91d..6e68db4b2ad9 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -9,6 +9,49 @@ */ #include +#include +#include +#include + +#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) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 60caab0ab806..307834adf1e8 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -7,6 +7,7 @@ #include #include +#include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) #include #include @@ -15,6 +16,20 @@ #include #include +#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 -- 2.30.2