OSDN Git Service

Make sure accelerometer driver returns accordingly if attempted frequency is not...
authorAdriana Reus <adriana.reus@intel.com>
Tue, 16 Jul 2013 13:32:23 +0000 (16:32 +0300)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 18 Mar 2014 01:48:21 +0000 (09:48 +0800)
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>
drivers/iio/common/hid-sensors/hid-sensor-attributes.c

index 35b0d0c..20cc042 100644 (file)
@@ -145,9 +145,10 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
 {
        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) {
@@ -162,9 +163,19 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
                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, &current_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);