This is a workaround for a suspected firmware issue.
If a bigger value than supported is attempted to be set it is
silently discarded, and the write function in the driver returns normally
even though it was unsuccessfull.
This patch double checks a value by also reading the field and checking if it was
set accordingly.
Issue: AXIA-3061
Change-Id: Ief11af31994e26f4bc9c4d6b05023623192aaa2f
Original-Change-Id: I1b52a1a176079962caedc4f084e57f9765c7f45b
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
{
s32 value;
int ret;
+ s32 current_value = 0;
if (val1 < 0 || val2 < 0)
- ret = -EINVAL;
+ return -EINVAL;
value = val1 * pow_10(6) + val2;
if (value) {
st->poll.report_id,
st->poll.index, value);
if (ret < 0 || value < 0)
- ret = -EINVAL;
-
- return ret;
+ return -EINVAL;
+ ret = sensor_hub_get_feature(st->hsdev,
+ st->poll.report_id,
+ st->poll.index, ¤t_value);
+ if (ret < 0) {
+ printk(KERN_ERR "sensor_hub_get_feature failed\n");
+ return ret;
+ }
+ if (current_value != value) {
+ printk(KERN_ERR "sensor_hub_set_feature_failed\n");
+ return -EINVAL;
+ }
+ return 0;
}
EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);