From 0f1fd2a84233605644632dd0b065f63d8d332cc7 Mon Sep 17 00:00:00 2001
From: Tobias Powalowski <tpowa@archlinux.org>
Date: Thu, 3 Sep 2015 18:55:59 +0000
Subject: [PATCH] fixed initial 4.2 with non gpl patch for nvidia

---
 0001-make_flush_workqueue_non_gpl.patch | 34 +++++++++++++++++++++++++
 PKGBUILD                                | 10 ++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 0001-make_flush_workqueue_non_gpl.patch

diff --git a/0001-make_flush_workqueue_non_gpl.patch b/0001-make_flush_workqueue_non_gpl.patch
new file mode 100644
index 0000000..1ba8cb9
--- /dev/null
+++ b/0001-make_flush_workqueue_non_gpl.patch
@@ -0,0 +1,34 @@
+From 1dadafa86a779884f14a6e7a3ddde1a57b0a0a65 Mon Sep 17 00:00:00 2001
+From: Tim Gardner <tim.gardner@canonical.com>
+Date: Tue, 4 Aug 2015 11:26:04 -0600
+Subject: workqueue: Make flush_workqueue() available again to non GPL modules
+
+Commit 37b1ef31a568fc02e53587620226e5f3c66454c8 ("workqueue: move
+flush_scheduled_work() to workqueue.h") moved the exported non GPL
+flush_scheduled_work() from a function to an inline wrapper.
+Unfortunately, it directly calls flush_workqueue() which is a GPL function.
+This has the effect of changing the licensing requirement for this function
+and makes it unavailable to non GPL modules.
+
+See commit ad7b1f841f8a54c6d61ff181451f55b68175e15a ("workqueue: Make
+schedule_work() available again to non GPL modules") for precedent.
+
+Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+
+diff --git a/kernel/workqueue.c b/kernel/workqueue.c
+index 4c4f061..a413acb 100644
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -2614,7 +2614,7 @@ void flush_workqueue(struct workqueue_struct *wq)
+ out_unlock:
+ 	mutex_unlock(&wq->mutex);
+ }
+-EXPORT_SYMBOL_GPL(flush_workqueue);
++EXPORT_SYMBOL(flush_workqueue);
+ 
+ /**
+  * drain_workqueue - drain a workqueue
+-- 
+cgit v0.10.2
+
diff --git a/PKGBUILD b/PKGBUILD
index b335f36..88c29b6 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -19,13 +19,15 @@ source=("https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz"
         'config' 'config.x86_64'
         # standard config files for mkinitcpio ramdisk
         'linux.preset'
-        'change-default-console-loglevel.patch')
+        'change-default-console-loglevel.patch'
+        '0001-make_flush_workqueue_non_gpl.patch')
 sha256sums=('cf20e044f17588d2a42c8f2a450b0fd84dfdbd579b489d93e9ab7d0e8b45dbeb'
             'SKIP'
             'dbac1b59a0a1861fe2ae64348512f0994594ccbe959f50aa94b91d8464e44c97'
             '90fa14aca07b560334ddb14ffe4f04c3ed149851e45952a5e4a2d0732ce29fb4'
             'f0d90e756f14533ee67afda280500511a62465b4f76adcc5effa95a40045179c'
-            '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99')
+            '1256b241cd477b265a3c2d64bdc19ffe3c9bbcee82ea3994c590c2c76e767d99'
+            '4e776734e2c2185910a6fbb6f333d967b04f4a72b3196310af286c6a779bd97d')
 validpgpkeys=(
               'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
               '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
@@ -42,6 +44,10 @@ prepare() {
   # add latest fixes from stable queue, if needed
   # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
 
+  # fix work_queue symbol to non GPL for nvidia module building
+  # already applied to 4.3 series
+  patch -p1 -i "${srcdir}/0001-make_flush_workqueue_non_gpl.patch"
+
   # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
   # remove this when a Kconfig knob is made available by upstream
   # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)