linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Ye Xiang <xiang.ye@intel.com>
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
Date: Sat, 6 Mar 2021 17:07:43 +0000	[thread overview]
Message-ID: <20210306170743.16d30d95@archlinux> (raw)
In-Reply-To: <20210303063615.12130-4-xiang.ye@intel.com>

On Wed,  3 Mar 2021 14:36:14 +0800
Ye Xiang <xiang.ye@intel.com> 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 <xiang.ye@intel.com>
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;


  reply	other threads:[~2021-03-06 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03  6:36 [PATCH 0/4] Fix humidity and temperature timestamp channel issues Ye Xiang
2021-03-03  6:36 ` [PATCH 1/4] iio: hid-sensor-humidity: Fix alignment issue of timestamp channel Ye Xiang
2021-03-06 17:05   ` Jonathan Cameron
2021-03-03  6:36 ` [PATCH 2/4] iio: hid-sensor-humidity: Get sample timestamp from sensor hub Ye Xiang
2021-03-03  6:36 ` [PATCH 3/4] iio: hid-sensor-temperature: Fix issues of timestamp channel Ye Xiang
2021-03-06 17:07   ` Jonathan Cameron [this message]
2021-03-03  6:36 ` [PATCH 4/4] iio: hid-sensor-temperature: Get sample timestamp from sensor hub Ye Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210306170743.16d30d95@archlinux \
    --to=jic23@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=xiang.ye@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).