From ef6119c1805a3cf0d49a9c490b937b94f6519952 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 19 Aug 2013 01:37:50 +0200 Subject: backports: add hid_alloc_report_buf() Upstream commit: 1a996968fc51cc1323e1bedceb32143aa1226e9b This is now in kernel 3.10+ Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- backport/backport-include/linux/hid.h | 5 +++++ backport/compat/backport-3.10.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) 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 #include #include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) #include @@ -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); -- cgit v1.2.3