OSDN Git Service

STPK-1429 Minor tweak to compass calibration data save point
authorPatrick Porlan <patrick.porlan@intel.com>
Wed, 2 Jul 2014 12:18:11 +0000 (14:18 +0200)
committerGerrit Code Review <gerrit@mcg-psi-gcr1.jf.intel.com>
Thu, 17 Jul 2014 13:20:36 +0000 (06:20 -0700)
Was being saved each time the magnetometer reference count was
decremented. Doing it when it reaches zero is probably enough.

Issue: STPK-1429

Change-Id: Ia465821cbf1ec22c5645753b6289e368d7ef2bd8
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
control.c

index d9e1ea2..a7de562 100644 (file)
--- a/control.c
+++ b/control.c
@@ -234,9 +234,6 @@ int adjust_counters (int s, int enabled)
                ALOGI("Disabling sensor %d (iio device %d: %s)\n", s, dev_num,
                      sensor_info[s].friendly_name);
 
-               if (sensor_type == SENSOR_TYPE_MAGNETIC_FIELD)
-                       compass_store_data(&sensor_info[s]);
-
                sensor_info[s].enable_count--;
 
                if (sensor_info[s].enable_count > 0)
@@ -244,6 +241,9 @@ int adjust_counters (int s, int enabled)
 
                /* Sensor disabled, lower report available flag */
                sensor_info[s].report_pending = 0;
+
+               if (sensor_type == SENSOR_TYPE_MAGNETIC_FIELD)
+                       compass_store_data(&sensor_info[s]);
        }
 
        /* We changed the state of a sensor - adjust per iio device counters */