From: Chanwoo Choi Date: Wed, 26 Jan 2022 08:52:50 +0000 (+0900) Subject: halapi: common: Remove json unused code X-Git-Tag: submit/tizen/20220208.024112~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba5af454cf4416c7b996a31159aa5e7b06f27fe0;p=platform%2Fhal%2Fapi%2Fcommon.git halapi: common: Remove json unused code Change-Id: I87aeb68c4af32542a3d3d91da360e89cfb851eb1 Signed-off-by: Chanwoo Choi --- diff --git a/include/hal-common.h b/include/hal-common.h index 1b0e328..4c197fe 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -83,61 +83,6 @@ enum hal_module { HAL_MODULE_END, }; -#ifdef HAL_API_CONF_JSON -static const char *const hal_module_string[] = { - [HAL_MODULE_UNKNOWN] = "HAL_MODULE_UNKNOWN", - - /* HAL_GROUP_GRAPHICS */ - [HAL_MODULE_TBM] = "HAL_MODULE_TBM", - [HAL_MODULE_TDM] = "HAL_MODULE_TDM", - [HAL_MODULE_COREGL] = "HAL_MODULE_COREGL", - [HAL_MODULE_INPUT] = "HAL_MODULE_INPUT", - - /* HAL_GROUP_MULTIMEDIA */ - [HAL_MODULE_AUDIO] = "HAL_MODULE_AUDIO", - [HAL_MODULE_CAMERA] = "HAL_MODULE_CAMERA", - [HAL_MODULE_RADIO] = "HAL_MODULE_RADIO", - [HAL_MODULE_CODEC] = "HAL_MODULE_CODEC", - [HAL_MODULE_USB_AUDIO] = "HAL_MODULE_USB_AUDIO", - [HAL_MODULE_ALSAUCM] = "HAL_MODULE_ALSAUCM", - - /* HAL_GROUP_CONNECTIVITY */ - [HAL_MODULE_BLUETOOTH] = "HAL_MODULE_BLUETOOTH", - [HAL_MODULE_WIFI] = "HAL_MODULE_WIFI", - [HAL_MODULE_NAN] = "HAL_MODULE_NAN", - [HAL_MODULE_NFC] = "HAL_MODULE_NFC", - [HAL_MODULE_ZIGBEE] = "HAL_MODULE_ZIGBEE", - [HAL_MODULE_UWB] = "HAL_MODULE_UWB", - [HAL_MODULE_MTP] = "HAL_MODULE_MTP", - - /* HAL_GROUP_TELEPHONY */ - [HAL_MODULE_TELEPHONY] = "HAL_MODULE_TELEPHONY", - - /* HAL_GROUP_LOCATION */ - [HAL_MODULE_LOCATION] = "HAL_MODULE_LOCATION", - - /* HAL_GROUP_SYSTEM */ - [HAL_MODULE_COMMON] = "HAL_MODULE_COMMON", - [HAL_MODULE_POWER] = "HAL_MODULE_POWER", - [HAL_MODULE_SENSOR] = "HAL_MODULE_SENSOR", - [HAL_MODULE_PERIPHERAL] = "HAL_MODULE_PERIPHERAL", - [HAL_MODULE_DEVICE_BATTERY] = "HAL_MODULE_DEVICE_BATTERY", - [HAL_MODULE_DEVICE_BEZEL] = "HAL_MODULE_DEVICE_BEZEL", - [HAL_MODULE_DEVICE_DISPLAY] = "HAL_MODULE_DEVICE_DISPLAY", - [HAL_MODULE_DEVICE_IR] = "HAL_MODULE_DEVICE_IR", - [HAL_MODULE_DEVICE_TOUCHSCREEN] = "HAL_MODULE_DEVICE_TOUCHSCREEN", - [HAL_MODULE_DEVICE_LED] = "HAL_MODULE_DEVICE_LED", - [HAL_MODULE_DEVICE_BOARD] = "HAL_MODULE_DEVICE_BOARD", - [HAL_MODULE_DEVICE_EXTERNAL_CONNECTION] = "HAL_MODULE_DEVICE_EXTERNAL_CONNECTION", - [HAL_MODULE_DEVICE_THERMAL] = "HAL_MODULE_DEVICE_THERMAL", - [HAL_MODULE_DEVICE_USB_GADGET] = "HAL_MODULE_DEVICE_USB_GADGET", - [HAL_MODULE_DEVICE_HAPTIC] = "HAL_MODULE_DEVICE_HAPTIC", - [HAL_MODULE_DEVICE_MEMORY] = "HAL_MODULE_DEVICE_MEMORY", - - [HAL_MODULE_END] = "HAL_MODULE_END", -}; -#endif - /** * @brief Get the backend library name according to the type of HAL module * @param[in] HAL module id among enum hal_moudle diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index d511354..d86f03a 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -29,12 +29,6 @@ #include "hal-api-conf.h" #include "hal-api-list.h" -#ifdef HAL_API_CONF_JSON -static enum hal_abi_version _platform_abi_version = HAL_ABI_VERSION_END; - -static json_object *_json_file_object = NULL; -#endif - static GHashTable *_module_hash = NULL; static int _usage_count = 0; @@ -63,159 +57,10 @@ do { \ } } -#ifdef HAL_API_CONF_JSON -static enum hal_abi_version __convert_abi_version_str_to_enum(const char *abi_version) { - int version; - for (version = HAL_ABI_VERSION_UNKNOWN + 1; version < HAL_ABI_VERSION_END; version++){ - if (g_strcmp0(abi_version, hal_abi_version_str[version]) == 0) - return (enum hal_abi_version)version; - } - - return HAL_ABI_VERSION_UNKNOWN; -} - -static const char *__convert_module_to_string(enum hal_module module) -{ - return hal_module_string[module]; -} - -static enum hal_group __convert_group_str_to_enum(const char * group) -{ - enum hal_group group_idx; - - for (group_idx = HAL_GROUP_UNKNOWN + 1; group_idx < HAL_GROUP_END; group_idx++) { - if (g_strcmp0(group, hal_group_string[group_idx]) == 0) - return group_idx; - } - - return HAL_GROUP_UNKNOWN; -} - -static enum hal_license __convert_license_str_to_enum(const char *license) -{ - if (g_strcmp0(license, "APACHE_2_0") == 0) - return HAL_LICENSE_APACHE_2_0; - - if (g_strcmp0(license, "FLORA") == 0) - return HAL_LICENSE_FLORA; - - if (g_strcmp0(license, "MIT") == 0) - return HAL_LICENSE_MIT; - - return HAL_LICENSE_UNKNOWN; -} - -static const char * __get_json_object_string(json_object *object, const char *key) -{ - json_object *temp_object = NULL; - - json_object_object_get_ex(object, key, &temp_object); - return json_object_get_string(temp_object); -} - -static struct __hal_module_info *__create_hal_module_info(enum hal_module module, json_object *object) -{ - struct __hal_module_info *info; - GList *abi_list = NULL; - GList *iter_list = NULL; - int list_index = 0; - json_object *abi_versions_array; - json_object *tmp_object; - const char *tmp; - - info = (struct __hal_module_info *)calloc(1, sizeof(struct __hal_module_info)); - if (info == NULL) { - _E("Out of Memory\n"); - return NULL; - } - - info->module = module; - info->module_name = g_strdup(__convert_module_to_string(module)); - info->backend_module_name = g_strdup(__convert_module_to_string(backend_module)); - - tmp = __get_json_object_string(object, "group"); - info->group = __convert_group_str_to_enum(tmp); - - tmp = __get_json_object_string(object, "license"); - info->license = __convert_license_str_to_enum(tmp); - - info->library_name = g_strdup(__get_json_object_string(object, "library_name")); - info->library_name_64bit = g_strdup(__get_json_object_string(object, "library_name_64bit")); - info->symbol_name = g_strdup(__get_json_object_string(object, "symbol_name")); - - if (info->library_name && info->library_name_64bit && info->symbol_name) - info->hal_api = true; - - json_object_object_get_ex(object, "abi_versions", &abi_versions_array); - if (json_object_get_type(abi_versions_array) != json_type_array) - return info; - - info->num_abi_versions = json_object_array_length(abi_versions_array); - if (info->num_abi_versions > 0) { - info->abi_versions = (struct hal_abi_version_match*)calloc(info->num_abi_versions, - sizeof(struct hal_abi_version_match)); - if (info->abi_versions == NULL) { - _E("Out of Memory\n"); - _destroy_module_info(info); - return NULL; - } - - for (int i = 0; i < info->num_abi_versions; i++) { - json_object *abi_object = json_object_array_get_idx(abi_versions_array, i); - - tmp = __get_json_object_string(abi_object, "platform_abi_version"); - info->abi_versions[list_index].platform_abi_version = - __convert_abi_version_str_to_enum(tmp); - - tmp = __get_json_object_string(abi_object, "backend_min_abi_version"); - info->abi_versions[list_index].backend_min_abi_version = - __convert_abi_version_str_to_enum(tmp); - list_index++; - } - } - - return info; -} - -static struct __hal_module_info* _get_module_info(enum hal_module module) -{ - struct __hal_module_info *info = NULL; - json_object *module_array_object = NULL; - const char *group_name = NULL; - const char *module_name = NULL; - int i; - - if (!_json_file_object || !_module_hash) - return NULL; - - info = (struct __hal_module_info*)g_hash_table_lookup(_module_hash, GINT_TO_POINTER(module)); - if (info != NULL) - return info; - - json_object_object_get_ex(_json_file_object, "MODULE_INFO", &module_array_object); - module_name = __convert_module_to_string(module); - - for (i = 0; i < json_object_array_length(module_array_object); i++) { - json_object *temp_object = json_object_array_get_idx(module_array_object, i); - const char *value = __get_json_object_string(temp_object, "module"); - if (g_strcmp0(value, module_name) == 0) { - info = __create_hal_module_info(module, temp_object); - if (info == NULL) - _E("Failed to create hal module info\n"); - else - g_hash_table_insert(_module_hash, GINT_TO_POINTER(module), info); - break; - } - } - - return info; -} -#else static struct __hal_module_info* _get_module_info(enum hal_module module) { return &g_hal_module_info[module]; } -#endif static struct __hal_module_info* _get_module_info_with_library_name(enum hal_module module, const char *library_name) @@ -227,11 +72,6 @@ static struct __hal_module_info* _get_module_info_with_library_name(enum hal_mod char *library_name_prefix = NULL; int ret; -#ifdef HAL_API_CONF_JSON - if (!_json_file_object) - return NULL; -#endif - if (!_module_hash | !library_name) return NULL; @@ -306,11 +146,6 @@ __attribute__ ((visibility("default"))) struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module, const char *library_name) { -#ifdef HAL_API_CONF_JSON - if (!_json_file_object) - return NULL; -#endif - if (!_module_hash) return NULL; @@ -323,24 +158,7 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module, enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) { -#ifdef HAL_API_CONF_JSON - const char *abi_version = NULL; - bool ret_initialized; - json_object *platform_obj = NULL; - - if (_platform_abi_version != HAL_ABI_VERSION_END) - return _platform_abi_version; - - if (!_json_file_object || !_module_hash) - return HAL_ABI_VERSION_UNKNOWN; - - abi_version = __get_json_object_string(_json_file_object, "PLATFORM_ABI_VERSION"); - _platform_abi_version = __convert_abi_version_str_to_enum(abi_version); - - return _platform_abi_version; -#else return g_platform_curr_abi_version; -#endif } __attribute__ ((visibility("default"))) @@ -349,29 +167,9 @@ int _hal_api_conf_init(void) if (_usage_count++ > 0) return 0; -#ifdef HAL_API_CONF_JSON - _json_file_object = json_object_from_file(HAL_CONFIGURATION_PATH); - if (_json_file_object == NULL) { - _E("Failed to parsing json configuration file : %s\n", json_util_get_last_err()); - goto err; - } -#endif - _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); return 0; - -#ifdef HAL_API_CONF_JSON -err: - _usage_count--; - - if (_module_hash) { - g_hash_table_remove_all(_module_hash); - g_hash_table_unref(_module_hash); - } - - return -EINVAL; -#endif } __attribute__ ((visibility("default"))) @@ -381,13 +179,6 @@ void _hal_api_conf_exit(void) if (_usage_count != 0) return; -#ifdef HAL_API_CONF_JSON - if (_json_file_object) { - json_object_put(_json_file_object); - _json_file_object = NULL; - } -#endif - if (_module_hash) { g_hash_table_remove_all(_module_hash); g_hash_table_unref(_module_hash);