diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2013-08-19 01:37:50 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2013-10-28 23:29:07 +0100 |
commit | 5207db9d97475bc51ae8fb606c6f20c4d72868bb (patch) | |
tree | e4e18043008d525b84d482ed142038e13c402726 | |
parent | 9257103d0d58bfe41d2339c59c715135f1bb3a84 (diff) |
backports: add hid_alloc_report_buf()
Upstream commit: 1a996968fc51cc1323e1bedceb32143aa1226e9b
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
-rw-r--r-- | backport/backport-include/linux/hid.h | 5 | ||||
-rw-r--r-- | backport/compat/backport-3.10.c | 17 |
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); |