* [PATCH] HID: sensor-hub: correct dyn_callback_lock IRQ-safe change
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 1/4] HID: hid-sensor-hub: Enhance feature report API Srinivas Pandruvada
` (16 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Commit 0ccf091d1fbc1f99bb7f93bff8cf346769a9b0cd ("HID: sensor-hub:
make dyn_callback_lock IRQ-safe) was supposed to change locks
in sensor_hub_get_callback(), but missed.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6a58b6c..e54ce10 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -135,8 +135,9 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
{
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 &&
(collection_index >=
@@ -145,10 +146,11 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
callback->hsdev->end_collection_index)) {
*priv = callback->priv;
*hsdev = callback->hsdev;
- spin_unlock(&pdata->dyn_callback_lock);
+ spin_unlock_irqrestore(&pdata->dyn_callback_lock,
+ flags);
return callback->usage_callback;
}
- spin_unlock(&pdata->dyn_callback_lock);
+ spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
return NULL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/4] HID: hid-sensor-hub: Enhance feature report API
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH] HID: sensor-hub: correct dyn_callback_lock IRQ-safe change Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 3/4] HID: hid-sensor-hub: Enhance feature report set API Srinivas Pandruvada
` (15 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Some hid sensor feature report can contain more than one reports.
This API can now support receiving multiple values from the feature
report.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 16 ++++++++++++++--
include/linux/hid-sensor-hub.h | 8 +++++---
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index e54ce10..0ad5813 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -232,10 +232,11 @@ done_proc:
EXPORT_SYMBOL_GPL(sensor_hub_set_feature);
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)
{
struct hid_report *report;
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
+ int report_size;
int ret = 0;
mutex_lock(&data->mutex);
@@ -247,7 +248,18 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
}
hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
hid_hw_wait(hsdev->hdev);
- *value = report->field[field_index]->value[0];
+
+ /* calculate number of bytes required to read this field */
+ report_size = report->field[field_index]->report_size / 8;
+ if (report->field[field_index]->report_size % 8)
+ ++report_size;
+ report_size *= report->field[field_index]->report_count;
+ if (!report_size) {
+ ret = -EINVAL;
+ goto done_proc;
+ }
+ ret = min(report_size, buffer_size);
+ memcpy(buffer, report->field[field_index]->value, ret);
done_proc:
mutex_unlock(&data->mutex);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 4173a8f..dfdf6ef 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -179,13 +179,15 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
* @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 */
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/4] HID: hid-sensor-hub: Enhance feature report set API
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH] HID: sensor-hub: correct dyn_callback_lock IRQ-safe change Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 1/4] HID: hid-sensor-hub: Enhance feature report API Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 4/4] iio: hid_sensor_hub: update parameters to set feature report Srinivas Pandruvada
` (14 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Current API only allows setting one offset in the field. This API
is extended to set multiple offsets in the field report.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 22 ++++++++++++++++++++--
include/linux/hid-sensor-hub.h | 5 +++--
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 0ad5813..8e77e93c 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -208,10 +208,14 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
EXPORT_SYMBOL_GPL(sensor_hub_remove_callback);
int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 value)
+ u32 field_index, int buffer_size, void *buffer)
{
struct hid_report *report;
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
+ __s32 *buf32 = (__s32 *)buffer;
+ int i = 0;
+ int remaining_bytes;
+ __s32 value;
int ret = 0;
mutex_lock(&data->mutex);
@@ -220,7 +224,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
ret = -EINVAL;
goto done_proc;
}
- hid_set_field(report->field[field_index], 0, value);
+
+ remaining_bytes = do_div(buffer_size, sizeof(__s32));
+ if (buffer_size) {
+ for (i = 0; i < buffer_size; ++i) {
+ hid_set_field(report->field[field_index], i,
+ cpu_to_le32(*buf32));
+ ++buf32;
+ }
+ }
+ if (remaining_bytes) {
+ value = 0;
+ memcpy(&value, (u8 *)buf32, remaining_bytes);
+ hid_set_field(report->field[field_index], i,
+ cpu_to_le32(value));
+ }
hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
hid_hw_wait(hsdev->hdev);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index dfdf6ef..e899c67 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -166,13 +166,14 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
* @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.
*/
int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
- u32 field_index, s32 value);
+ u32 field_index, int buffer_size, void *buffer);
/**
* sensor_hub_get_feature() - Feature get request
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/4] iio: hid_sensor_hub: update parameters to set feature report
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (2 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 3/4] HID: hid-sensor-hub: Enhance feature report set API Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (13 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
The new sensor_hub_set_feature can set multiple values, this
resulted in the change in API. Update the API usage here.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 11 +++++------
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 9 +++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index e1435e9..e81f434 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,
else
value = 0;
}
- ret = sensor_hub_set_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, value);
+ ret = sensor_hub_set_feature(st->hsdev, st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0)
ret = -EINVAL;
@@ -254,9 +253,9 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
value = convert_to_vtf_format(st->sensitivity.size,
st->sensitivity.unit_expo,
val1, val2);
- ret = sensor_hub_set_feature(st->hsdev,
- st->sensitivity.report_id,
- st->sensitivity.index, value);
+ ret = sensor_hub_set_feature(st->hsdev, st->sensitivity.report_id,
+ st->sensitivity.index, sizeof(value),
+ &value);
if (ret < 0 || value < 0)
ret = -EINVAL;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index ef0c495..910e82a 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)
if (state_val >= 0) {
state_val += st->power_state.logical_minimum;
sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
- st->power_state.index,
- (s32)state_val);
+ st->power_state.index, sizeof(state_val),
+ &state_val);
}
if (report_val >= 0) {
report_val += st->report_state.logical_minimum;
sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
- st->report_state.index,
- (s32)report_val);
+ st->report_state.index,
+ sizeof(report_val),
+ &report_val);
}
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
[parent not found: <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>]
* [PATCH 2/4] iio: hid_sensor_hub: update parameters to get feature report
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH] HID: hid-sensor-hub: Allow parallel synchronous reads Srinivas Pandruvada
` (6 subsequent siblings)
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new sensor_hub_get_feature can return multiple values, this
resulted in the change in API. Update the API usage here.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 13 +++++++------
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 4 ++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 25b01e1..e1435e9 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -153,8 +153,8 @@ s32 hid_sensor_read_poll_value(struct hid_sensor_common *st)
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, &value);
+ st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0) {
return -EINVAL;
@@ -174,8 +174,8 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->poll.report_id,
- st->poll.index, &value);
+ st->poll.report_id,
+ st->poll.index, sizeof(value), &value);
if (ret < 0 || value < 0) {
*val1 = *val2 = 0;
return -EINVAL;
@@ -229,8 +229,9 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
int ret;
ret = sensor_hub_get_feature(st->hsdev,
- st->sensitivity.report_id,
- st->sensitivity.index, &value);
+ st->sensitivity.report_id,
+ st->sensitivity.index, sizeof(value),
+ &value);
if (ret < 0 || value < 0) {
*val1 = *val2 = 0;
return -EINVAL;
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 92068cd..ef0c495 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -76,8 +76,8 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
}
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);
return 0;
}
EXPORT_SYMBOL(hid_sensor_power_state);
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH] HID: hid-sensor-hub: Allow parallel synchronous reads
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-01-07 0:58 ` [PATCH 2/4] iio: hid_sensor_hub: update parameters to get " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read Srinivas Pandruvada
` (5 subsequent siblings)
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
Current implementation only allows one outstanding synchronous read.
This is a performance hit when user mode is requesting raw reads
of sensor attributes on multiple sensors together.
This change changes the mutex lock to per hid sensor hub device instead
of global lock. Although request to hid sensor hub is serialized, there
can be multiple outstanding read requests pending for responses via
hid reports.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/hid/hid-sensor-hub.c | 90 +++++++++++++++++++-----------------------
include/linux/hid-sensor-hub.h | 24 +++++++++++
2 files changed, 65 insertions(+), 49 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 8e77e93c..8d177f0 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -29,29 +29,10 @@
#define HID_SENSOR_HUB_ENUM_QUIRK 0x01
/**
- * struct sensor_hub_pending - Synchronous read pending information
- * @status: Pending status true/false.
- * @ready: Completion synchronization data.
- * @usage_id: Usage id for physical device, E.g. Gyro usage id.
- * @attr_usage_id: Usage Id of a field, E.g. X-AXIS for a gyro.
- * @raw_size: Response size for a read request.
- * @raw_data: Place holder for received response.
- */
-struct sensor_hub_pending {
- bool status;
- struct completion ready;
- u32 usage_id;
- u32 attr_usage_id;
- int raw_size;
- u8 *raw_data;
-};
-
-/**
* struct sensor_hub_data - Hold a instance data for a HID hub device
* @hsdev: Stored hid instance for current hub device.
* @mutex: Mutex to serialize synchronous request.
* @lock: Spin lock to protect pending request structure.
- * @pending: Holds information of pending sync read request.
* @dyn_callback_list: Holds callback function
* @dyn_callback_lock: spin lock to protect callback list
* @hid_sensor_hub_client_devs: Stores all MFD cells for a hub instance.
@@ -61,7 +42,6 @@ struct sensor_hub_pending {
struct sensor_hub_data {
struct mutex mutex;
spinlock_t lock;
- struct sensor_hub_pending pending;
struct list_head dyn_callback_list;
spinlock_t dyn_callback_lock;
struct mfd_cell *hid_sensor_hub_client_devs;
@@ -296,40 +276,42 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
struct hid_report *report;
int ret_val = 0;
- mutex_lock(&data->mutex);
- memset(&data->pending, 0, sizeof(data->pending));
- init_completion(&data->pending.ready);
- data->pending.usage_id = usage_id;
- data->pending.attr_usage_id = attr_usage_id;
- data->pending.raw_size = 0;
+ mutex_lock(&hsdev->mutex);
+ memset(&hsdev->pending, 0, sizeof(hsdev->pending));
+ init_completion(&hsdev->pending.ready);
+ hsdev->pending.usage_id = usage_id;
+ hsdev->pending.attr_usage_id = attr_usage_id;
+ hsdev->pending.raw_size = 0;
spin_lock_irqsave(&data->lock, flags);
- data->pending.status = true;
+ hsdev->pending.status = true;
spin_unlock_irqrestore(&data->lock, flags);
report = sensor_hub_report(report_id, hsdev->hdev, HID_INPUT_REPORT);
if (!report)
goto err_free;
+ mutex_lock(&data->mutex);
hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
- wait_for_completion_interruptible_timeout(&data->pending.ready, HZ*5);
- switch (data->pending.raw_size) {
+ mutex_unlock(&data->mutex);
+ wait_for_completion_interruptible_timeout(&hsdev->pending.ready, HZ*5);
+ switch (hsdev->pending.raw_size) {
case 1:
- ret_val = *(u8 *)data->pending.raw_data;
+ ret_val = *(u8 *)hsdev->pending.raw_data;
break;
case 2:
- ret_val = *(u16 *)data->pending.raw_data;
+ ret_val = *(u16 *)hsdev->pending.raw_data;
break;
case 4:
- ret_val = *(u32 *)data->pending.raw_data;
+ ret_val = *(u32 *)hsdev->pending.raw_data;
break;
default:
ret_val = 0;
}
- kfree(data->pending.raw_data);
+ kfree(hsdev->pending.raw_data);
err_free:
- data->pending.status = false;
- mutex_unlock(&data->mutex);
+ hsdev->pending.status = false;
+ mutex_unlock(&hsdev->mutex);
return ret_val;
}
@@ -485,16 +467,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
report->field[i]->report_count)/8);
sz = (report->field[i]->report_size *
report->field[i]->report_count)/8;
- if (pdata->pending.status && pdata->pending.attr_usage_id ==
- report->field[i]->usage->hid) {
- hid_dbg(hdev, "data was pending ...\n");
- pdata->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
- if (pdata->pending.raw_data)
- pdata->pending.raw_size = sz;
- else
- pdata->pending.raw_size = 0;
- complete(&pdata->pending.ready);
- }
collection = &hdev->collection[
report->field[i]->usage->collection_index];
hid_dbg(hdev, "collection->usage %x\n",
@@ -504,8 +476,21 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
report->field[i]->physical,
report->field[i]->usage[0].collection_index,
&hsdev, &priv);
-
- if (callback && callback->capture_sample) {
+ if (!callback) {
+ ptr += sz;
+ continue;
+ }
+ if (hsdev->pending.status && hsdev->pending.attr_usage_id ==
+ report->field[i]->usage->hid) {
+ hid_dbg(hdev, "data was pending ...\n");
+ hsdev->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
+ if (hsdev->pending.raw_data)
+ hsdev->pending.raw_size = sz;
+ else
+ hsdev->pending.raw_size = 0;
+ complete(&hsdev->pending.ready);
+ }
+ if (callback->capture_sample) {
if (report->field[i]->logical)
callback->capture_sample(hsdev,
report->field[i]->logical, sz, ptr,
@@ -660,6 +645,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
hsdev->hdev = hdev;
hsdev->vendor_id = hdev->vendor;
hsdev->product_id = hdev->product;
+ hsdev->usage = collection->usage;
+ mutex_init(&hsdev->mutex);
hsdev->start_collection_index = i;
if (last_hsdev)
last_hsdev->end_collection_index = i;
@@ -706,13 +693,18 @@ static void sensor_hub_remove(struct hid_device *hdev)
{
struct sensor_hub_data *data = hid_get_drvdata(hdev);
unsigned long flags;
+ int i;
hid_dbg(hdev, " hardware removed\n");
hid_hw_close(hdev);
hid_hw_stop(hdev);
spin_lock_irqsave(&data->lock, flags);
- if (data->pending.status)
- complete(&data->pending.ready);
+ for (i = 0; i < data->hid_sensor_client_cnt; ++i) {
+ struct hid_sensor_hub_device *hsdev =
+ data->hid_sensor_hub_client_devs[i].platform_data;
+ if (hsdev->pending.status)
+ complete(&hsdev->pending.ready);
+ }
spin_unlock_irqrestore(&data->lock, flags);
mfd_remove_devices(&hdev->dev);
hid_set_drvdata(hdev, NULL);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index e899c67..a51c768 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -49,19 +49,43 @@ struct hid_sensor_hub_attribute_info {
};
/**
+ * struct sensor_hub_pending - Synchronous read pending information
+ * @status: Pending status true/false.
+ * @ready: Completion synchronization data.
+ * @usage_id: Usage id for physical device, E.g. Gyro usage id.
+ * @attr_usage_id: Usage Id of a field, E.g. X-AXIS for a gyro.
+ * @raw_size: Response size for a read request.
+ * @raw_data: Place holder for received response.
+ */
+struct sensor_hub_pending {
+ bool status;
+ struct completion ready;
+ u32 usage_id;
+ u32 attr_usage_id;
+ int raw_size;
+ u8 *raw_data;
+};
+
+/**
* struct hid_sensor_hub_device - Stores the hub instance data
* @hdev: Stores the hid instance.
* @vendor_id: Vendor id of hub device.
* @product_id: Product id of hub device.
+ * @usage: Usage id for this hub device instance.
* @start_collection_index: Starting index for a phy type collection
* @end_collection_index: Last index for a phy type collection
+ * @mutex: synchronizing mutex.
+ * @pending: Holds information of pending sync read request.
*/
struct hid_sensor_hub_device {
struct hid_device *hdev;
u32 vendor_id;
u32 product_id;
+ u32 usage;
int start_collection_index;
int end_collection_index;
+ struct mutex mutex;
+ struct sensor_hub_pending pending;
};
/**
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-01-07 0:58 ` [PATCH 2/4] iio: hid_sensor_hub: update parameters to get " Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH] HID: hid-sensor-hub: Allow parallel synchronous reads Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 3/9] iio: hid-sensor-gyro-3d: " Srinivas Pandruvada
` (4 subsequent siblings)
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index d5d9531..0085c2f 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -130,7 +130,8 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
accel_state->common_attributes.hsdev,
HID_USAGE_SENSOR_ACCEL_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&accel_state->common_attributes,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/9] iio: hid-sensor-gyro-3d: Adjust parameter for attribute read
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (2 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 4/9] iio: hid-sensor-als: " Srinivas Pandruvada
` (3 subsequent siblings)
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index a3ea1e8..bdcd105 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -130,7 +130,8 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
gyro_state->common_attributes.hsdev,
HID_USAGE_SENSOR_GYRO_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&gyro_state->common_attributes,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/9] iio: hid-sensor-als: Adjust parameter for attribute read
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (3 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 3/9] iio: hid-sensor-gyro-3d: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 6/9] iio: hid-sensor-magn-3d: " Srinivas Pandruvada
` (2 subsequent siblings)
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/light/hid-sensor-als.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index a5283d7..321862d 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -109,7 +109,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
als_state->common_attributes.hsdev,
HID_USAGE_SENSOR_ALS, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&als_state->common_attributes,
false);
} else {
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/9] iio: hid-sensor-magn-3d: Adjust parameter for attribute read
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (4 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 4/9] iio: hid-sensor-als: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 7/9] iio: hid-sensor-incl-3d: " Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 2/8] iio: hid-sensor-accel-3d: Introduce PM Srinivas Pandruvada
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 6294575..4d299f3 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -178,7 +178,8 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
magn_state->common_attributes.hsdev,
HID_USAGE_SENSOR_COMPASS_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
*val = 0;
hid_sensor_power_state(&magn_state->common_attributes,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 7/9] iio: hid-sensor-incl-3d: Adjust parameter for attribute read
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (5 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 6/9] iio: hid-sensor-magn-3d: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 2/8] iio: hid-sensor-accel-3d: Introduce PM Srinivas Pandruvada
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/orientation/hid-sensor-incl-3d.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 1ff181b..45bed08 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -132,7 +132,8 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
incl_state->common_attributes.hsdev,
HID_USAGE_SENSOR_INCLINOMETER_3D, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
else {
hid_sensor_power_state(&incl_state->common_attributes,
false);
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/8] iio: hid-sensor-accel-3d: Introduce PM
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
` (6 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 7/9] iio: hid-sensor-incl-3d: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
7 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina-AlSwsSmVLrQ, jic23-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/iio/accel/hid-sensor-accel-3d.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 0085c2f..2b4fad6 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -111,19 +111,12 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
- poll_value = hid_sensor_read_poll_value(
- &accel_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&accel_state->common_attributes, true);
- msleep_interruptible(poll_value * 2);
report_id = accel_state->accel[chan->scan_index].report_id;
address = accel_3d_addresses[chan->scan_index];
if (report_id >= 0)
@@ -420,6 +413,7 @@ static struct platform_driver hid_accel_3d_platform_driver = {
.id_table = hid_accel_3d_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_accel_3d_probe,
.remove = hid_accel_3d_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (4 preceding siblings ...)
[not found] ` <1420592328-9942-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 5/9] iio: hid-sensor-prox: Adjust parameter for attribute read Srinivas Pandruvada
` (11 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Add additional flag to read in async mode. In this mode the caller
need to register for events and match attribute usage id for result.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 15 ++++++++++++++-
include/linux/hid-sensor-hub.h | 19 +++++++++++++------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 8d177f0..84290e5 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -269,13 +269,26 @@ EXPORT_SYMBOL_GPL(sensor_hub_get_feature);
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 attr_usage_id, u32 report_id,
+ enum sensor_hub_read_flags flag)
{
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
unsigned long flags;
struct hid_report *report;
int ret_val = 0;
+ if (flag == SENSOR_HUB_ASYNC) {
+ report = sensor_hub_report(report_id, hsdev->hdev,
+ HID_INPUT_REPORT);
+ if (!report)
+ return -EINVAL;
+
+ mutex_lock(&data->mutex);
+ hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
+ mutex_unlock(&data->mutex);
+ return 0;
+ }
+
mutex_lock(&hsdev->mutex);
memset(&hsdev->pending, 0, sizeof(hsdev->pending));
init_completion(&hsdev->pending.ready);
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index a51c768..d48e91f 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -171,20 +171,27 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
struct hid_sensor_hub_attribute_info *info);
/**
-* sensor_hub_input_attr_get_raw_value() - Synchronous read request
+* sensor_hub_input_attr_get_raw_value() - Attribute read request
* @hsdev: Hub device instance.
* @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: Synchronour 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.
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/9] iio: hid-sensor-prox: Adjust parameter for attribute read
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (5 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 8/9] iio: hid-sensor-press: " Srinivas Pandruvada
` (10 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/light/hid-sensor-prox.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index f5a5146..db9c60e 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -105,7 +105,8 @@ static int prox_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
prox_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PROX, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&prox_state->common_attributes,
false);
} else {
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 8/9] iio: hid-sensor-press: Adjust parameter for attribute read
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (6 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 5/9] iio: hid-sensor-prox: Adjust parameter for attribute read Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: " Srinivas Pandruvada
` (9 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/pressure/hid-sensor-press.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 7649286..ac150f0 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -108,7 +108,8 @@ static int press_read_raw(struct iio_dev *indio_dev,
*val = sensor_hub_input_attr_get_raw_value(
press_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PRESSURE, address,
- report_id);
+ report_id,
+ SENSOR_HUB_SYNC);
hid_sensor_power_state(&press_state->common_attributes,
false);
} else {
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: Adjust parameter for attribute read
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (7 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 8/9] iio: hid-sensor-press: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 1/8] iio: hid_sensor_hub: Common PM functions Srinivas Pandruvada
` (8 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
The new API added a flag for sync/async mode. Added sync mode flag.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/rtc/rtc-hid-sensor-time.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c
index ae7c2ba..af4f85a 100644
--- a/drivers/rtc/rtc-hid-sensor-time.c
+++ b/drivers/rtc/rtc-hid-sensor-time.c
@@ -213,7 +213,7 @@ static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* get a report with all values through requesting one value */
sensor_hub_input_attr_get_raw_value(time_state->common_attributes.hsdev,
HID_USAGE_SENSOR_TIME, hid_time_addresses[0],
- time_state->info[0].report_id);
+ time_state->info[0].report_id, SENSOR_HUB_SYNC);
/* wait for all values (event) */
ret = wait_for_completion_killable_timeout(
&time_state->comp_last_time, HZ*6);
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/8] iio: hid_sensor_hub: Common PM functions
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (8 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 3/8] iio: hid-sensor-gyro-3d: Introduce PM Srinivas Pandruvada
` (7 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
To improvement power and performance, both regular and run time callbacks
are introduced. Because of auto suspend delay, two consecutive read
don't have to go through full power on/off procedure. The auto suspend
time can be adjusted using regular power attributes of PM sysfs.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../iio/common/hid-sensors/hid-sensor-trigger.c | 76 +++++++++++++++++++++-
.../iio/common/hid-sensors/hid-sensor-trigger.h | 5 ++
2 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 910e82a..d128070 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -22,16 +22,18 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/slab.h>
+#include <linux/delay.h>
#include <linux/hid-sensor-hub.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include <linux/iio/sysfs.h>
#include "hid-sensor-trigger.h"
-int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
+static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
{
int state_val;
int report_val;
+ s32 poll_value = 0;
if (state) {
if (sensor_hub_device_open(st->hsdev))
@@ -47,6 +49,8 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
st->report_state.report_id,
st->report_state.index,
HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
+
+ poll_value = hid_sensor_read_poll_value(st);
} else {
if (!atomic_dec_and_test(&st->data_ready))
return 0;
@@ -79,7 +83,34 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
st->power_state.index,
sizeof(state_val), &state_val);
+
+ if (state && poll_value)
+ msleep_interruptible(poll_value * 2);
+
+ return 0;
+}
+
+int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
+{
+#ifdef CONFIG_PM
+ int ret;
+
+ if (state)
+ ret = pm_runtime_get_sync(&st->pdev->dev);
+ else {
+ pm_runtime_mark_last_busy(&st->pdev->dev);
+ ret = pm_runtime_put_autosuspend(&st->pdev->dev);
+ }
+ if (ret < 0) {
+ if (state)
+ pm_runtime_put_noidle(&st->pdev->dev);
+ return ret;
+ }
+
return 0;
+#else
+ return _hid_sensor_power_state(st, state);
+#endif
}
EXPORT_SYMBOL(hid_sensor_power_state);
@@ -126,8 +157,21 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
attrb->trigger = trig;
indio_dev->trig = iio_trigger_get(trig);
- return ret;
+ ret = pm_runtime_set_active(&indio_dev->dev);
+ if (ret)
+ goto error_unreg_trigger;
+
+ iio_device_set_drvdata(indio_dev, attrb);
+ pm_suspend_ignore_children(&attrb->pdev->dev, true);
+ pm_runtime_enable(&attrb->pdev->dev);
+ /* Default to 3 seconds, but can be changed from sysfs */
+ pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
+ 3000);
+ pm_runtime_use_autosuspend(&attrb->pdev->dev);
+ return ret;
+error_unreg_trigger:
+ iio_trigger_unregister(trig);
error_free_trig:
iio_trigger_free(trig);
error_ret:
@@ -135,6 +179,34 @@ error_ret:
}
EXPORT_SYMBOL(hid_sensor_setup_trigger);
+#ifdef CONFIG_PM
+static int hid_sensor_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
+
+ return _hid_sensor_power_state(attrb, false);
+}
+
+static int hid_sensor_resume(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev);
+
+ return _hid_sensor_power_state(attrb, true);
+}
+
+#endif
+
+const struct dev_pm_ops hid_sensor_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend, hid_sensor_resume)
+ SET_RUNTIME_PM_OPS(hid_sensor_suspend,
+ hid_sensor_resume, NULL)
+};
+EXPORT_SYMBOL(hid_sensor_pm_ops);
+
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
MODULE_DESCRIPTION("HID Sensor trigger processing");
MODULE_LICENSE("GPL");
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index 0f8e78c..9f4713f 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -19,6 +19,11 @@
#ifndef _HID_SENSOR_TRIGGER_H
#define _HID_SENSOR_TRIGGER_H
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+
+extern const struct dev_pm_ops hid_sensor_pm_ops;
+
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
struct hid_sensor_common *attrb);
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/8] iio: hid-sensor-gyro-3d: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (9 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 1/8] iio: hid_sensor_hub: Common PM functions Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 4/8] iio: hid-sensor-als: " Srinivas Pandruvada
` (6 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/gyro/hid-sensor-gyro-3d.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index bdcd105..b5883b6 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -111,19 +111,12 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
- poll_value = hid_sensor_read_poll_value(
- &gyro_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&gyro_state->common_attributes, true);
- msleep_interruptible(poll_value * 2);
report_id = gyro_state->gyro[chan->scan_index].report_id;
address = gyro_3d_addresses[chan->scan_index];
if (report_id >= 0)
@@ -417,6 +410,7 @@ static struct platform_driver hid_gyro_3d_platform_driver = {
.id_table = hid_gyro_3d_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_gyro_3d_probe,
.remove = hid_gyro_3d_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/8] iio: hid-sensor-als: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (10 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 3/8] iio: hid-sensor-gyro-3d: Introduce PM Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 5/8] iio: hid-sensor-prox: " Srinivas Pandruvada
` (5 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/light/hid-sensor-als.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 321862d..1609ecd 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -80,7 +80,6 @@ static int als_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
@@ -97,15 +96,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
break;
}
if (report_id >= 0) {
- poll_value = hid_sensor_read_poll_value(
- &als_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&als_state->common_attributes,
true);
- msleep_interruptible(poll_value * 2);
-
*val = sensor_hub_input_attr_get_raw_value(
als_state->common_attributes.hsdev,
HID_USAGE_SENSOR_ALS, address,
@@ -382,6 +374,7 @@ static struct platform_driver hid_als_platform_driver = {
.id_table = hid_als_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_als_probe,
.remove = hid_als_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/8] iio: hid-sensor-prox: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (11 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 4/8] iio: hid-sensor-als: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 6/8] iio: hid-sensor-magn-3d: " Srinivas Pandruvada
` (4 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/light/hid-sensor-prox.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index db9c60e..91ecc46 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -75,7 +75,6 @@ static int prox_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
@@ -92,16 +91,8 @@ static int prox_read_raw(struct iio_dev *indio_dev,
break;
}
if (report_id >= 0) {
- poll_value = hid_sensor_read_poll_value(
- &prox_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&prox_state->common_attributes,
true);
-
- msleep_interruptible(poll_value * 2);
-
*val = sensor_hub_input_attr_get_raw_value(
prox_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PROX, address,
@@ -374,6 +365,7 @@ static struct platform_driver hid_prox_platform_driver = {
.id_table = hid_prox_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_prox_probe,
.remove = hid_prox_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/8] iio: hid-sensor-magn-3d: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (12 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 5/8] iio: hid-sensor-prox: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 7/8] iio: hid-sensor-incl-3d: " Srinivas Pandruvada
` (3 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 4d299f3..4f9c0be 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -157,20 +157,12 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
- poll_value = hid_sensor_read_poll_value(
- &magn_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&magn_state->common_attributes, true);
- msleep_interruptible(poll_value * 2);
-
report_id =
magn_state->magn[chan->address].report_id;
address = magn_3d_addresses[chan->address];
@@ -531,6 +523,7 @@ static struct platform_driver hid_magn_3d_platform_driver = {
.id_table = hid_magn_3d_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_magn_3d_probe,
.remove = hid_magn_3d_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 7/8] iio: hid-sensor-incl-3d: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (13 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 6/8] iio: hid-sensor-magn-3d: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 8/8] iio: hid-sensor-press: " Srinivas Pandruvada
` (2 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/orientation/hid-sensor-incl-3d.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 45bed08..5930fa3 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -111,20 +111,12 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
switch (mask) {
case IIO_CHAN_INFO_RAW:
- poll_value = hid_sensor_read_poll_value(
- &incl_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
-
hid_sensor_power_state(&incl_state->common_attributes, true);
- msleep_interruptible(poll_value * 2);
-
report_id =
incl_state->incl[chan->scan_index].report_id;
address = incl_3d_addresses[chan->scan_index];
@@ -438,6 +430,7 @@ static struct platform_driver hid_incl_3d_platform_driver = {
.id_table = hid_incl_3d_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_incl_3d_probe,
.remove = hid_incl_3d_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 8/8] iio: hid-sensor-press: Introduce PM
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (14 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 7/8] iio: hid-sensor-incl-3d: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH] HID: hid-sensor-hub: Add collection device Srinivas Pandruvada
2015-01-07 8:48 ` [PATCH] HID: hid-sensor-hub: Correct documentation Jiri Kosina
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
Use common hid sensor iio pm functions. Also the poll time read and
wait is part of power up function of hid sensor iio pm function, so
remove from the client drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/pressure/hid-sensor-press.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index ac150f0..7bb8d4c 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -79,7 +79,6 @@ static int press_read_raw(struct iio_dev *indio_dev,
int report_id = -1;
u32 address;
int ret_type;
- s32 poll_value;
*val = 0;
*val2 = 0;
@@ -96,15 +95,8 @@ static int press_read_raw(struct iio_dev *indio_dev,
break;
}
if (report_id >= 0) {
- poll_value = hid_sensor_read_poll_value(
- &press_state->common_attributes);
- if (poll_value < 0)
- return -EINVAL;
hid_sensor_power_state(&press_state->common_attributes,
true);
-
- msleep_interruptible(poll_value * 2);
-
*val = sensor_hub_input_attr_get_raw_value(
press_state->common_attributes.hsdev,
HID_USAGE_SENSOR_PRESSURE, address,
@@ -383,6 +375,7 @@ static struct platform_driver hid_press_platform_driver = {
.id_table = hid_press_ids,
.driver = {
.name = KBUILD_MODNAME,
+ .pm = &hid_sensor_pm_ops,
},
.probe = hid_press_probe,
.remove = hid_press_remove,
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH] HID: hid-sensor-hub: Add collection device
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (15 preceding siblings ...)
2015-01-07 0:58 ` [PATCH 8/8] iio: hid-sensor-press: " Srinivas Pandruvada
@ 2015-01-07 0:58 ` Srinivas Pandruvada
2015-01-07 8:48 ` [PATCH] HID: hid-sensor-hub: Correct documentation Jiri Kosina
17 siblings, 0 replies; 30+ messages in thread
From: Srinivas Pandruvada @ 2015-01-07 0:58 UTC (permalink / raw)
To: jkosina, jic23; +Cc: linux-iio, linux-input, Srinivas Pandruvada
HID sensor hub exports several sensor which are fusion sensors, where
data is interpreted from one or more sensors. Some of them can't be
exported via IIO like sysfs as the user space download some firmware,
which defines what sensor will look like. They can be a part of a
collection.
Creating a MFD cell for a collection to write a standalone driver
to manage collections. Most of the time they will be propritery drivers
may not be even upstreamed. This patch allows framework to have
capability to write such drivers.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-hub.c | 50 ++++++++++++++++++++++++++++++++++++++----
include/linux/hid-sensor-ids.h | 2 ++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 84290e5..7403b25 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -119,11 +119,12 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
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 == HID_USAGE_SENSOR_TYPE_COLLECTION ||
+ (callback->usage_id == usage_id &&
(collection_index >=
callback->hsdev->start_collection_index) &&
(collection_index <
- callback->hsdev->end_collection_index)) {
+ callback->hsdev->end_collection_index))) {
*priv = callback->priv;
*hsdev = callback->hsdev;
spin_unlock_irqrestore(&pdata->dyn_callback_lock,
@@ -159,7 +160,12 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
callback->usage_callback = usage_callback;
callback->usage_id = usage_id;
callback->priv = NULL;
- list_add_tail(&callback->list, &pdata->dyn_callback_list);
+ /* Give higher priority to collection device, so add to front */
+ if (usage_id == HID_USAGE_SENSOR_TYPE_COLLECTION)
+ list_add(&callback->list, &pdata->dyn_callback_list);
+ else
+ list_add_tail(&callback->list, &pdata->dyn_callback_list);
+
spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
return 0;
@@ -590,6 +596,37 @@ static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
return rdesc;
}
+static int sensor_hub_add_collection_device(struct hid_device *hdev,
+ struct sensor_hub_data *sd)
+{
+ struct hid_sensor_hub_device *hsdev;
+ char *name;
+
+ hsdev = devm_kzalloc(&hdev->dev, sizeof(*hsdev), GFP_KERNEL);
+ if (!hsdev)
+ return -ENOMEM;
+
+ hsdev->hdev = hdev;
+ hsdev->vendor_id = hdev->vendor;
+ hsdev->product_id = hdev->product;
+ hsdev->usage = HID_USAGE_SENSOR_TYPE_COLLECTION;
+ mutex_init(&hsdev->mutex);
+ name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "HID-SENSOR-%x",
+ HID_USAGE_SENSOR_TYPE_COLLECTION);
+ if (name == NULL) {
+ hid_err(hdev, "Failed MFD device name\n");
+ return -ENOMEM;
+ }
+ sd->hid_sensor_hub_client_devs[sd->hid_sensor_client_cnt].name = name;
+ sd->hid_sensor_hub_client_devs[
+ sd->hid_sensor_client_cnt].platform_data = hsdev;
+ sd->hid_sensor_hub_client_devs[
+ sd->hid_sensor_client_cnt].pdata_size = sizeof(*hsdev);
+ sd->hid_sensor_client_cnt++;
+
+ return 0;
+}
+
static int sensor_hub_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
@@ -634,7 +671,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
ret = -EINVAL;
goto err_stop_hw;
}
- sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
+ sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev,
+ (dev_cnt + 1) *
sizeof(struct mfd_cell),
GFP_KERNEL);
if (sd->hid_sensor_hub_client_devs == NULL) {
@@ -688,6 +726,10 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (last_hsdev)
last_hsdev->end_collection_index = i;
+ ret = sensor_hub_add_collection_device(hdev, sd);
+ if (ret)
+ goto err_stop_hw;
+
ret = mfd_add_hotplug_devices(&hdev->dev,
sd->hid_sensor_hub_client_devs,
sd->hid_sensor_client_cnt);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 109f0e6..300ffea 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -21,6 +21,8 @@
#define HID_MAX_PHY_DEVICES 0xFF
+#define HID_USAGE_SENSOR_TYPE_COLLECTION 0x200001
+
/* Accel 3D (200073) */
#define HID_USAGE_SENSOR_ACCEL_3D 0x200073
#define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452
--
1.9.1
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH] HID: hid-sensor-hub: Correct documentation
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
` (16 preceding siblings ...)
2015-01-07 0:58 ` [PATCH] HID: hid-sensor-hub: Add collection device Srinivas Pandruvada
@ 2015-01-07 8:48 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1501070946540.25732-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
17 siblings, 1 reply; 30+ messages in thread
From: Jiri Kosina @ 2015-01-07 8:48 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: jic23, linux-iio, linux-input
Srinivas,
the way you sent the patches are really confusing.
Most importantly, you seem to have inter-mixed three patch series (with
4,8 and 9 patches respectively) into one thread, plus there are 4 patches
which aren't marked by series numbering. All this is mixed together into
one thread without any particular ordering.
This way it makes it really difficult to review (and possibly apply
afterwards).
Could you please resend as proper independent series, with correct
threading etc?
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 30+ messages in thread