summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backport/backport-include/linux/hid.h5
-rw-r--r--backport/compat/backport-3.10.c17
2 files changed, 22 insertions, 0 deletions
diff --git a/backport/backport-include/linux/hid.h b/backport/backport-include/linux/hid.h
index 22ff6f14..555ec2bd 100644
--- a/backport/backport-include/linux/hid.h
+++ b/backport/backport-include/linux/hid.h
@@ -34,4 +34,9 @@ extern bool hid_ignore(struct hid_device *);
.bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,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/backport-3.10.c b/backport/compat/backport-3.10.c
index 980ed59d..b1550922 100644
--- a/backport/compat/backport-3.10.c
+++ b/backport/compat/backport-3.10.c
@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/err.h>
#include <linux/proc_fs.h>
+#include <linux/hid.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
#include <linux/init.h>
@@ -77,3 +78,19 @@ void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
de->gid = gid;
}
EXPORT_SYMBOL_GPL(proc_set_user);
+
+/*
+ * 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);