#include <stdint.h>
#include <stdbool.h>
#include <dlfcn.h>
-#include <dlog.h>
#include <dirent.h>
#define _GNU_SOURCE
/* Check parameter whether is valid or not */
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid parameter of HAL module (%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
if (_hal_api_conf_init())
- return TIZEN_ERROR_UNKNOWN;
+ return -EINVAL;
info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto out;
}
library_name = get_backend_library_name(info);
if (!library_name) {
_E("%s backend library name is NULL\n", info->module_name);
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
len_library_name = strlen(library_name);
if (!name || (len_library_name + 1 > size)) {
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
name = NULL;
goto out;
}
strncpy(name, library_name, len_library_name);
name[len_library_name] = '\0';
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
out:
_hal_api_conf_exit();
/* Check parameter whether is valid or not */
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid paramer of HAL module (%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
if (_hal_api_conf_init())
- return TIZEN_ERROR_UNKNOWN;
+ return -EINVAL;
info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto out;
}
symbol_name = info->symbol_name;
if (!symbol_name) {
_E("%s backend symbol name is NULL\n", info->module_name);
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
len_symbol_name = strlen(symbol_name);
if (!name || (len_symbol_name + 1 > size)) {
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
name = NULL;
goto out;
}
strncpy(name, symbol_name, len_symbol_name);
name[len_symbol_name] = '\0';
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
out:
_hal_api_conf_exit();
if (!backend_library_name) {
_E("%s: Failed to get backend library name\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
if (!info->symbol_name) {
_E("%s: Failed to get backend symbol name\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
if (!info->handle) {
_E("%s: Failed to load backend library (%s)\n",
info->module_name, dlerror());
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
if (!info->backend) {
_E("%s: Failed to find backend data (%s)\n",
info->module_name, dlerror());
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_dlclose;
}
if (!info->handle || !info->backend) {
_I("%s: Has not yet dlopend backend\n", info->module_name);
- return TIZEN_ERROR_NONE;
+ return 0;
}
if (!info->backend->init) {
_E("%s: hal_backend->init() is NULL\n", info->module_name);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
/* Check HAL ABI Version */
info->backend->abi_version);
if (ret < 0) {
_E("%s: Failed to check ABI version\n", info->module_name);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
/* Initialize backend */
_E("%s: Failed to initialize backend: name(%s)/vendor(%s)\n",
info->module_name, info->backend->name,
info->backend->vendor);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
- return TIZEN_ERROR_NONE;
+ return 0;
}
static int __exit_backend(struct __hal_module_info *info, void *data,
if (!info->handle || !info->backend) {
_I("%s: Has not yet dlopend backend\n", info->module_name);
- return TIZEN_ERROR_NONE;
+ return 0;
}
/* Exit backend */
_E("%s: Failed to exit backend: name(%s)/vendor(%s)\n",
info->module_name, info->backend->name,
info->backend->vendor);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
}
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid parameter of HAL module (%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
G_LOCK(hal_common_lock);
if (_hal_api_conf_init()) {
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto err;
}
else
_E("Failed to get HAL module(%d) information (%s)\n",
module, library_name);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto err;
}
if (ret < 0) {
_E("%s: Failed to get the backend library by dlopen\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
if (ret < 0) {
_E("%s: Failed to initialize the backend library\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_dlclose;
}
program_invocation_name);
G_UNLOCK(hal_common_lock);
- return TIZEN_ERROR_NONE;
+ return 0;
err_dlclose:
_hal_api_conf_exit();
/* Check parameter whether is valid or not */
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid parameter of HAL module (%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
G_LOCK(hal_common_lock);
info = _hal_api_conf_get_module_info(module, library_name);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto out;
}
if (!info->handle || !info->backend) {
_I("%s: Has not yet dlopend backend\n", info->module_name);
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
if (!info->usage_count) {
_I("%s: Already fully put for HAL module\n", info->module_name);
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
if (ret < 0) {
_E("%s: Failed to exit the backend library\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto out;
}
program_invocation_name);
if (info->usage_count > 0) {
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
__close_backend(info);
_hal_api_conf_exit();
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
out:
G_UNLOCK(hal_common_lock);
if (ret < 0) {
_E("%s: Failed to get the backend library by dlopen\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_conf_exit;
}
if (!info->backend->name || (len + 1 > name_size)) {
_E("%s: Invalid size of name[] array\n", info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_conf_exit;
}
if (!info->backend->vendor || (len + 1 > vendor_size)) {
_E("%s: Invalid size of vendor[] array\n", info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_conf_exit;
}
vendor[len] = '\0';
} else {
_E("%s: Failed to get backend data\n", info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_conf_exit;
}
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
err_conf_exit:
_hal_api_conf_exit();
/* Check parameter whether is valid or not */
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid paramer of HAL module(%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
if (abi_version <= HAL_ABI_VERSION_UNKNOWN
|| abi_version >= HAL_ABI_VERSION_END) {
_E("Invalid paramer of HAL ABI version(%d) for HAL module(%d)\n",
abi_version, module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
if (_hal_api_conf_init())
- return TIZEN_ERROR_UNKNOWN;
+ return -EINVAL;
info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto out;
}
/* Check abi_version whether is supported or not */
if (!info->hal_api) {
_E("%s: Doesn't support HAL API\n", info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto out;
}
|| !info->abi_versions) {
_E("%s: Doesn't have the ABI version information\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto out;
}
data->backend_min_abi_version >= HAL_ABI_VERSION_END) {
_E("%s: abi_versions[%d].backend_min_abi_version(%d) is invalid\n",
info->module_name, i, data->backend_min_abi_version);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto out;
}
if (abi_version <= data->platform_abi_version
&& abi_version >= data->backend_min_abi_version) {
- ret = TIZEN_ERROR_NONE;
+ ret = 0;
goto out;
}
hal_abi_version_str[data->backend_min_abi_version],
hal_abi_version_str[data->platform_abi_version]);
}
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
out:
_hal_api_conf_exit();
/* Check parameter whether is valid or not */
if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
_E("Invalid parameter of HAL module (%d)\n", module);
- return TIZEN_ERROR_INVALID_PARAMETER;
+ return -EINVAL;
}
if (_hal_api_conf_init())
- return TIZEN_ERROR_UNKNOWN;
+ return -EINVAL;
info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
if (info->backend_module_name == NULL) {
_E("Don't support HAL backend of HAL module(%s)\n",
info->module_name);
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err;
}
backend_module_name = g_strdup_printf("libhal-backend-%s",
if (!backend_module_name) {
_E("Failed to allocate the backend_module_name of HAL module(%s)\n",
info->module_name);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto err;
}
if (!dir) {
_E("Failed to find HAL backend path(%s) for HAL module(%s)\n",
hal_backend_path, info->module_name);
- ret = TIZEN_ERROR_UNKNOWN;
+ ret = -EINVAL;
goto err_free_backend_module_name;
}
}
if (lib_count > 0 && count != lib_count) {
- ret = TIZEN_ERROR_INVALID_PARAMETER;
+ ret = -EINVAL;
goto err_mismatch_count;
}