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>
#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
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_BATTERY, (void *)hal_battery_funcs);
hal_battery_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_battery_funcs && !hal_initialized) {
+ if (!hal_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_battery_funcs && !hal_initialized) {
+ if (!hal_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_battery_funcs && !hal_initialized) {
+ if (!hal_battery_funcs) {
if ((ret = hal_device_battery_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_BEZEL, (void *)hal_bezel_funcs);
hal_bezel_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_bezel_funcs && !hal_initialized) {
+ if (!hal_bezel_funcs) {
if ((ret = hal_device_bezel_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, (void *)hal_external_connection_funcs);
hal_external_connection_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
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;
}
{
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;
}
{
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;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_haptic_funcs && !hal_initialized) {
+ if (!hal_device_haptic_funcs) {
if ((ret = hal_device_haptic_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
}
hal_device_input_funcs = NULL;
- hal_initialized = HAL_INITIALIZED_NOT;
return 0;
}
{
int ret;
- if (!hal_device_input_funcs && !hal_initialized) {
+ if (!hal_device_input_funcs) {
if ((ret = hal_device_input_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_device_input_funcs && !hal_initialized) {
+ if (!hal_device_input_funcs) {
if ((ret = hal_device_input_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_IR, (void *)hal_ir_funcs);
hal_ir_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_ir_funcs && !hal_initialized) {
+ if (!hal_ir_funcs) {
if ((ret = hal_device_ir_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_ir_funcs && !hal_initialized) {
+ if (!hal_ir_funcs) {
if ((ret = hal_device_ir_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_LED, (void *)hal_led_funcs);
hal_led_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_led_funcs && !hal_initialized) {
+ if (!hal_led_funcs) {
if ((ret = hal_device_led_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_memory_funcs && !hal_initialized) {
+ if (!hal_memory_funcs) {
if ((ret = hal_device_memory_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_memory_funcs && !hal_initialized) {
+ if (!hal_memory_funcs) {
if ((ret = hal_device_memory_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
}
hal_device_power_funcs = NULL;
- hal_initialized = HAL_INITIALIZED_NOT;
return 0;
}
{
int ret;
- if (!hal_device_power_funcs && !hal_initialized) {
+ if (!hal_device_power_funcs) {
if ((ret = hal_device_power_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_THERMAL, (void *)hal_thermal_funcs);
hal_thermal_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_thermal_funcs && !hal_initialized) {
+ if (!hal_thermal_funcs) {
if ((ret = hal_device_thermal_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_thermal_funcs && !hal_initialized) {
+ if (!hal_thermal_funcs) {
if ((ret = hal_device_thermal_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_thermal_funcs && !hal_initialized) {
+ if (!hal_thermal_funcs) {
if ((ret = hal_device_thermal_get_backend()) < 0)
return ret;
}
#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)
{
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;
}
hal_common_put_backend(HAL_MODULE_DEVICE_TOUCHSCREEN, (void *)hal_touchscreen_funcs);
hal_touchscreen_funcs = NULL;
- hal_initialized = 0;
return 0;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}
{
int ret;
- if (!hal_touchscreen_funcs && !hal_initialized) {
+ if (!hal_touchscreen_funcs) {
if ((ret = hal_device_touchscreen_get_backend()) < 0)
return ret;
}