Apply multi-hal interface 04/314304/3 accepted/tizen/unified/20240712.160101 accepted/tizen/unified/dev/20240715.080546
authorWootak Jung <wootak.jung@samsung.com>
Wed, 10 Jul 2024 04:39:59 +0000 (13:39 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 10 Jul 2024 05:00:18 +0000 (14:00 +0900)
Change-Id: Ie5cdadb337444132fe992e8158324c31178a4f6f

src/hal-api-bluetooth.c

index a51f988..cab1988 100644 (file)
 
 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;