Commit dc49f841 authored by Song Hongyan's avatar Song Hongyan Committed by Ben Hutchings

iio: hid-sensor-attributes: Fix sensor property setting failure.

commit bba6d9e4 upstream.

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
properties(no matter read any sensor peroperty, driver will get all
the peroperties and return the requested one).

Fixes: 73c6768b ("iio: hid-sensors: Common attribute and trigger")
Signed-off-by: default avatarSong Hongyan <hongyan.song@intel.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
[bwh: Backported to 3.16:
 - sensor_hub_get_feature() doesn't take a 'buffer_size' parameter
 - Adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 2c10d3e6
...@@ -363,6 +363,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, ...@@ -363,6 +363,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
struct hid_sensor_common *st) struct hid_sensor_common *st)
{ {
s32 value;
int ret;
hid_sensor_get_reporting_interval(hsdev, usage_id, st); hid_sensor_get_reporting_interval(hsdev, usage_id, st);
...@@ -387,6 +389,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, ...@@ -387,6 +389,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
st->power_state.index, st->power_state.report_id, st->power_state.index, st->power_state.report_id,
st->sensitivity.index, st->sensitivity.report_id); st->sensitivity.index, st->sensitivity.report_id);
ret = sensor_hub_get_feature(hsdev,
st->power_state.report_id,
st->power_state.index, &value);
if (ret < 0)
return ret;
if (value < 0)
return -EINVAL;
return 0; return 0;
} }
EXPORT_SYMBOL(hid_sensor_parse_common_attributes); EXPORT_SYMBOL(hid_sensor_parse_common_attributes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment