backports: fix bit_wait() and bit_wait_io()
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 26 Jul 2014 19:37:03 +0000 (21:37 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 27 Jul 2014 21:40:17 +0000 (23:40 +0200)
In kernel version < 3.17 wait_on_bit() takes an action as a parameter,
which contains a schedule() or io_schedule() call in most cases. For
such calls wait_on_bit() was changed to not take an action but execute
schedule() action. This patch backports the new behavior to old kernel
versions.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
backport/backport-include/linux/wait.h [new file with mode: 0644]
backport/compat/Makefile
backport/compat/backport-3.17.c [new file with mode: 0644]

diff --git a/backport/backport-include/linux/wait.h b/backport/backport-include/linux/wait.h
new file mode 100644 (file)
index 0000000..dfb111d
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __BACKPORT_LINUX_WAIT_H
+#define __BACKPORT_LINUX_WAIT_H
+#include_next <linux/wait.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+extern int bit_wait(void *);
+extern int bit_wait_io(void *);
+
+static inline int
+backport_wait_on_bit(void *word, int bit, unsigned mode)
+{
+       return wait_on_bit(word, bit, bit_wait, mode);
+}
+
+static inline int
+backport_wait_on_bit_io(void *word, int bit, unsigned mode)
+{
+       return wait_on_bit(word, bit, bit_wait_io, mode);
+}
+
+#define wait_on_bit LINUX_BACKPORT(wait_on_bit)
+#define wait_on_bit_io LINUX_BACKPORT(wait_on_bit_io)
+
+#endif
+
+#endif /* __BACKPORT_LINUX_WAIT_H */
index 353a71dc9fa09388457484881cc7a3ef3bd9b2d0..d648982983b131daa5909af4ccd749cd6f2f039e 100644 (file)
@@ -18,6 +18,7 @@ compat-$(CPTCFG_BACKPORT_KERNEL_3_12) += backport-3.12.o
 compat-$(CPTCFG_BACKPORT_KERNEL_3_13) += backport-3.13.o
 compat-$(CPTCFG_BACKPORT_KERNEL_3_14) += backport-3.14.o
 compat-$(CPTCFG_BACKPORT_KERNEL_3_15) += backport-3.15.o
+compat-$(CPTCFG_BACKPORT_KERNEL_3_17) += backport-3.17.o
 
 compat-$(CPTCFG_BACKPORT_BUILD_CRYPTO_CCM) += crypto-ccm.o
 compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o
diff --git a/backport/compat/backport-3.17.c b/backport/compat/backport-3.17.c
new file mode 100644 (file)
index 0000000..9cc0a82
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014  Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Backport functionality introduced in Linux 3.17.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/export.h>
+
+int bit_wait(void *word)
+{
+       schedule();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(bit_wait);
+
+int bit_wait_io(void *word)
+{
+       io_schedule();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(bit_wait_io);
+