diff options
author | Nikolai Kondrashov <spbnick@gmail.com> | 2010-08-06 15:03:06 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-08-09 13:52:42 -0400 |
commit | 73e4008ddddc84d5f2499c17012b340a0dae153e (patch) | |
tree | d3adfa8c5792e71c21cb7a9cd18517cce9c92685 /drivers/hid/hid-cypress.c | |
parent | 3cfc2c42c1cbc8e238bb9c0612c0df4565e3a8b4 (diff) |
HID: allow resizing and replacing report descriptors
Update hid_driver's report_fixup prototype to allow changing report
descriptor size and/or returning completely different report descriptor.
Update existing usage accordingly.
This is to give more freedom in descriptor fixup and to allow having a whole
fixed descriptor in the code for the sake of readability.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-cypress.c')
-rw-r--r-- | drivers/hid/hid-cypress.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c index 998b6f443d7d..4cd0e2345991 100644 --- a/drivers/hid/hid-cypress.c +++ b/drivers/hid/hid-cypress.c | |||
@@ -31,16 +31,16 @@ | |||
31 | * Some USB barcode readers from cypress have usage min and usage max in | 31 | * Some USB barcode readers from cypress have usage min and usage max in |
32 | * the wrong order | 32 | * the wrong order |
33 | */ | 33 | */ |
34 | static void cp_report_fixup(struct hid_device *hdev, __u8 *rdesc, | 34 | static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
35 | unsigned int rsize) | 35 | unsigned int *rsize) |
36 | { | 36 | { |
37 | unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); | 37 | unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); |
38 | unsigned int i; | 38 | unsigned int i; |
39 | 39 | ||
40 | if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) | 40 | if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX)) |
41 | return; | 41 | return rdesc; |
42 | 42 | ||
43 | for (i = 0; i < rsize - 4; i++) | 43 | for (i = 0; i < *rsize - 4; i++) |
44 | if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { | 44 | if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) { |
45 | __u8 tmp; | 45 | __u8 tmp; |
46 | 46 | ||
@@ -50,6 +50,7 @@ static void cp_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
50 | rdesc[i + 3] = rdesc[i + 1]; | 50 | rdesc[i + 3] = rdesc[i + 1]; |
51 | rdesc[i + 1] = tmp; | 51 | rdesc[i + 1] = tmp; |
52 | } | 52 | } |
53 | return rdesc; | ||
53 | } | 54 | } |
54 | 55 | ||
55 | static int cp_input_mapped(struct hid_device *hdev, struct hid_input *hi, | 56 | static int cp_input_mapped(struct hid_device *hdev, struct hid_input *hi, |