Commit 7c4d5773 authored by Huzefa Kankroliwala's avatar Huzefa Kankroliwala Committed by Jiri Kosina

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: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarHuzefa Kankroliwala <huzefa.nomanx.kankroliwala@intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 83a44ac8
...@@ -567,18 +567,17 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep, ...@@ -567,18 +567,17 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
int reqtype) int reqtype)
{ {
struct i2c_client *client = hid->driver_data; struct i2c_client *client = hid->driver_data;
struct i2c_hid *ihid = i2c_get_clientdata(client);
char *buf; char *buf;
int ret; int ret;
int len = i2c_hid_get_report_length(rep) - 2;
buf = kzalloc(ihid->bufsize, GFP_KERNEL); buf = kzalloc(len, GFP_KERNEL);
if (!buf) if (!buf)
return; return;
switch (reqtype) { switch (reqtype) {
case HID_REQ_GET_REPORT: case HID_REQ_GET_REPORT:
ret = i2c_hid_get_raw_report(hid, rep->id, buf, ihid->bufsize, ret = i2c_hid_get_raw_report(hid, rep->id, buf, len, rep->type);
rep->type);
if (ret < 0) if (ret < 0)
dev_err(&client->dev, "%s: unable to get report: %d\n", dev_err(&client->dev, "%s: unable to get report: %d\n",
__func__, ret); __func__, ret);
...@@ -587,7 +586,7 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep, ...@@ -587,7 +586,7 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
break; break;
case HID_REQ_SET_REPORT: case HID_REQ_SET_REPORT:
hid_output_report(rep, buf); hid_output_report(rep, buf);
i2c_hid_output_raw_report(hid, buf, ihid->bufsize, rep->type); i2c_hid_output_raw_report(hid, buf, len, rep->type);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment