linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Song Hongyan
	<hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH] iio: hid-sensor-attributes: Fix sensor property setting failure.
Date: Sat, 25 Mar 2017 18:00:01 +0000	[thread overview]
Message-ID: <48b89e39-011c-34b8-5241-401c8137766d@kernel.org> (raw)
In-Reply-To: <1490352828-40203-1-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On 24/03/17 10:53, Song Hongyan wrote:
> When system bootup without get sensor property, set sensor
> property will be fail.
> 
> If no get_feature operation done before set_feature, the sensor
> properties will all be the initialized value, which is not the
> same with sensor real properties. When set sensor property it will
> write back to sensor the changed perperty data combines with other
> sensor properties data, it is not right and may be dangerous.
> 
> In order to get all sensor properties, choose to read one of the sensor
> property(no matter read any sensor peroperty, driver will get all
> the peroperties and return the requested one).
property, properties throughout description.
> 
> Signed-off-by: Song Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Fixes?

Definitely sounds like one for stable and that tag helps people quickly
find where it is relevant.
> ---
>  drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> index 7afdac42..01e02b9 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> @@ -379,6 +379,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
>  {
>  
>  	struct hid_sensor_hub_attribute_info timestamp;
> +	s32 value;
> +	int ret;
>  
>  	hid_sensor_get_reporting_interval(hsdev, usage_id, st);
>  
> @@ -417,6 +419,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
>  		st->sensitivity.index, st->sensitivity.report_id,
>  		timestamp.index, timestamp.report_id);
>  
> +	ret = sensor_hub_get_feature(hsdev,
> +				st->power_state.report_id,
> +				st->power_state.index, sizeof(value), &value);
> +	if (ret < 0)
> +		return ret;
> +	if (value < 0)
> +		return -EINVAL;
> +
>  	return 0;
>  }
>  EXPORT_SYMBOL(hid_sensor_parse_common_attributes);
> 

      parent reply	other threads:[~2017-03-25 18:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 10:53 [PATCH] iio: hid-sensor-attributes: Fix sensor property setting failure Song Hongyan
     [not found] ` <1490352828-40203-1-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-25 18:00   ` Jonathan Cameron [this message]

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=48b89e39-011c-34b8-5241-401c8137766d@kernel.org \
    --to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /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).