From: Jiri Kosina Date: Mon, 13 Apr 2015 21:43:34 +0000 (+0200) Subject: Merge branch 'for-4.1/sensor-hub' into for-linus X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2e455c27bddbf8cf6d1039daea40de8e6865c453;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git Merge branch 'for-4.1/sensor-hub' into for-linus Conflicts: drivers/iio/common/hid-sensors/hid-sensor-trigger.c include/linux/hid-sensor-hub.h --- 2e455c27bddbf8cf6d1039daea40de8e6865c453 diff --cc drivers/hid/hid-sensor-hub.c index e54ce1097e2c,ecdcb5ac91f9..c3f6f1e311ea --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@@ -135,11 -116,11 +116,12 @@@ static struct hid_sensor_hub_callbacks { struct hid_sensor_hub_callbacks_list *callback; struct sensor_hub_data *pdata = hid_get_drvdata(hdev); + unsigned long flags; - spin_lock(&pdata->dyn_callback_lock); + spin_lock_irqsave(&pdata->dyn_callback_lock, flags); list_for_each_entry(callback, &pdata->dyn_callback_list, list) - if (callback->usage_id == usage_id && + if ((callback->usage_id == usage_id || + callback->usage_id == HID_USAGE_SENSOR_COLLECTION) && (collection_index >= callback->hsdev->start_collection_index) && (collection_index < diff --cc drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 2f1d535b94c4,910e82a7d06e..610fc98f88ef --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@@ -80,11 -77,8 +81,11 @@@ static int _hid_sensor_power_state(stru } sensor_hub_get_feature(st->hsdev, st->power_state.report_id, - st->power_state.index, - &state_val); + st->power_state.index, + sizeof(state_val), &state_val); + if (state && poll_value) + msleep_interruptible(poll_value * 2); + return 0; } EXPORT_SYMBOL(hid_sensor_power_state); diff --cc include/linux/hid-sensor-hub.h index 4173a8fdad9e,4a2fdbabfcf1..0408421d885f --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@@ -152,21 -173,29 +176,30 @@@ int sensor_hub_input_get_attribute_info * @usage_id: Attribute usage id of parent physical device as per spec * @attr_usage_id: Attribute usage id as per spec * @report_id: Report id to look for + * @flag: Synchronous or asynchronous read * - * Issues a synchronous read request for an input attribute. Returns - * data upto 32 bits. Since client can get events, so this call should - * not be used for data paths, this will impact performance. + * Issues a synchronous or asynchronous read request for an input attribute. + * Returns data upto 32 bits. */ + enum sensor_hub_read_flags { + SENSOR_HUB_SYNC, + SENSOR_HUB_ASYNC, + }; + int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, - u32 usage_id, - u32 attr_usage_id, u32 report_id); + u32 usage_id, + u32 attr_usage_id, u32 report_id, + enum sensor_hub_read_flags flag + ); + /** * sensor_hub_set_feature() - Feature set request +* @hsdev: Hub device instance. * @report_id: Report id to look for * @field_index: Field index inside a report - * @value: Value to set + * @buffer_size: size of the buffer + * @buffer: buffer to use in the feature set * * Used to set a field in feature report. For example this can set polling * interval, sensitivity, activate/deactivate state. @@@ -176,16 -205,17 +209,18 @@@ int sensor_hub_set_feature(struct hid_s /** * sensor_hub_get_feature() - Feature get request +* @hsdev: Hub device instance. * @report_id: Report id to look for * @field_index: Field index inside a report - * @value: Place holder for return value + * @buffer_size: size of the buffer + * @buffer: buffer to copy output * * Used to get a field in feature report. For example this can get polling - * interval, sensitivity, activate/deactivate state. + * interval, sensitivity, activate/deactivate state. On success it returns + * number of bytes copied to buffer. On failure, it returns value < 0. */ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, - u32 field_index, s32 *value); + u32 field_index, int buffer_size, void *buffer); /* hid-sensor-attributes */