summaryrefslogtreecommitdiff
path: root/backport
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2013-08-19 01:37:50 +0200
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-08-27 11:43:04 -0700
commit1a996968fc51cc1323e1bedceb32143aa1226e9b (patch)
treec7a6ba22703c71b40eeee073f0324def59569a2b /backport
parentea9040ab25c0e0da73a754f20af98a425063cbf9 (diff)
backports: add hid_alloc_report_buf()
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Diffstat (limited to 'backport')
-rw-r--r--backport/backport-include/linux/hid.h5
-rw-r--r--backport/compat/Makefile1
-rw-r--r--backport/compat/backport-3.12.c28
3 files changed, 34 insertions, 0 deletions
diff --git a/backport/backport-include/linux/hid.h b/backport/backport-include/linux/hid.h
index 2cae9b7e..91d3de6a 100644
--- a/backport/backport-include/linux/hid.h
+++ b/backport/backport-include/linux/hid.h
@@ -79,4 +79,9 @@ extern bool hid_ignore(struct hid_device *);
dev_dbg(&(hid)->dev, fmt, ##arg)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
+#define hid_alloc_report_buf LINUX_BACKPORT(hid_alloc_report_buf)
+u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
+#endif
+
#endif /* __BACKPORT_HID_H */
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
index 80c0294f..efdeebd5 100644
--- a/backport/compat/Makefile
+++ b/backport/compat/Makefile
@@ -36,6 +36,7 @@ compat-$(CPTCFG_BACKPORT_KERNEL_3_8) += compat-3.8.o
compat-$(CPTCFG_BACKPORT_KERNEL_3_9) += compat-3.9.o
compat-$(CPTCFG_BACKPORT_KERNEL_3_10) += backport-3.10.o
compat-$(CPTCFG_BACKPORT_KERNEL_3_11) += backport-3.11.o
+compat-$(CPTCFG_BACKPORT_KERNEL_3_12) += backport-3.12.o
compat-$(CPTCFG_BACKPORT_BUILD_KFIFO) += kfifo.o
compat-$(CPTCFG_BACKPORT_BUILD_GENERIC_ATOMIC64) += compat_atomic.o
diff --git a/backport/compat/backport-3.12.c b/backport/compat/backport-3.12.c
new file mode 100644
index 00000000..8ca9a8e5
--- /dev/null
+++ b/backport/compat/backport-3.12.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * Backport functionality introduced in Linux 3.12.
+ *
+ * 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/export.h>
+#include <linux/hid.h>
+
+/*
+ * Allocator for buffer that is going to be passed to hid_output_report()
+ */
+u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
+{
+ /*
+ * 7 extra bytes are necessary to achieve proper functionality
+ * of implement() working on 8 byte chunks
+ */
+
+ int len = ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7;
+
+ return kmalloc(len, flags);
+}
+EXPORT_SYMBOL_GPL(hid_alloc_report_buf);