From patchwork Tue Sep 10 20:03:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 2867621 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6204EBF43F for ; Tue, 10 Sep 2013 20:04:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77CE72010B for ; Tue, 10 Sep 2013 20:04:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43ED020174 for ; Tue, 10 Sep 2013 20:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427Ab3IJUEH (ORCPT ); Tue, 10 Sep 2013 16:04:07 -0400 Received: from mga02.intel.com ([134.134.136.20]:61911 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204Ab3IJUEG (ORCPT ); Tue, 10 Sep 2013 16:04:06 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 10 Sep 2013 13:04:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,879,1371106800"; d="scan'208";a="376226595" Received: from spandruv-linux-test.jf.intel.com ([10.7.199.164]) by orsmga001.jf.intel.com with ESMTP; 10 Sep 2013 13:04:04 -0700 From: Srinivas Pandruvada To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: jc23@cam.ac.uk, jkosina@suse.cz, holler@ahsoftware.de, Srinivas Pandruvada Subject: [PATCH 2/3] IIO: call sensor hub open close function Date: Tue, 10 Sep 2013 13:03:51 -0700 Message-Id: <1378843432-5113-2-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1378843432-5113-1-git-send-email-srinivas.pandruvada@linux.intel.com> References: <1378843432-5113-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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Call hid_sensor_hub_device_open when user space opens device and call hid_sensor_hub_device_close when device is closed. This helps in saving power. Signed-off-by: Srinivas Pandruvada --- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 87419c4..b6e77e0 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -34,6 +34,12 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, struct hid_sensor_common *st = iio_trigger_get_drvdata(trig); int state_val; + if (state) { + if (sensor_hub_device_open(st->hsdev)) + return -EIO; + } else + sensor_hub_device_close(st->hsdev); + state_val = state ? 1 : 0; if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS)) ++state_val;