aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/hid/hid-sensor-hub.c22
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-attributes.c11
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c9
3 files changed, 30 insertions, 12 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
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index e1435e98636d..e81f434760f4 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -212,9 +212,8 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
212 else 212 else
213 value = 0; 213 value = 0;
214 } 214 }
215 ret = sensor_hub_set_feature(st->hsdev, 215 ret = sensor_hub_set_feature(st->hsdev, st->poll.report_id,
216 st->poll.report_id, 216 st->poll.index, sizeof(value), &value);
217 st->poll.index, value);
218 if (ret < 0 || value < 0) 217 if (ret < 0 || value < 0)
219 ret = -EINVAL; 218 ret = -EINVAL;
220 219
@@ -254,9 +253,9 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
254 value = convert_to_vtf_format(st->sensitivity.size, 253 value = convert_to_vtf_format(st->sensitivity.size,
255 st->sensitivity.unit_expo, 254 st->sensitivity.unit_expo,
256 val1, val2); 255 val1, val2);
257 ret = sensor_hub_set_feature(st->hsdev, 256 ret = sensor_hub_set_feature(st->hsdev, st->sensitivity.report_id,
258 st->sensitivity.report_id, 257 st->sensitivity.index, sizeof(value),
259 st->sensitivity.index, value); 258 &value);
260 if (ret < 0 || value < 0) 259 if (ret < 0 || value < 0)
261 ret = -EINVAL; 260 ret = -EINVAL;
262 261
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index ef0c495a8ef9..910e82a7d06e 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -64,15 +64,16 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
64 if (state_val >= 0) { 64 if (state_val >= 0) {
65 state_val += st->power_state.logical_minimum; 65 state_val += st->power_state.logical_minimum;
66 sensor_hub_set_feature(st->hsdev, st->power_state.report_id, 66 sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
67 st->power_state.index, 67 st->power_state.index, sizeof(state_val),
68 (s32)state_val); 68 &state_val);
69 } 69 }
70 70
71 if (report_val >= 0) { 71 if (report_val >= 0) {
72 report_val += st->report_state.logical_minimum; 72 report_val += st->report_state.logical_minimum;
73 sensor_hub_set_feature(st->hsdev, st->report_state.report_id, 73 sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
74 st->report_state.index, 74 st->report_state.index,
75 (s32)report_val); 75 sizeof(report_val),
76 &report_val);
76 } 77 }
77 78
78 sensor_hub_get_feature(st->hsdev, st->power_state.report_id, 79 sensor_hub_get_feature(st->hsdev, st->power_state.report_id,