OSDN Git Service

Rework a little bit the end cases in check_state_change
authorPatrick Porlan <patrick.porlan@intel.com>
Wed, 17 Dec 2014 14:58:51 +0000 (15:58 +0100)
committerGerrit Code Review <gerrit2@irsgerrit001.ir.intel.com>
Thu, 18 Dec 2014 08:35:57 +0000 (08:35 +0000)
The new version is equivalent but a little bit clearer.

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

index 5c95008..015a019 100644 (file)
--- a/control.c
+++ b/control.c
@@ -84,15 +84,12 @@ static int check_state_change (int s, int enabled, int from_virtual)
                /* We're indirectly disabled but the base is still active */
                return 0;
 
-       /* If it's disable, and it's from Android, and we still have ref counts */
-       if (!from_virtual && sensor[s].ref_count) {
-               sensor[s].directly_enabled = 0;
-               return 0;
-       }
-
-       /*If perhaps we are from virtual but we're disabling it*/
+       /* We're now directly disabled */
        sensor[s].directly_enabled = 0;
 
+       if (!from_virtual && sensor[s].ref_count)
+               return 0; /* We still have ref counts */
+
        return 1; /* Do continue disabling this sensor */
 }