1
0
Fork 0

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

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: 73c6768b71 ("iio: hid-sensors: Common attribute and trigger")
Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
hifive-unleashed-5.1
Song Hongyan 2017-03-28 22:23:55 +08:00 committed by Jonathan Cameron
parent 862d1d89ad
commit bba6d9e47f
1 changed files with 10 additions and 0 deletions

View File

@ -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);