Skip to content

Commit

Permalink
HID: hid-sensor-hub: Add logical min and max
Browse files Browse the repository at this point in the history
Exporting logical minimum and maximum of HID fields as part of the
hid sensor attribute info. This can be used for range checking and
to calculate enumeration base for NAry fields of HID sensor hub.

Signed-off-by: Srinivas Pandruvada <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
spandruvada authored and jic23 committed Dec 2, 2013
1 parent 930ba4a commit 9f740ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 8 additions & 12 deletions drivers/hid/hid-sensor-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ static int sensor_hub_get_physical_device_count(

static void sensor_hub_fill_attr_info(
struct hid_sensor_hub_attribute_info *info,
s32 index, s32 report_id, s32 units, s32 unit_expo, s32 size)
s32 index, s32 report_id, struct hid_field *field)
{
info->index = index;
info->report_id = report_id;
info->units = units;
info->unit_expo = unit_expo;
info->size = size/8;
info->units = field->unit;
info->unit_expo = field->unit_exponent;
info->size = (field->report_size * field->report_count)/8;
info->logical_minimum = field->logical_minimum;
info->logical_maximum = field->logical_maximum;
}

static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
Expand Down Expand Up @@ -325,9 +327,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
if (field->physical == usage_id &&
field->logical == attr_usage_id) {
sensor_hub_fill_attr_info(info, i, report->id,
field->unit, field->unit_exponent,
field->report_size *
field->report_count);
field);
ret = 0;
} else {
for (j = 0; j < field->maxusage; ++j) {
Expand All @@ -336,11 +336,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
field->usage[j].collection_index ==
collection_index) {
sensor_hub_fill_attr_info(info,
i, report->id,
field->unit,
field->unit_exponent,
field->report_size *
field->report_count);
i, report->id, field);
ret = 0;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/hid-sensor-hub.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct hid_sensor_hub_attribute_info {
s32 units;
s32 unit_expo;
s32 size;
s32 logical_minimum;
s32 logical_maximum;
};

/**
Expand Down

0 comments on commit 9f740ff

Please sign in to comment.