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 <[email protected]>
Reviewed-by: Benjamin Tissoires <[email protected]>
Signed-off-by: Huzefa Kankroliwala <[email protected]>
---
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 935f387..2b1799a 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,
int reqtype)
{
struct i2c_client *client = hid->driver_data;
- struct i2c_hid *ihid = i2c_get_clientdata(client);
char *buf;
int ret;
+ int len = i2c_hid_get_report_length(rep) - 2;
- buf = kzalloc(ihid->bufsize, GFP_KERNEL);
+ buf = kzalloc(len, GFP_KERNEL);
if (!buf)
return;
switch (reqtype) {
case HID_REQ_GET_REPORT:
- ret = i2c_hid_get_raw_report(hid, rep->id, buf, ihid->bufsize,
- rep->type);
+ ret = i2c_hid_get_raw_report(hid, rep->id, buf, len, rep->type);
if (ret < 0)
dev_err(&client->dev, "%s: unable to get report: %d\n",
__func__, ret);
@@ -587,7 +586,7 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
break;
case HID_REQ_SET_REPORT:
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;
}
--
1.7.4.1
On Wed, 3 Apr 2013, Huzefa Kankroliwala wrote:
> 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 <[email protected]>
> Reviewed-by: Benjamin Tissoires <[email protected]>
> Signed-off-by: Huzefa Kankroliwala <[email protected]>
This is based on some old version of the driver though. Could you please
rebase it so that it applies on top of for-next branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
and resend? (actually rebasing on Linus' current tree would be absolutely
sufficient).
Thanks.
--
Jiri Kosina
SUSE Labs
On Thu, Apr 4, 2013 at 9:47 AM, Jiri Kosina <[email protected]> wrote:
> On Wed, 3 Apr 2013, Huzefa Kankroliwala wrote:
>
>> 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 <[email protected]>
>> Reviewed-by: Benjamin Tissoires <[email protected]>
>> Signed-off-by: Huzefa Kankroliwala <[email protected]>
>
> This is based on some old version of the driver though. Could you please
> rebase it so that it applies on top of for-next branch of
>
> git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
>
> and resend? (actually rebasing on Linus' current tree would be absolutely
> sufficient).
Actually, the patch goes smoothly on your for-next branch on my computer...
And there is no point rebasing it on top of Linus' tree as the
i2c_hid_request() callback is scheduled for 3.10.
Could you double check Jiri?
Thanks,
Benjamin
>
> Thanks.
>
> --
> Jiri Kosina
> SUSE Labs
On Thu, 4 Apr 2013, Benjamin Tissoires wrote:
> >> 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 <[email protected]>
> >> Reviewed-by: Benjamin Tissoires <[email protected]>
> >> Signed-off-by: Huzefa Kankroliwala <[email protected]>
> >
> > This is based on some old version of the driver though. Could you please
> > rebase it so that it applies on top of for-next branch of
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
> >
> > and resend? (actually rebasing on Linus' current tree would be absolutely
> > sufficient).
>
> Actually, the patch goes smoothly on your for-next branch on my computer...
> And there is no point rebasing it on top of Linus' tree as the
> i2c_hid_request() callback is scheduled for 3.10.
>
> Could you double check Jiri?
Apologies, that was an error on my side, I have forgotten about the
i2c_hid_request()-related refactoring that is queued.
I will review and apply the patch shortly, thanks.
--
Jiri Kosina
SUSE Labs