Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1016410pxb; Thu, 4 Mar 2021 00:37:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL2nUJbumIJEpiKEptbk30TbrRIn1KQp5ngOfU+N4X+KT1KOmO1Kpf/ztRJezcejVyUWDS X-Received: by 2002:a17:906:1bf2:: with SMTP id t18mr3077515ejg.418.1614847065920; Thu, 04 Mar 2021 00:37:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614847065; cv=none; d=google.com; s=arc-20160816; b=KYE0viHJ48r+waqG6ndNywXgBsWfG5PdQiw2+vjbyEjmjTNCgToV7FAdvR8KGxXzHH 9gTFnCb+s8/JYeVqtBAqfa/POKnex/QQ322jtoeIoQe0Mx6zWLhX9DKEkiDXBGWhybng 3EZjWxfVTimJuza0utB98FjauROz9UdbAe74e31TNcpRs8xUJYVA6KpfBsU0W2gzT84e tWTGsEKm2tq1jb9kXDIu0GCrKvym31mH1mzQJC6BmgU3XuNKDZ70IdaXvKq8R0P/sto1 PBWdIKinSARVIsVWlZiM5l0EOn0StzOHSvKaQoCoEV97mMfth3R4b/Wyb1gkItcsy+PO zbQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=+cGw3d+Gh4f+TOjWDu6PBPH4/5J1WJWQd7xkS/3JIcI=; b=ahOty5cYry5L4qbmf/PKA8+C2W0B/xqLE7E1ckNjBhdnqX61DAQHkKUa1RUmWR+GSP i5pzBICkFO5kM7/8sXU94JcvlmgYuRTNYpaFVIWRMb1gOsZQ1vW1m0MkUylcnTF4ZI9F VWPVEFyg1d03Xc9PLzuN6eSFynIMt7LPqhA7nHMlTDzKh6Z0IybkeqmB21WBAPnODF3Q wmGHG+lWHQjeJD4ha8RGDTMLKioncO5PIrw7tF++H9NfUm2x2xA8DlNP+BCSRTf8ttnZ AnBNFwICDUIZVsQxIVzNdzyrtLlSs9qTFTwHdcTQTreYGrSvzelXiwKPx0vpAPWbZu4K nAuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si18401195edi.63.2021.03.04.00.37.23; Thu, 04 Mar 2021 00:37:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444182AbhCCMPW (ORCPT + 99 others); Wed, 3 Mar 2021 07:15:22 -0500 Received: from mga17.intel.com ([192.55.52.151]:50151 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1841820AbhCCGiR (ORCPT ); Wed, 3 Mar 2021 01:38:17 -0500 IronPort-SDR: m+zdDewE6wxrFoFKHb2ZbRXnhjeKrgQgg4pv7kEW6BAy4tfDqgd9rn1re0UjwtpQCig4sNPF3C Qval5Zc9Zb5w== X-IronPort-AV: E=McAfee;i="6000,8403,9911"; a="167012884" X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="167012884" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2021 22:36:00 -0800 IronPort-SDR: n841CAA7egzCmxnVOXp/mTQQeI446hcezOqZau0UCHroGA5Lvwp4e4q2IFlvtHhEdBBZe8zaUX qabmyh2hOinA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="383870907" Received: from host.sh.intel.com ([10.239.154.115]) by orsmga002.jf.intel.com with ESMTP; 02 Mar 2021 22:35:58 -0800 From: Ye Xiang To: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@linux.intel.com Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ye Xiang Subject: [PATCH 2/4] iio: hid-sensor-humidity: Get sample timestamp from sensor hub Date: Wed, 3 Mar 2021 14:36:13 +0800 Message-Id: <20210303063615.12130-3-xiang.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210303063615.12130-1-xiang.ye@intel.com> References: <20210303063615.12130-1-xiang.ye@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Try to get sample timestamp from sensor hub first, if failed then use system timestamp. Signed-off-by: Ye Xiang --- drivers/iio/humidity/hid-sensor-humidity.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c index 74383abc0d44..f7b4c76ed94f 100644 --- a/drivers/iio/humidity/hid-sensor-humidity.c +++ b/drivers/iio/humidity/hid-sensor-humidity.c @@ -23,6 +23,7 @@ struct hid_humidity_state { int scale_post_decml; int scale_precision; int value_offset; + s64 timestamp; }; static const u32 humidity_sensitivity_addresses[] = { @@ -131,9 +132,14 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(pdev); struct hid_humidity_state *humid_st = iio_priv(indio_dev); - if (atomic_read(&humid_st->common_attributes.data_ready)) + if (atomic_read(&humid_st->common_attributes.data_ready)) { + if (!humid_st->timestamp) + humid_st->timestamp = iio_get_time_ns(indio_dev); + iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan, - iio_get_time_ns(indio_dev)); + humid_st->timestamp); + humid_st->timestamp = 0; + } return 0; } @@ -151,6 +157,10 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev, humid_st->scan.humidity_data = *(s32 *)raw_data; return 0; + case HID_USAGE_SENSOR_TIME_TIMESTAMP: + humid_st->timestamp = hid_sensor_convert_timestamp(&humid_st->common_attributes, + *(s64 *)raw_data); + return 0; default: return -EINVAL; } -- 2.17.1