From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: jkosina@suse.cz, jic23@kernel.org, a.zummo@towertech.it
Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org,
holler@ahsoftware.de, rtc-linux@googlegroups.com,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads
Date: Wed, 7 Jan 2015 10:47:55 -0800 [thread overview]
Message-ID: <1420656483-7093-2-git-send-email-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <1420656483-7093-1-git-send-email-srinivas.pandruvada@linux.intel.com>
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 8bed109..7403b25 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -275,13 +275,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.3
next prev parent reply other threads:[~2015-01-07 18:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 18:47 [PATCH 0/9] Asynchronous attribute reads Srinivas Pandruvada
2015-01-07 18:47 ` Srinivas Pandruvada [this message]
2015-01-10 22:43 ` [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads Jonathan Cameron
2015-01-07 18:47 ` [PATCH 2/9] iio: hid-sensor-accel-3d: Adjust parameter for attribute read Srinivas Pandruvada
2015-01-10 22:42 ` Jonathan Cameron
2015-01-11 23:08 ` Srinivas Pandruvada
2015-01-11 23:24 ` Srinivas Pandruvada
2015-01-12 21:24 ` Jonathan Cameron
2015-01-12 21:33 ` Srinivas Pandruvada
2015-01-07 18:47 ` [PATCH 3/9] iio: hid-sensor-gyro-3d: " Srinivas Pandruvada
2015-01-07 18:47 ` [PATCH 4/9] iio: hid-sensor-als: " Srinivas Pandruvada
2015-01-07 18:47 ` [PATCH 5/9] iio: hid-sensor-prox: " Srinivas Pandruvada
2015-01-07 18:48 ` [PATCH 6/9] iio: hid-sensor-magn-3d: " Srinivas Pandruvada
2015-01-07 18:48 ` [PATCH 7/9] iio: hid-sensor-incl-3d: " Srinivas Pandruvada
2015-01-07 18:48 ` [PATCH 8/9] iio: hid-sensor-press: " Srinivas Pandruvada
2015-01-07 18:48 ` [PATCH 9/9] drivers/rtc/rtc-hid-sensor-time.c: " Srinivas Pandruvada
-- strict thread matches above, loose matches on Subject: below --
2015-01-07 0:58 [PATCH] HID: hid-sensor-hub: Correct documentation Srinivas Pandruvada
2015-01-07 0:58 ` [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads Srinivas Pandruvada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420656483-7093-2-git-send-email-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=a.zummo@towertech.it \
--cc=holler@ahsoftware.de \
--cc=jic23@kernel.org \
--cc=jkosina@suse.cz \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).