aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/hid-sensor-hub.c22
-rw-r--r--include/linux/hid-sensor-hub.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 46f4480035bc..ad2b8692ad77 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -291,6 +291,28 @@ err_free:
291} 291}
292EXPORT_SYMBOL_GPL(sensor_hub_input_attr_get_raw_value); 292EXPORT_SYMBOL_GPL(sensor_hub_input_attr_get_raw_value);
293 293
294int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev,
295 u32 report_id, int field_index, u32 usage_id)
296{
297 struct hid_report *report;
298 struct hid_field *field;
299 int i;
300
301 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
302 if (!report || (field_index >= report->maxfield))
303 goto done_proc;
304
305 field = report->field[field_index];
306 for (i = 0; i < field->maxusage; ++i) {
307 if (field->usage[i].hid == usage_id)
308 return field->usage[i].usage_index;
309 }
310
311done_proc:
312 return -EINVAL;
313}
314EXPORT_SYMBOL_GPL(hid_sensor_get_usage_index);
315
294int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, 316int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
295 u8 type, 317 u8 type,
296 u32 usage_id, 318 u32 usage_id,
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index b914ca3f57ba..205eba0326af 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -218,4 +218,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
218int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, 218int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
219 int *val1, int *val2); 219 int *val1, int *val2);
220 220
221int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev,
222 u32 report_id, int field_index, u32 usage_id);
223
221#endif 224#endif