diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2015-02-19 18:35:25 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-02-23 09:19:49 -0500 |
commit | 6adc83fca74ab73abcbd3b394cf3a8fd3701db99 (patch) | |
tree | 57cd3f15e4b469ddf6ccb177edd473a80d1658cb /drivers/hid | |
parent | b3f4737d00de317d1549d5cb5b1dad90e19f5cec (diff) |
HID: hid-sensor-hub: Enhance get feature report API
Some hid sensor feature report can contain more than one reports.
This API can now support receiving multiple values from the feature
report.
Also update the parameters in the users of this API.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-sensor-hub.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 0a9162363164..c025c489270d 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
@@ -223,10 +223,11 @@ done_proc: | |||
223 | EXPORT_SYMBOL_GPL(sensor_hub_set_feature); | 223 | EXPORT_SYMBOL_GPL(sensor_hub_set_feature); |
224 | 224 | ||
225 | int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | 225 | int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, |
226 | u32 field_index, s32 *value) | 226 | u32 field_index, int buffer_size, void *buffer) |
227 | { | 227 | { |
228 | struct hid_report *report; | 228 | struct hid_report *report; |
229 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); | 229 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); |
230 | int report_size; | ||
230 | int ret = 0; | 231 | int ret = 0; |
231 | 232 | ||
232 | mutex_lock(&data->mutex); | 233 | mutex_lock(&data->mutex); |
@@ -238,7 +239,17 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | |||
238 | } | 239 | } |
239 | hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT); | 240 | hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT); |
240 | hid_hw_wait(hsdev->hdev); | 241 | hid_hw_wait(hsdev->hdev); |
241 | *value = report->field[field_index]->value[0]; | 242 | |
243 | /* calculate number of bytes required to read this field */ | ||
244 | report_size = DIV_ROUND_UP(report->field[field_index]->report_size, | ||
245 | 8) * | ||
246 | report->field[field_index]->report_count; | ||
247 | if (!report_size) { | ||
248 | ret = -EINVAL; | ||
249 | goto done_proc; | ||
250 | } | ||
251 | ret = min(report_size, buffer_size); | ||
252 | memcpy(buffer, report->field[field_index]->value, ret); | ||
242 | 253 | ||
243 | done_proc: | 254 | done_proc: |
244 | mutex_unlock(&data->mutex); | 255 | mutex_unlock(&data->mutex); |