From patchwork Wed Sep 18 17:13:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 2908071 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC0C79F1BF for ; Wed, 18 Sep 2013 17:13:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27B43203A8 for ; Wed, 18 Sep 2013 17:13:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B180A203B4 for ; Wed, 18 Sep 2013 17:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865Ab3IRRNJ (ORCPT ); Wed, 18 Sep 2013 13:13:09 -0400 Received: from mga02.intel.com ([134.134.136.20]:53756 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751988Ab3IRRNI (ORCPT ); Wed, 18 Sep 2013 13:13:08 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Sep 2013 10:13:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,930,1371106800"; d="scan'208";a="405303301" Received: from spandruv-linux-test.jf.intel.com ([10.7.199.164]) by orsmga002.jf.intel.com with ESMTP; 18 Sep 2013 10:13:06 -0700 From: Srinivas Pandruvada To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: jic23@kernel.org, jkosina@suse.cz, holler@ahsoftware.de, Srinivas Pandruvada Subject: [PATCH 3/3] HID RTC: Open sensor hub open close Date: Wed, 18 Sep 2013 10:13:19 -0700 Message-Id: <1379524399-16995-3-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1379524399-16995-1-git-send-email-srinivas.pandruvada@linux.intel.com> References: <1379524399-16995-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 Open sensor hub when module is loaded and close when module is removed. This helps saving power by opening HID transport only when there is an user. Signed-off-by: Srinivas Pandruvada Acked-by: Alessandro Zummo --- drivers/rtc/rtc-hid-sensor-time.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index 7273b01..1fe170c 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c @@ -279,15 +279,28 @@ static int hid_time_probe(struct platform_device *pdev) return ret; } + ret = sensor_hub_device_open(hsdev); + if (ret) { + dev_err(&pdev->dev, "failed to open sensor hub device!\n"); + goto err_open; + } + time_state->rtc = devm_rtc_device_register(&pdev->dev, "hid-sensor-time", &hid_time_rtc_ops, THIS_MODULE); if (IS_ERR(time_state->rtc)) { dev_err(&pdev->dev, "rtc device register failed!\n"); - return PTR_ERR(time_state->rtc); + ret = PTR_ERR(time_state->rtc); + goto err_rtc; } + return 0; + +err_rtc: + sensor_hub_device_close(hsdev); +err_open: + sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); return ret; } @@ -295,6 +308,7 @@ static int hid_time_remove(struct platform_device *pdev) { struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; + sensor_hub_device_close(hsdev); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); return 0;