Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1514743pxb; Thu, 4 Mar 2021 13:25:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWo+GWiCWEHHif+ieBd73ESRrBlolEaOzjANAmncsEHEfP+j0980TtZgMyNFydRDqELATw X-Received: by 2002:a50:d7c7:: with SMTP id m7mr6414212edj.260.1614893102034; Thu, 04 Mar 2021 13:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614893102; cv=none; d=google.com; s=arc-20160816; b=nNBzV8cwz9HUKv7jxQPbriLy2/R+jhDm9gm++ahPixq/66S3enwGIzEgcWvEKxMINO QZQ7pVXkpnGXxagHUYPgikxkG98kA3VnFCtioRLdPPEOUgTAdbuP4w/7qByAwWEZ580l /wp9s8RrEkRXgxBA3GrPxOr4sntUHWNRP7J1EskwbLYiOvpiLf6toU6KuWE1Oxfl0Cj5 jbrHsVRvdTuVfF1drFcGMjSgrBrpN4g0uSMGVr0iju0YDzeuotTT15wX/ioxCEps20nE XXHtoMakVm9+MstFZgC3DtAgc6Wf4VBGn37sCp+UYb8r3vpJC2NZII5u+3fVZuQV+4D1 V6XQ== 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=4XPcd2IDAz004jJojOwcpTYOiRmDHhsnJeL3Q9GdCR4=; b=zIMwZBSOlR5+PfyWpm6qup042o8ZAqtYY8w1nsSOqGUVO0cfZmOCYLsMz+RMPSED6k Z7MRlfsjbV/PCHKe5fDEHTG0Xl8S/RMesJI0JWbfAjZIKHpNLzTA+D2ozF/DoIMtuYna LRcHjZV8mXO3IW4ipjYGVHpyliWuXdi9GfGgJ7+K6oAK1O08XH0ffOeKSDKkf0VhFRkw NTw4Rhq4V2fo0Sw+YQw/uIY5KnPNNGH9H0Tes5a0p+LKm6+6yISz5+s/ILN7w2ak+1ts MUOetUxuPcP/dXcqI/VozPLdAN+hXiIawSBpg+6YErK+Q2PXMavab4XjmRROm6nkNA+F BrRQ== 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 kf17si224556ejc.308.2021.03.04.13.24.37; Thu, 04 Mar 2021 13:25:02 -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 S1444439AbhCCMPb (ORCPT + 99 others); Wed, 3 Mar 2021 07:15:31 -0500 Received: from mga17.intel.com ([192.55.52.151]:50147 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1841823AbhCCGi3 (ORCPT ); Wed, 3 Mar 2021 01:38:29 -0500 IronPort-SDR: QupRfpN9oBzzs6zVIuboLXDxDoZMdk2mqvHukpoBsDxq6zthxHviWdMYu5UUnLmncnlofHcucd aPcxtno4UaWg== X-IronPort-AV: E=McAfee;i="6000,8403,9911"; a="167012902" X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="167012902" 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:02 -0800 IronPort-SDR: 1NxdKoDzUvWwhEtx/0uVwLiNyEaT+4EYDyHqLUGY+iyA3yPB99tpZj9MxZPd8Wxtw9MltYeL8D Uh+pPZQ5bibA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,219,1610438400"; d="scan'208";a="383870919" Received: from host.sh.intel.com ([10.239.154.115]) by orsmga002.jf.intel.com with ESMTP; 02 Mar 2021 22:36:00 -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 3/4] iio: hid-sensor-temperature: Fix issues of timestamp channel Date: Wed, 3 Mar 2021 14:36:14 +0800 Message-Id: <20210303063615.12130-4-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 This patch fixes 2 issues of timestamp channel: 1. This patch ensures that there is sufficient space and correct alignment for the timestamp. 2. Correct the timestamp channel scan index. Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support") Signed-off-by: Ye Xiang --- drivers/iio/temperature/hid-sensor-temperature.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c index e3d38cbcf354..dc534ed784c3 100644 --- a/drivers/iio/temperature/hid-sensor-temperature.c +++ b/drivers/iio/temperature/hid-sensor-temperature.c @@ -15,7 +15,10 @@ struct temperature_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info temperature_attr; - s32 temperature_data; + struct { + s32 temperature_data; + u64 timestamp __aligned(8); + } scan; int scale_pre_decml; int scale_post_decml; int scale_precision; @@ -36,7 +39,7 @@ static const struct iio_chan_spec temperature_channels[] = { BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS), }, - IIO_CHAN_SOFT_TIMESTAMP(3), + IIO_CHAN_SOFT_TIMESTAMP(1), }; /* Adjust channel real bits based on report descriptor */ @@ -127,9 +130,8 @@ static int temperature_proc_event(struct hid_sensor_hub_device *hsdev, struct temperature_state *temp_st = iio_priv(indio_dev); if (atomic_read(&temp_st->common_attributes.data_ready)) - iio_push_to_buffers_with_timestamp(indio_dev, - &temp_st->temperature_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan, + iio_get_time_ns(indio_dev)); return 0; } @@ -144,7 +146,7 @@ static int temperature_capture_sample(struct hid_sensor_hub_device *hsdev, switch (usage_id) { case HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE: - temp_st->temperature_data = *(s32 *)raw_data; + temp_st->scan.temperature_data = *(s32 *)raw_data; return 0; default: return -EINVAL; -- 2.17.1