compat: backport system_nrt_wq
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 6 Nov 2011 21:25:03 +0000 (22:25 +0100)
committerLuis R. Rodriguez <mcgrof@qca.qualcomm.com>
Tue, 8 Nov 2011 19:21:01 +0000 (11:21 -0800)
The workqueue system_nrt_wq is not available in kernel version < 2.6.36.
This backport code creates such a queue but this old kernel does not
have WQ_NON_REENTRANT, so we use a single threaded queue instead as it
should meat the same restrictions.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
compat/compat-2.6.36.c
compat/main.c
include/linux/compat-2.6.36.h

index 5faefb4..aab25df 100644 (file)
@@ -92,5 +92,20 @@ void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor)
        spin_unlock_irqrestore(&anchor->lock, flags);
 }
 EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs);
+
+struct workqueue_struct *system_nrt_wq __read_mostly;
+EXPORT_SYMBOL_GPL(system_nrt_wq);
+
+void compat_system_workqueue_create()
+{
+       system_nrt_wq = create_singlethread_workqueue("events_nrt");
+       WARN_ON(system_nrt_wq);
+}
+
+void compat_system_workqueue_destroy()
+{
+       destroy_workqueue(system_nrt_wq);
+}
+
 #endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */
 
index a1a48d0..f830488 100644 (file)
@@ -36,6 +36,7 @@ static int __init compat_init(void)
 {
        /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */
        compat_pm_qos_power_init();
+       compat_system_workqueue_create();
 
        printk(KERN_INFO
               COMPAT_PROJECT " backport release: "
@@ -52,6 +53,7 @@ module_init(compat_init);
 static void __exit compat_exit(void)
 {
        compat_pm_qos_power_deinit();
+       compat_system_workqueue_destroy();
 
         return;
 }
index f4d6f80..29ade27 100644 (file)
@@ -134,6 +134,21 @@ static inline void skb_tx_timestamp(struct sk_buff *skb)
 {
 }
 
+extern struct workqueue_struct *system_nrt_wq;
+
+void compat_system_workqueue_create(void);
+void compat_system_workqueue_destroy(void);
+
+#else
+
+static inline void compat_system_workqueue_create(void)
+{
+}
+
+static inline void compat_system_workqueue_destroy(void)
+{
+}
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
 
 #endif /* LINUX_26_36_COMPAT_H */