diff options
author | Huzefa Kankroliwala <huzefa.nomanx.kankroliwala@intel.com> | 2013-04-03 08:45:21 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-04-04 03:59:32 -0400 |
commit | 7c4d577367fb710ea74a56955c5e3546fe5dd7ac (patch) | |
tree | 2e30de664d1f64d122a49b19604916f873f3fcdb /drivers/hid/i2c-hid/i2c-hid.c | |
parent | 83a44ac8bf4a8e6cbbf0c00ff281a482778f708a (diff) |
HID: i2c-hid: fix length for set/get report in i2c hid
With the current i2c hid driver set/get report does not work
as expected, for e.g sensor hub properties like power state,
frequency etc is not set properly on the device as a result
we do not get events.
The problem is that i2c hid driver in function i2c_hid_request
sets length equal to default buffer size for which the sensor
hub does not respond on get/set commands. Use report length
and calculate it based on report size and id.
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Huzefa Kankroliwala <huzefa.nomanx.kankroliwala@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/i2c-hid/i2c-hid.c')
-rw-r--r-- | drivers/hid/i2c-hid/i2c-hid.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 935f387be95a..2b1799a3b212 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
@@ -567,18 +567,17 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep, | |||
567 | int reqtype) | 567 | int reqtype) |
568 | { | 568 | { |
569 | struct i2c_client *client = hid->driver_data; | 569 | struct i2c_client *client = hid->driver_data; |
570 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
571 | char *buf; | 570 | char *buf; |
572 | int ret; | 571 | int ret; |
572 | int len = i2c_hid_get_report_length(rep) - 2; | ||
573 | 573 | ||
574 | buf = kzalloc(ihid->bufsize, GFP_KERNEL); | 574 | buf = kzalloc(len, GFP_KERNEL); |
575 | if (!buf) | 575 | if (!buf) |
576 | return; | 576 | return; |
577 | 577 | ||
578 | switch (reqtype) { | 578 | switch (reqtype) { |
579 | case HID_REQ_GET_REPORT: | 579 | case HID_REQ_GET_REPORT: |
580 | ret = i2c_hid_get_raw_report(hid, rep->id, buf, ihid->bufsize, | 580 | ret = i2c_hid_get_raw_report(hid, rep->id, buf, len, rep->type); |
581 | rep->type); | ||
582 | if (ret < 0) | 581 | if (ret < 0) |
583 | dev_err(&client->dev, "%s: unable to get report: %d\n", | 582 | dev_err(&client->dev, "%s: unable to get report: %d\n", |
584 | __func__, ret); | 583 | __func__, ret); |
@@ -587,7 +586,7 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep, | |||
587 | break; | 586 | break; |
588 | case HID_REQ_SET_REPORT: | 587 | case HID_REQ_SET_REPORT: |
589 | hid_output_report(rep, buf); | 588 | hid_output_report(rep, buf); |
590 | i2c_hid_output_raw_report(hid, buf, ihid->bufsize, rep->type); | 589 | i2c_hid_output_raw_report(hid, buf, len, rep->type); |
591 | break; | 590 | break; |
592 | } | 591 | } |
593 | 592 | ||