From e08a28b380c50d9349b3b5c7e22d4780a6521e2c Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Wed, 10 Jul 2024 13:39:59 +0900 Subject: [PATCH] Apply multi-hal interface Change-Id: Ie5cdadb337444132fe992e8158324c31178a4f6f --- src/hal-api-bluetooth.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/hal-api-bluetooth.c b/src/hal-api-bluetooth.c index a51f988..cab1988 100644 --- a/src/hal-api-bluetooth.c +++ b/src/hal-api-bluetooth.c @@ -17,51 +17,48 @@ static hal_backend_bluetooth_funcs *g_bluetooth_funcs = NULL; -EXPORT -int hal_bluetooth_get_backend(void) +EXPORT int hal_bluetooth_get_backend(void) { int ret; if (g_bluetooth_funcs) return 0; + g_bluetooth_funcs = calloc(1, sizeof(hal_backend_bluetooth_funcs)); + if (!g_bluetooth_funcs) + return -ENOMEM; + ret = hal_common_get_backend(HAL_MODULE_BLUETOOTH, (void **)&g_bluetooth_funcs); if (ret < 0) { - _E("Failed to get backend\n"); - return -EINVAL; + free(g_bluetooth_funcs); + g_bluetooth_funcs = NULL; + return -ENOTSUP; } return 0; } -EXPORT -int hal_bluetooth_put_backend(void) +EXPORT int hal_bluetooth_put_backend(void) { - int ret; - if (!g_bluetooth_funcs) return -EINVAL; - ret = hal_common_put_backend(HAL_MODULE_BLUETOOTH, (void *)g_bluetooth_funcs); - if (ret < 0) { - _E("Failed to put backend\n"); - return -EINVAL; - } + hal_common_put_backend(HAL_MODULE_BLUETOOTH, (void *)g_bluetooth_funcs); + + free(g_bluetooth_funcs); g_bluetooth_funcs = NULL; return 0; } -EXPORT -int hal_bluetooth_start(void) +EXPORT int hal_bluetooth_start(void) { if (!g_bluetooth_funcs) return -ENOTSUP; return g_bluetooth_funcs->start(); } -EXPORT -int hal_bluetooth_stop(void) +EXPORT int hal_bluetooth_stop(void) { if (!g_bluetooth_funcs) return -ENOTSUP; -- 2.7.4