Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp578172pxb; Sat, 6 Mar 2021 09:13:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmw0mmc6cSUSgUFL05qpsZdfyrwt9UuwR/yegvampExQBWKXOklLR1I8kWNZs5JNMadKTf X-Received: by 2002:aa7:db51:: with SMTP id n17mr15192345edt.259.1615050792464; Sat, 06 Mar 2021 09:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615050792; cv=none; d=google.com; s=arc-20160816; b=rIzx5NKYdIHPAeNNxKCZxrapBNUBJPBekLqH08nTjFC991l/C5JrftMjdvLF7jKoF5 hQp8JFPa5DMapBuqOjR3tBEwpQOP/SLbe9NrjPlavjwzFDsgv1sgU+NtF153fMWjhIR7 cgEXVjN0I9p0a0QQxB68ufcAHdTPVSmO2e2BAaDhrrK64TrO93B/GmlsK+CJ0EhRsfPm NYNvVsRNZ6sytxigodHJ6YxACpBKICIe/SCNWt/IP8Lj/x8yvxMtQ9wfawvXvrZ8MUTx eAkPJBTPOAOoH4BrztaXhwvbAr29yMKCPTZvMapmJY18+X3UVJxZJvXVUdT7I+9xo1aa BNoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=aKcmST+Ck31/DtT7Vrja4zTZDsH8vBmHYAvA631o/p4=; b=Xvc2C8XNGH16cix5EVR/oKilhoZkR/xHmqymSCC6Bb87mLKU6m4a+qy5DffKKKay9v ir+YMwpkH584nW1NEfRcJtvD60ZgbOKSH2x70SJcGqXJJ1h/AHTmr7W4BOODzqVl+Y/e 4fa3syv65GuVEtRGMzu/ayowPM4O7qihzZpoTl/GQE+JhQjEDY2gitQrhXxIGI/1GRlB OEIe0Yv7mpRk6i6a1SkUivHHyndJ/JmKnBcyr13FccqrkdR7IJRa++hsh8EF7qOkBvws OzJUDzIHsfeSnQtuR1eeDl27fshMuvvkfZQQelcEyFHHZGzG7HLLiDTRcxG2Qouh8W6e aJew== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si3758641edk.64.2021.03.06.09.12.49; Sat, 06 Mar 2021 09:13:12 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbhCFRII (ORCPT + 99 others); Sat, 6 Mar 2021 12:08:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:57572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbhCFRHt (ORCPT ); Sat, 6 Mar 2021 12:07:49 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFA2B64FFD; Sat, 6 Mar 2021 17:07:47 +0000 (UTC) Date: Sat, 6 Mar 2021 17:07:43 +0000 From: Jonathan Cameron To: Ye Xiang Cc: jikos@kernel.org, srinivas.pandruvada@linux.intel.com, linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4] iio: hid-sensor-temperature: Fix issues of timestamp channel Message-ID: <20210306170743.16d30d95@archlinux> In-Reply-To: <20210303063615.12130-4-xiang.ye@intel.com> References: <20210303063615.12130-1-xiang.ye@intel.com> <20210303063615.12130-4-xiang.ye@intel.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 3 Mar 2021 14:36:14 +0800 Ye Xiang wrote: > 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. This isn't technically a bug because channel index numbers just need to be monotonic. Still it's a reasonable tidy up given 1. > > Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support") > Signed-off-by: Ye Xiang Applied to the fixes togreg branch of iio.git and marked for stable. Patch 4 is not a fix (I think) so will have to wait for this to be upstream. Jonathan > --- > 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;