From d9ac41e619554b96bc54fd784383b6da2395d278 Mon Sep 17 00:00:00 2001 From: Patrick Porlan Date: Wed, 17 Dec 2014 15:58:51 +0100 Subject: [PATCH] Rework a little bit the end cases in check_state_change The new version is equivalent but a little bit clearer. Change-Id: I8606a3e10007d60bac895f0ad12f4fd40f2fb2c7 Signed-off-by: Patrick Porlan --- control.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/control.c b/control.c index 5c95008..015a019 100644 --- 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 */ } -- 2.11.0