* [PATCH] HID: hid-sensor-hub: fix report size
@ 2013-10-18 16:48 Srinivas Pandruvada
2013-10-25 9:01 ` Jiri Kosina
0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2013-10-18 16:48 UTC (permalink / raw)
To: jkosina; +Cc: linux-input, Srinivas Pandruvada
The number of bytes in a field needs to take account of report_count
field. Need to multiply report_size and report_count to get total
number of bytes.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 88fc5ae..a184e19 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -326,7 +326,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
field->logical == attr_usage_id) {
sensor_hub_fill_attr_info(info, i, report->id,
field->unit, field->unit_exponent,
- field->report_size);
+ field->report_size *
+ field->report_count);
ret = 0;
} else {
for (j = 0; j < field->maxusage; ++j) {
@@ -338,7 +339,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
i, report->id,
field->unit,
field->unit_exponent,
- field->report_size);
+ field->report_size *
+ field->report_count);
ret = 0;
break;
}
@@ -425,9 +427,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n",
i, report->field[i]->usage->collection_index,
report->field[i]->usage->hid,
- report->field[i]->report_size/8);
-
- sz = report->field[i]->report_size/8;
+ (report->field[i]->report_size *
+ report->field[i]->report_count)/8);
+ sz = (report->field[i]->report_size *
+ report->field[i]->report_count)/8;
if (pdata->pending.status && pdata->pending.attr_usage_id ==
report->field[i]->usage->hid) {
hid_dbg(hdev, "data was pending ...\n");
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] HID: hid-sensor-hub: fix report size
2013-10-18 16:48 [PATCH] HID: hid-sensor-hub: fix report size Srinivas Pandruvada
@ 2013-10-25 9:01 ` Jiri Kosina
0 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2013-10-25 9:01 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-input
On Fri, 18 Oct 2013, Srinivas Pandruvada wrote:
> The number of bytes in a field needs to take account of report_count
> field. Need to multiply report_size and report_count to get total
> number of bytes.
Srinivas,
could you please elaborate a little bit more in the changelog what
user-visible bug this is fixing? Thanks.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> drivers/hid/hid-sensor-hub.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 88fc5ae..a184e19 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -326,7 +326,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
> field->logical == attr_usage_id) {
> sensor_hub_fill_attr_info(info, i, report->id,
> field->unit, field->unit_exponent,
> - field->report_size);
> + field->report_size *
> + field->report_count);
> ret = 0;
> } else {
> for (j = 0; j < field->maxusage; ++j) {
> @@ -338,7 +339,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
> i, report->id,
> field->unit,
> field->unit_exponent,
> - field->report_size);
> + field->report_size *
> + field->report_count);
> ret = 0;
> break;
> }
> @@ -425,9 +427,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
> hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n",
> i, report->field[i]->usage->collection_index,
> report->field[i]->usage->hid,
> - report->field[i]->report_size/8);
> -
> - sz = report->field[i]->report_size/8;
> + (report->field[i]->report_size *
> + report->field[i]->report_count)/8);
> + sz = (report->field[i]->report_size *
> + report->field[i]->report_count)/8;
> if (pdata->pending.status && pdata->pending.attr_usage_id ==
> report->field[i]->usage->hid) {
> hid_dbg(hdev, "data was pending ...\n");
> --
> 1.8.3.2
>
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] HID: hid-sensor-hub: fix report size
@ 2013-10-26 17:04 Srinivas Pandruvada
2013-10-30 13:27 ` Jiri Kosina
0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2013-10-26 17:04 UTC (permalink / raw)
To: jkosina; +Cc: linux-input, Srinivas Pandruvada
Most of the hid sensor field size is reported in report_size field
in the report descriptor. For rotation fusion sensor the quaternion
data is 16 byte field, the report size was set to 4 and report
count field is set to 4. So the total size is 16 bytes. But the current
driver has a bug and not taking account for report count field. This
causes user space to see only 4 bytes of data sent via IIO interface.
The number of bytes in a field needs to take account of report_count
field. Need to multiply report_size and report_count to get total
number of bytes.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 88fc5ae..a184e19 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -326,7 +326,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
field->logical == attr_usage_id) {
sensor_hub_fill_attr_info(info, i, report->id,
field->unit, field->unit_exponent,
- field->report_size);
+ field->report_size *
+ field->report_count);
ret = 0;
} else {
for (j = 0; j < field->maxusage; ++j) {
@@ -338,7 +339,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
i, report->id,
field->unit,
field->unit_exponent,
- field->report_size);
+ field->report_size *
+ field->report_count);
ret = 0;
break;
}
@@ -425,9 +427,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n",
i, report->field[i]->usage->collection_index,
report->field[i]->usage->hid,
- report->field[i]->report_size/8);
-
- sz = report->field[i]->report_size/8;
+ (report->field[i]->report_size *
+ report->field[i]->report_count)/8);
+ sz = (report->field[i]->report_size *
+ report->field[i]->report_count)/8;
if (pdata->pending.status && pdata->pending.attr_usage_id ==
report->field[i]->usage->hid) {
hid_dbg(hdev, "data was pending ...\n");
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] HID: hid-sensor-hub: fix report size
2013-10-26 17:04 Srinivas Pandruvada
@ 2013-10-30 13:27 ` Jiri Kosina
0 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2013-10-30 13:27 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-input
On Sat, 26 Oct 2013, Srinivas Pandruvada wrote:
> Most of the hid sensor field size is reported in report_size field
> in the report descriptor. For rotation fusion sensor the quaternion
> data is 16 byte field, the report size was set to 4 and report
> count field is set to 4. So the total size is 16 bytes. But the current
> driver has a bug and not taking account for report count field. This
> causes user space to see only 4 bytes of data sent via IIO interface.
> The number of bytes in a field needs to take account of report_count
> field. Need to multiply report_size and report_count to get total
> number of bytes.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Thanks, applied.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-30 13:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-18 16:48 [PATCH] HID: hid-sensor-hub: fix report size Srinivas Pandruvada
2013-10-25 9:01 ` Jiri Kosina
-- strict thread matches above, loose matches on Subject: below --
2013-10-26 17:04 Srinivas Pandruvada
2013-10-30 13:27 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).