aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 933bf1052ec0..c66e6acf7152 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -137,6 +137,7 @@ struct i2c_hid {
137 * descriptor. */ 137 * descriptor. */
138 unsigned int bufsize; /* i2c buffer size */ 138 unsigned int bufsize; /* i2c buffer size */
139 char *inbuf; /* Input buffer */ 139 char *inbuf; /* Input buffer */
140 char *rawbuf; /* Raw Input buffer */
140 char *cmdbuf; /* Command buffer */ 141 char *cmdbuf; /* Command buffer */
141 char *argsbuf; /* Command arguments buffer */ 142 char *argsbuf; /* Command arguments buffer */
142 143
@@ -504,9 +505,11 @@ static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type,
504static void i2c_hid_free_buffers(struct i2c_hid *ihid) 505static void i2c_hid_free_buffers(struct i2c_hid *ihid)
505{ 506{
506 kfree(ihid->inbuf); 507 kfree(ihid->inbuf);
508 kfree(ihid->rawbuf);
507 kfree(ihid->argsbuf); 509 kfree(ihid->argsbuf);
508 kfree(ihid->cmdbuf); 510 kfree(ihid->cmdbuf);
509 ihid->inbuf = NULL; 511 ihid->inbuf = NULL;
512 ihid->rawbuf = NULL;
510 ihid->cmdbuf = NULL; 513 ihid->cmdbuf = NULL;
511 ihid->argsbuf = NULL; 514 ihid->argsbuf = NULL;
512 ihid->bufsize = 0; 515 ihid->bufsize = 0;
@@ -522,10 +525,11 @@ static int i2c_hid_alloc_buffers(struct i2c_hid *ihid, size_t report_size)
522 report_size; /* report */ 525 report_size; /* report */
523 526
524 ihid->inbuf = kzalloc(report_size, GFP_KERNEL); 527 ihid->inbuf = kzalloc(report_size, GFP_KERNEL);
528 ihid->rawbuf = kzalloc(report_size, GFP_KERNEL);
525 ihid->argsbuf = kzalloc(args_len, GFP_KERNEL); 529 ihid->argsbuf = kzalloc(args_len, GFP_KERNEL);
526 ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL); 530 ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL);
527 531
528 if (!ihid->inbuf || !ihid->argsbuf || !ihid->cmdbuf) { 532 if (!ihid->inbuf || !ihid->rawbuf || !ihid->argsbuf || !ihid->cmdbuf) {
529 i2c_hid_free_buffers(ihid); 533 i2c_hid_free_buffers(ihid);
530 return -ENOMEM; 534 return -ENOMEM;
531 } 535 }
@@ -552,12 +556,12 @@ static int i2c_hid_get_raw_report(struct hid_device *hid,
552 556
553 ret = i2c_hid_get_report(client, 557 ret = i2c_hid_get_report(client,
554 report_type == HID_FEATURE_REPORT ? 0x03 : 0x01, 558 report_type == HID_FEATURE_REPORT ? 0x03 : 0x01,
555 report_number, ihid->inbuf, ask_count); 559 report_number, ihid->rawbuf, ask_count);
556 560
557 if (ret < 0) 561 if (ret < 0)
558 return ret; 562 return ret;
559 563
560 ret_count = ihid->inbuf[0] | (ihid->inbuf[1] << 8); 564 ret_count = ihid->rawbuf[0] | (ihid->rawbuf[1] << 8);
561 565
562 if (ret_count <= 2) 566 if (ret_count <= 2)
563 return 0; 567 return 0;
@@ -566,7 +570,7 @@ static int i2c_hid_get_raw_report(struct hid_device *hid,
566 570
567 /* The query buffer contains the size, dropping it in the reply */ 571 /* The query buffer contains the size, dropping it in the reply */
568 count = min(count, ret_count - 2); 572 count = min(count, ret_count - 2);
569 memcpy(buf, ihid->inbuf + 2, count); 573 memcpy(buf, ihid->rawbuf + 2, count);
570 574
571 return count; 575 return count;
572} 576}