hal-api-device: Remove unnecessary hal_initialized flag 73/309673/1
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 15 Apr 2024 07:59:05 +0000 (16:59 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Mon, 15 Apr 2024 08:05:52 +0000 (17:05 +0900)
Before using hal api function, loading hal backend is essential.
Thus, before calling hal backend function, hal backend loading is always checked.
However hal_initialized flag is being used uncessarily in duplicate.
To avoid duplcated operation, hal_initialized flag is removed.

Change-Id: I64ff8e3f7405d12c8fe82038f96c96f21748cf8f
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
12 files changed:
include/common.h
src/battery.c
src/bezel.c
src/external_connection.c
src/hal-api-device-haptic.c
src/input.c
src/ir.c
src/led.c
src/memory.c
src/power.c
src/thermal.c
src/touchscreen.c

index 95c3b5d622878183f74fbb76f88480a31eb4f6f9..b5811bfea2d1efeeab7e45996a51e8fdc7baeb8a 100644 (file)
     #define _E(x, ...)
 #endif
 
-#define HAL_INITIALIZED_FAILED         -1
-#define HAL_INITIALIZED_NOT            0
-#define HAL_INITIALIZED_SUCCEEDED      1
-
 #ifndef __CONSTRUCTOR__
 #define __CONSTRUCTOR__ __attribute__ ((constructor))
 #endif
index 01bad7db0b24c2b9174dcc53f39e70a2f210281d..aa280622c3ae21639c6581706191050428226626 100644 (file)
 #include "common.h"
 
 static hal_backend_battery_funcs *hal_battery_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_battery_get_backend(void)
 {
@@ -37,11 +31,9 @@ int hal_device_battery_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_BATTERY, (void **)&hal_battery_funcs);
        if (ret < 0) {
                 _E("Failed to get battery backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -52,7 +44,6 @@ int hal_device_battery_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_BATTERY, (void *)hal_battery_funcs);
        hal_battery_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -61,7 +52,7 @@ int hal_device_battery_register_changed_event(BatteryUpdated updated_cb, void *d
 {
        int ret;
 
-       if (!hal_battery_funcs && !hal_initialized) {
+       if (!hal_battery_funcs) {
                if ((ret = hal_device_battery_get_backend()) < 0)
                        return ret;
        }
@@ -77,7 +68,7 @@ int hal_device_battery_unregister_changed_event(BatteryUpdated updated_cb)
 {
        int ret;
 
-       if (!hal_battery_funcs && !hal_initialized) {
+       if (!hal_battery_funcs) {
                if ((ret = hal_device_battery_get_backend()) < 0)
                        return ret;
        }
@@ -94,7 +85,7 @@ int hal_device_battery_get_current_state(BatteryUpdated updated_cb, void *data)
 {
        int ret;
 
-       if (!hal_battery_funcs && !hal_initialized) {
+       if (!hal_battery_funcs) {
                if ((ret = hal_device_battery_get_backend()) < 0)
                        return ret;
        }
index f650b8db5d10ea0ab7118bf3ab96a9b7bcc30f63..768354532768afd9f08be0e51b0f44cd3608c25b 100644 (file)
 #include "common.h"
 
 static hal_backend_bezel_funcs *hal_bezel_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_bezel_get_backend(void)
 {
@@ -38,11 +32,9 @@ int hal_device_bezel_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_BEZEL, (void **)&hal_bezel_funcs);
        if (ret < 0) {
                 _E("Failed to get bezel backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -53,7 +45,6 @@ int hal_device_bezel_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_BEZEL, (void *)hal_bezel_funcs);
        hal_bezel_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -62,7 +53,7 @@ int hal_device_bezel_get_state(enum bezel_state *state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
@@ -78,7 +69,7 @@ int hal_device_bezel_set_state(enum bezel_state state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
@@ -94,7 +85,7 @@ int hal_device_bezel_get_sw_state(enum bezel_state *state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
@@ -110,7 +101,7 @@ int hal_device_bezel_set_sw_state(enum bezel_state state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
@@ -126,7 +117,7 @@ int hal_device_bezel_get_vib_state(enum bezel_vib_state *state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
@@ -142,7 +133,7 @@ int hal_device_bezel_set_vib_state(enum bezel_vib_state state)
 {
        int ret;
 
-       if (!hal_bezel_funcs && !hal_initialized) {
+       if (!hal_bezel_funcs) {
                if ((ret = hal_device_bezel_get_backend()) < 0)
                        return ret;
        }
index 7ecc2d83e78d00560bc380c02232b55eb3d9b693..c14a54c97ae62460caffb58241e0254a778072dd 100644 (file)
 #include "common.h"
 
 static hal_backend_external_connection_funcs *hal_external_connection_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_external_connection_get_backend(void)
 {
@@ -38,11 +32,9 @@ int hal_device_external_connection_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void **)&hal_external_connection_funcs);
        if (ret < 0) {
                 _E("Failed to get external connection backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -53,7 +45,6 @@ int hal_device_external_connection_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void *)hal_external_connection_funcs);
        hal_external_connection_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -63,7 +54,7 @@ int hal_device_external_connection_register_changed_event(ConnectionUpdated upda
 {
        int ret;
 
-       if (!hal_external_connection_funcs && !hal_initialized) {
+       if (!hal_external_connection_funcs) {
                if ((ret = hal_device_external_connection_get_backend()) < 0)
                        return ret;
        }
@@ -79,7 +70,7 @@ int hal_device_external_connection_unregister_changed_event(ConnectionUpdated up
 {
        int ret;
 
-       if (!hal_external_connection_funcs && !hal_initialized) {
+       if (!hal_external_connection_funcs) {
                if ((ret = hal_device_external_connection_get_backend()) < 0)
                        return ret;
        }
@@ -96,7 +87,7 @@ int hal_device_external_connection_get_current_state(ConnectionUpdated updated_c
 {
        int ret;
 
-       if (!hal_external_connection_funcs && !hal_initialized) {
+       if (!hal_external_connection_funcs) {
                if ((ret = hal_device_external_connection_get_backend()) < 0)
                        return ret;
        }
index ba7b7b30a263179c3ce16db270f759e0e5e21d92..fc4beadd5af8c3e47a96d8ae2ca04b8470a53fa3 100644 (file)
@@ -80,7 +80,7 @@ int hal_device_haptic_get_device_count(int *count)
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
@@ -98,7 +98,7 @@ int hal_device_haptic_open_device(int *handle)
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
@@ -116,7 +116,7 @@ int hal_device_haptic_close_device(int handle)
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
@@ -131,7 +131,7 @@ bool hal_device_haptic_is_valid(void)
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
@@ -146,7 +146,7 @@ int hal_device_haptic_vibrate(int handle, int duration, int frequency, int overd
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
@@ -162,7 +162,7 @@ int hal_device_haptic_stop_device(int handle)
 {
        int ret;
 
-       if (!hal_device_haptic_funcs && !hal_initialized) {
+       if (!hal_device_haptic_funcs) {
                if ((ret = hal_device_haptic_get_backend()) < 0)
                        return ret;
        }
index 2777fcdd96788c9e4818110e3fa3cb4907b931b3..1f2ae1b55c9a1b94199b1f0a64233e7269424fec 100644 (file)
@@ -20,7 +20,6 @@
 #include "common.h"
 
 static hal_backend_device_input_funcs *hal_device_input_funcs = NULL;
-static int hal_initialized = HAL_INITIALIZED_NOT;
 
 int hal_device_input_get_backend(void)
 {
@@ -32,11 +31,9 @@ int hal_device_input_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_INPUT, (void **)&hal_device_input_funcs);
        if (ret < 0) {
                _E("Failed to get input backend");
-               hal_initialized = HAL_INITIALIZED_FAILED;
                return ret;
        }
 
-       hal_initialized = HAL_INITIALIZED_SUCCEEDED;
        return 0;
 }
 
@@ -54,7 +51,6 @@ int hal_device_input_put_backend(void)
        }
 
        hal_device_input_funcs = NULL;
-       hal_initialized = HAL_INITIALIZED_NOT;
 
        return 0;
 }
@@ -63,7 +59,7 @@ int hal_device_input_set_event_state(int input_device_id, int on)
 {
        int ret;
 
-       if (!hal_device_input_funcs && !hal_initialized) {
+       if (!hal_device_input_funcs) {
                if ((ret = hal_device_input_get_backend()) < 0)
                        return ret;
        }
@@ -79,7 +75,7 @@ int hal_device_input_get_event_state(int input_device_id, int* on)
 {
        int ret;
 
-       if (!hal_device_input_funcs && !hal_initialized) {
+       if (!hal_device_input_funcs) {
                if ((ret = hal_device_input_get_backend()) < 0)
                        return ret;
        }
index 3d640396e5ac7a0c29d908d44df3278c55abde47..687e59a75b9366ee27ed263cdbc8ed3fad73a8bc 100644 (file)
--- a/src/ir.c
+++ b/src/ir.c
 #include "common.h"
 
 static hal_backend_ir_funcs *hal_ir_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_ir_get_backend(void)
 {
@@ -38,11 +32,9 @@ int hal_device_ir_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_IR, (void **)&hal_ir_funcs);
        if (ret < 0) {
                 _E("Failed to get ir backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -53,7 +45,6 @@ int hal_device_ir_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_IR, (void *)hal_ir_funcs);
        hal_ir_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -63,7 +54,7 @@ int hal_device_ir_is_available(bool *available)
 {
        int ret;
 
-       if (!hal_ir_funcs && !hal_initialized) {
+       if (!hal_ir_funcs) {
                if ((ret = hal_device_ir_get_backend()) < 0)
                        return ret;
        }
@@ -79,7 +70,7 @@ int hal_device_ir_transmit(int *frequency_pattern, int size)
 {
        int ret;
 
-       if (!hal_ir_funcs && !hal_initialized) {
+       if (!hal_ir_funcs) {
                if ((ret = hal_device_ir_get_backend()) < 0)
                        return ret;
        }
index 7f0493708f06dbcfbb89b65a88c33e7062251d5f..b856c935972e1fe419ceecbb71b86d3672002e73 100644 (file)
--- a/src/led.c
+++ b/src/led.c
 #include "hal-led-interface.h"
 
 static hal_backend_led_funcs *hal_led_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_led_get_backend(void)
 {
@@ -37,11 +31,9 @@ int hal_device_led_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_LED, (void **)&hal_led_funcs);
        if (ret < 0) {
                 _E("Failed to get led backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -52,7 +44,6 @@ int hal_device_led_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_LED, (void *)hal_led_funcs);
        hal_led_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -61,7 +52,7 @@ int hal_device_led_set_state(enum led_device_type type, struct led_state *state)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -105,7 +96,7 @@ int hal_device_led_get_state(enum led_device_type type, struct led_state **state
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -149,7 +140,7 @@ int hal_device_led_get_number(void)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -166,7 +157,7 @@ int hal_device_led_set_number(int number)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -185,7 +176,7 @@ int hal_device_led_get_max_num(void)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -202,7 +193,7 @@ int hal_device_keyled_set_state(struct keyled_state *state)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
@@ -219,7 +210,7 @@ int hal_device_keyled_get_state(int *keycode, int *brightness)
 {
        int ret;
 
-       if (!hal_led_funcs && !hal_initialized) {
+       if (!hal_led_funcs) {
                if ((ret = hal_device_led_get_backend()) < 0)
                        return ret;
        }
index 9acd608283918c150f2a222aadaf3ca157ca4b7d..774bc32b1e622f4932b93c8bfdd195dda13df40e 100644 (file)
@@ -61,7 +61,7 @@ int hal_device_memory_get_gpu_info(int pid, struct gpu_info *info)
 {
        int ret;
 
-       if (!hal_memory_funcs && !hal_initialized) {
+       if (!hal_memory_funcs) {
                if ((ret = hal_device_memory_get_backend()) < 0)
                        return ret;
        }
@@ -76,7 +76,7 @@ int hal_device_memory_get_gem_info(int pid, struct gem_info *info)
 {
        int ret;
 
-       if (!hal_memory_funcs && !hal_initialized) {
+       if (!hal_memory_funcs) {
                if ((ret = hal_device_memory_get_backend()) < 0)
                        return ret;
        }
index cb037201755950b1f2280d90e3fa20b8c8491fe3..997db61ae851b0f11942f47930c7a8f98b981f1d 100644 (file)
@@ -20,7 +20,6 @@
 #include "common.h"
 
 static hal_backend_device_power_funcs *hal_device_power_funcs = NULL;
-static int hal_initialized = HAL_INITIALIZED_NOT;
 
 int hal_device_power_get_backend(void)
 {
@@ -31,11 +30,9 @@ int hal_device_power_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_POWER, (void **)&hal_device_power_funcs);
        if (ret < 0) {
                _E("Failed to get device power backend");
-               hal_initialized = HAL_INITIALIZED_FAILED;
                return ret;
        }
 
-       hal_initialized = HAL_INITIALIZED_SUCCEEDED;
        return 0;
 }
 
@@ -52,7 +49,6 @@ int hal_device_power_put_backend(void)
        }
 
        hal_device_power_funcs = NULL;
-       hal_initialized = HAL_INITIALIZED_NOT;
 
        return 0;
 }
@@ -61,7 +57,7 @@ int hal_device_power_get_wakeup_reason(enum hal_device_power_transition_reason *
 {
        int ret;
 
-       if (!hal_device_power_funcs && !hal_initialized) {
+       if (!hal_device_power_funcs) {
                if ((ret = hal_device_power_get_backend()) < 0)
                        return ret;
        }
index 6e056e461871401d08bf903ea3b14ea683817bca..2958df03f9487739d967f63e569ac675aec144c8 100644 (file)
 #include "hal-thermal-interface.h"
 
 static hal_backend_thermal_funcs *hal_thermal_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_thermal_get_backend(void)
 {
@@ -37,11 +31,9 @@ int hal_device_thermal_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_THERMAL, (void **)&hal_thermal_funcs);
        if (ret < 0) {
                 _E("Failed to get thermal backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -52,7 +44,6 @@ int hal_device_thermal_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_THERMAL, (void *)hal_thermal_funcs);
        hal_thermal_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -61,7 +52,7 @@ int hal_device_thermal_get_info(hal_device_thermal_e type, struct thermal_info *
 {
        int ret;
 
-       if (!hal_thermal_funcs && !hal_initialized) {
+       if (!hal_thermal_funcs) {
                if ((ret = hal_device_thermal_get_backend()) < 0)
                        return ret;
        }
@@ -77,7 +68,7 @@ int hal_device_thermal_register_changed_event(ThermalUpdated updated_cb, void *d
 {
        int ret;
 
-       if (!hal_thermal_funcs && !hal_initialized) {
+       if (!hal_thermal_funcs) {
                if ((ret = hal_device_thermal_get_backend()) < 0)
                        return ret;
        }
@@ -93,7 +84,7 @@ int hal_device_thermal_unregister_changed_event(ThermalUpdated updated_cb)
 {
        int ret;
 
-       if (!hal_thermal_funcs && !hal_initialized) {
+       if (!hal_thermal_funcs) {
                if ((ret = hal_device_thermal_get_backend()) < 0)
                        return ret;
        }
index d4e05603ead532217323b70c72336eed09c7600b..b920b71d90c1abf85fd56543a861cee31acb4951 100644 (file)
 #include "common.h"
 
 static hal_backend_touchscreen_funcs *hal_touchscreen_funcs = NULL;
-/*
--1 : failed to initialize
-0  : not initialized
-1  : succeeded to initialize
-*/
-static int hal_initialized = 0;
 
 int hal_device_touchscreen_get_backend(void)
 {
@@ -39,11 +33,9 @@ int hal_device_touchscreen_get_backend(void)
        ret = hal_common_get_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void **)&hal_touchscreen_funcs);
        if (ret < 0) {
                 _E("Failed to get touchscreen backend");
-               hal_initialized = -1;
                return -EINVAL;
        }
 
-       hal_initialized = 1;
        return 0;
 }
 
@@ -54,7 +46,6 @@ int hal_device_touchscreen_put_backend(void)
 
        hal_common_put_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void *)hal_touchscreen_funcs);
        hal_touchscreen_funcs = NULL;
-       hal_initialized = 0;
 
        return 0;
 }
@@ -64,7 +55,7 @@ int hal_device_touchscreen_get_state(enum touchscreen_state *state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }
@@ -80,7 +71,7 @@ int hal_device_touchscreen_set_state(enum touchscreen_state state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }
@@ -96,7 +87,7 @@ int hal_device_touchscreen_get_powersaving(int *state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }
@@ -112,7 +103,7 @@ int hal_device_touchscreen_set_powersaving(int state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }
@@ -128,7 +119,7 @@ int hal_device_touchscreen_glove_mode_get_state(int *state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }
@@ -144,7 +135,7 @@ int hal_device_touchscreen_glove_mode_set_state(int state)
 {
        int ret;
 
-       if (!hal_touchscreen_funcs && !hal_initialized) {
+       if (!hal_touchscreen_funcs) {
                if ((ret = hal_device_touchscreen_get_backend()) < 0)
                        return ret;
        }