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;