aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c0ef2b49a00c..ebcc7a232a03 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -90,7 +90,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
90 struct hid_field *field; 90 struct hid_field *field;
91 91
92 if (report->maxfield == HID_MAX_FIELDS) { 92 if (report->maxfield == HID_MAX_FIELDS) {
93 dbg_hid("too many fields in report\n"); 93 hid_err(report->device, "too many fields in report\n");
94 return NULL; 94 return NULL;
95 } 95 }
96 96
@@ -121,7 +121,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
121 usage = parser->local.usage[0]; 121 usage = parser->local.usage[0];
122 122
123 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { 123 if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) {
124 dbg_hid("collection stack overflow\n"); 124 hid_err(parser->device, "collection stack overflow\n");
125 return -1; 125 return -1;
126 } 126 }
127 127
@@ -129,7 +129,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
129 collection = kmalloc(sizeof(struct hid_collection) * 129 collection = kmalloc(sizeof(struct hid_collection) *
130 parser->device->collection_size * 2, GFP_KERNEL); 130 parser->device->collection_size * 2, GFP_KERNEL);
131 if (collection == NULL) { 131 if (collection == NULL) {
132 dbg_hid("failed to reallocate collection array\n"); 132 hid_err(parser->device, "failed to reallocate collection array\n");
133 return -1; 133 return -1;
134 } 134 }
135 memcpy(collection, parser->device->collection, 135 memcpy(collection, parser->device->collection,
@@ -165,7 +165,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
165static int close_collection(struct hid_parser *parser) 165static int close_collection(struct hid_parser *parser)
166{ 166{
167 if (!parser->collection_stack_ptr) { 167 if (!parser->collection_stack_ptr) {
168 dbg_hid("collection stack underflow\n"); 168 hid_err(parser->device, "collection stack underflow\n");
169 return -1; 169 return -1;
170 } 170 }
171 parser->collection_stack_ptr--; 171 parser->collection_stack_ptr--;
@@ -197,7 +197,7 @@ static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type)
197static int hid_add_usage(struct hid_parser *parser, unsigned usage) 197static int hid_add_usage(struct hid_parser *parser, unsigned usage)
198{ 198{
199 if (parser->local.usage_index >= HID_MAX_USAGES) { 199 if (parser->local.usage_index >= HID_MAX_USAGES) {
200 dbg_hid("usage index exceeded\n"); 200 hid_err(parser->device, "usage index exceeded\n");
201 return -1; 201 return -1;
202 } 202 }
203 parser->local.usage[parser->local.usage_index] = usage; 203 parser->local.usage[parser->local.usage_index] = usage;
@@ -222,12 +222,13 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
222 222
223 report = hid_register_report(parser->device, report_type, parser->global.report_id); 223 report = hid_register_report(parser->device, report_type, parser->global.report_id);
224 if (!report) { 224 if (!report) {
225 dbg_hid("hid_register_report failed\n"); 225 hid_err(parser->device, "hid_register_report failed\n");
226 return -1; 226 return -1;
227 } 227 }
228 228
229 if (parser->global.logical_maximum < parser->global.logical_minimum) { 229 if (parser->global.logical_maximum < parser->global.logical_minimum) {
230 dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); 230 hid_err(parser->device, "logical range invalid %d %d\n",
231 parser->global.logical_minimum, parser->global.logical_maximum);
231 return -1; 232 return -1;
232 } 233 }
233 234
@@ -307,7 +308,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
307 case HID_GLOBAL_ITEM_TAG_PUSH: 308 case HID_GLOBAL_ITEM_TAG_PUSH:
308 309
309 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { 310 if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) {
310 dbg_hid("global environment stack overflow\n"); 311 hid_err(parser->device, "global environment stack overflow\n");
311 return -1; 312 return -1;
312 } 313 }
313 314
@@ -318,7 +319,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
318 case HID_GLOBAL_ITEM_TAG_POP: 319 case HID_GLOBAL_ITEM_TAG_POP:
319 320
320 if (!parser->global_stack_ptr) { 321 if (!parser->global_stack_ptr) {
321 dbg_hid("global environment stack underflow\n"); 322 hid_err(parser->device, "global environment stack underflow\n");
322 return -1; 323 return -1;
323 } 324 }
324 325
@@ -363,7 +364,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
363 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: 364 case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
364 parser->global.report_size = item_udata(item); 365 parser->global.report_size = item_udata(item);
365 if (parser->global.report_size > 96) { 366 if (parser->global.report_size > 96) {
366 dbg_hid("invalid report_size %d\n", 367 hid_err(parser->device, "invalid report_size %d\n",
367 parser->global.report_size); 368 parser->global.report_size);
368 return -1; 369 return -1;
369 } 370 }
@@ -372,7 +373,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
372 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: 373 case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
373 parser->global.report_count = item_udata(item); 374 parser->global.report_count = item_udata(item);
374 if (parser->global.report_count > HID_MAX_USAGES) { 375 if (parser->global.report_count > HID_MAX_USAGES) {
375 dbg_hid("invalid report_count %d\n", 376 hid_err(parser->device, "invalid report_count %d\n",
376 parser->global.report_count); 377 parser->global.report_count);
377 return -1; 378 return -1;
378 } 379 }
@@ -381,13 +382,13 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
381 case HID_GLOBAL_ITEM_TAG_REPORT_ID: 382 case HID_GLOBAL_ITEM_TAG_REPORT_ID:
382 parser->global.report_id = item_udata(item); 383 parser->global.report_id = item_udata(item);
383 if (parser->global.report_id == 0) { 384 if (parser->global.report_id == 0) {
384 dbg_hid("report_id 0 is invalid\n"); 385 hid_err(parser->device, "report_id 0 is invalid\n");
385 return -1; 386 return -1;
386 } 387 }
387 return 0; 388 return 0;
388 389
389 default: 390 default:
390 dbg_hid("unknown global tag 0x%x\n", item->tag); 391 hid_err(parser->device, "unknown global tag 0x%x\n", item->tag);
391 return -1; 392 return -1;
392 } 393 }
393} 394}
@@ -414,14 +415,14 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
414 * items and the first delimiter set. 415 * items and the first delimiter set.
415 */ 416 */
416 if (parser->local.delimiter_depth != 0) { 417 if (parser->local.delimiter_depth != 0) {
417 dbg_hid("nested delimiters\n"); 418 hid_err(parser->device, "nested delimiters\n");
418 return -1; 419 return -1;
419 } 420 }
420 parser->local.delimiter_depth++; 421 parser->local.delimiter_depth++;
421 parser->local.delimiter_branch++; 422 parser->local.delimiter_branch++;
422 } else { 423 } else {
423 if (parser->local.delimiter_depth < 1) { 424 if (parser->local.delimiter_depth < 1) {
424 dbg_hid("bogus close delimiter\n"); 425 hid_err(parser->device, "bogus close delimiter\n");
425 return -1; 426 return -1;
426 } 427 }
427 parser->local.delimiter_depth--; 428 parser->local.delimiter_depth--;
@@ -506,7 +507,7 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
506 ret = hid_add_field(parser, HID_FEATURE_REPORT, data); 507 ret = hid_add_field(parser, HID_FEATURE_REPORT, data);
507 break; 508 break;
508 default: 509 default:
509 dbg_hid("unknown main item tag 0x%x\n", item->tag); 510 hid_err(parser->device, "unknown main item tag 0x%x\n", item->tag);
510 ret = 0; 511 ret = 0;
511 } 512 }
512 513
@@ -678,12 +679,12 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
678 while ((start = fetch_item(start, end, &item)) != NULL) { 679 while ((start = fetch_item(start, end, &item)) != NULL) {
679 680
680 if (item.format != HID_ITEM_FORMAT_SHORT) { 681 if (item.format != HID_ITEM_FORMAT_SHORT) {
681 dbg_hid("unexpected long global item\n"); 682 hid_err(device, "unexpected long global item\n");
682 goto err; 683 goto err;
683 } 684 }
684 685
685 if (dispatch_type[item.type](parser, &item)) { 686 if (dispatch_type[item.type](parser, &item)) {
686 dbg_hid("item %u %u %u %u parsing failed\n", 687 hid_err(device, "item %u %u %u %u parsing failed\n",
687 item.format, (unsigned)item.size, 688 item.format, (unsigned)item.size,
688 (unsigned)item.type, (unsigned)item.tag); 689 (unsigned)item.type, (unsigned)item.tag);
689 goto err; 690 goto err;
@@ -691,11 +692,11 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
691 692
692 if (start == end) { 693 if (start == end) {
693 if (parser->collection_stack_ptr) { 694 if (parser->collection_stack_ptr) {
694 dbg_hid("unbalanced collection at end of report description\n"); 695 hid_err(device, "unbalanced collection at end of report description\n");
695 goto err; 696 goto err;
696 } 697 }
697 if (parser->local.delimiter_depth) { 698 if (parser->local.delimiter_depth) {
698 dbg_hid("unbalanced delimiter at end of report description\n"); 699 hid_err(device, "unbalanced delimiter at end of report description\n");
699 goto err; 700 goto err;
700 } 701 }
701 vfree(parser); 702 vfree(parser);
@@ -703,7 +704,7 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
703 } 704 }
704 } 705 }
705 706
706 dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); 707 hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
707err: 708err:
708 vfree(parser); 709 vfree(parser);
709 return ret; 710 return ret;
@@ -873,7 +874,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field,
873 ret = hdrv->event(hid, field, usage, value); 874 ret = hdrv->event(hid, field, usage, value);
874 if (ret != 0) { 875 if (ret != 0) {
875 if (ret < 0) 876 if (ret < 0)
876 dbg_hid("%s's event failed with %d\n", 877 hid_err(hid, "%s's event failed with %d\n",
877 hdrv->name, ret); 878 hdrv->name, ret);
878 return; 879 return;
879 } 880 }
@@ -995,12 +996,13 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
995 hid_dump_input(field->report->device, field->usage + offset, value); 996 hid_dump_input(field->report->device, field->usage + offset, value);
996 997
997 if (offset >= field->report_count) { 998 if (offset >= field->report_count) {
998 dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); 999 hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n",
1000 offset, field->report_count);
999 return -1; 1001 return -1;
1000 } 1002 }
1001 if (field->logical_minimum < 0) { 1003 if (field->logical_minimum < 0) {
1002 if (value != snto32(s32ton(value, size), size)) { 1004 if (value != snto32(s32ton(value, size), size)) {
1003 dbg_hid("value %d is out of range\n", value); 1005 hid_err(field->report->device, "value %d is out of range\n", value);
1004 return -1; 1006 return -1;
1005 } 1007 }
1006 } 1008 }