aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2015-02-19 18:35:26 -0500
committerJiri Kosina <jkosina@suse.cz>2015-02-23 09:20:00 -0500
commit3950e03389cfc8ee9d7131074d999b5fb6bbc2bf (patch)
treebbf036b38751363eb8d6c6c8f27225d49a5f6750 /drivers/hid
parent6adc83fca74ab73abcbd3b394cf3a8fd3701db99 (diff)
HID: hid-sensor-hub: Enhance feature report set API
Current API only allows setting one offset in the field. This API is extended to set multiple offsets in the field report. Also update parameters in the users of this API. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-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.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index c025c489270d..44da796fa4fd 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -199,10 +199,14 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
199EXPORT_SYMBOL_GPL(sensor_hub_remove_callback); 199EXPORT_SYMBOL_GPL(sensor_hub_remove_callback);
200 200
201int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, 201int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
202 u32 field_index, s32 value) 202 u32 field_index, int buffer_size, void *buffer)
203{ 203{
204 struct hid_report *report; 204 struct hid_report *report;
205 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); 205 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
206 __s32 *buf32 = buffer;
207 int i = 0;
208 int remaining_bytes;
209 __s32 value;
206 int ret = 0; 210 int ret = 0;
207 211
208 mutex_lock(&data->mutex); 212 mutex_lock(&data->mutex);
@@ -211,7 +215,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
211 ret = -EINVAL; 215 ret = -EINVAL;
212 goto done_proc; 216 goto done_proc;
213 } 217 }
214 hid_set_field(report->field[field_index], 0, value); 218
219 remaining_bytes = do_div(buffer_size, sizeof(__s32));
220 if (buffer_size) {
221 for (i = 0; i < buffer_size; ++i) {
222 hid_set_field(report->field[field_index], i,
223 cpu_to_le32(*buf32));
224 ++buf32;
225 }
226 }
227 if (remaining_bytes) {
228 value = 0;
229 memcpy(&value, (u8 *)buf32, remaining_bytes);
230 hid_set_field(report->field[field_index], i,
231 cpu_to_le32(value));
232 }
215 hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT); 233 hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
216 hid_hw_wait(hsdev->hdev); 234 hid_hw_wait(hsdev->hdev);
217 235