Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343071
b: refs/heads/master
c: e5b50fe
h: refs/heads/master
i:
  343069: e39e5fb
  343067: f7ccdba
  343063: 4c07b11
  343055: 7e8a34b
  343039: 3256d75
v: v3
  • Loading branch information
Benjamin Tissoires authored and Jiri Kosina committed Dec 6, 2012
1 parent a4770c0 commit 0f338e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8a1bbb5319384dab6568ac2ce30d19b922413bec
refs/heads/master: e5b50fe7bea43d0658773c89ba410ecc56867ee6
16 changes: 12 additions & 4 deletions trunk/drivers/hid/i2c-hid/i2c-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,23 +502,31 @@ static int i2c_hid_get_raw_report(struct hid_device *hid,
{
struct i2c_client *client = hid->driver_data;
struct i2c_hid *ihid = i2c_get_clientdata(client);
size_t ret_count, ask_count;
int ret;

if (report_type == HID_OUTPUT_REPORT)
return -EINVAL;

if (count > ihid->bufsize)
count = ihid->bufsize;
/* +2 bytes to include the size of the reply in the query buffer */
ask_count = min(count + 2, (size_t)ihid->bufsize);

ret = i2c_hid_get_report(client,
report_type == HID_FEATURE_REPORT ? 0x03 : 0x01,
report_number, ihid->inbuf, count);
report_number, ihid->inbuf, ask_count);

if (ret < 0)
return ret;

count = ihid->inbuf[0] | (ihid->inbuf[1] << 8);
ret_count = ihid->inbuf[0] | (ihid->inbuf[1] << 8);

if (!ret_count)
return 0;

ret_count = min(ret_count, ask_count);

/* The query buffer contains the size, dropping it in the reply */
count = min(count, ret_count - 2);
memcpy(buf, ihid->inbuf + 2, count);

return count;
Expand Down

0 comments on commit 0f338e7

Please sign in to comment.