From patchwork Wed Jan 7 00:58:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 5578781 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D598ABF6C3 for ; Wed, 7 Jan 2015 01:00:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 088B82021B for ; Wed, 7 Jan 2015 01:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19D1D2024C for ; Wed, 7 Jan 2015 01:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756666AbbAGBAA (ORCPT ); Tue, 6 Jan 2015 20:00:00 -0500 Received: from mga02.intel.com ([134.134.136.20]:13667 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754248AbbAGA7m (ORCPT ); Tue, 6 Jan 2015 19:59:42 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 06 Jan 2015 16:59:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,711,1413270000"; d="scan'208";a="665491839" Received: from spandruv-desktop.jf.intel.com ([10.7.199.150]) by orsmga002.jf.intel.com with ESMTP; 06 Jan 2015 16:59:39 -0800 From: Srinivas Pandruvada To: jkosina@suse.cz, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-input@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 1/9] HID: hid-sensor-hub: Extend API for async reads Date: Tue, 6 Jan 2015 16:58:31 -0800 Message-Id: <1420592328-9942-8-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1420592328-9942-1-git-send-email-srinivas.pandruvada@linux.intel.com> References: <1420592328-9942-1-git-send-email-srinivas.pandruvada@linux.intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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.