summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]src/hal-api-uwb.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/hal-api-uwb.c b/src/hal-api-uwb.c
index b2c3b06..e045d93 100755..100644
--- a/src/hal-api-uwb.c
+++ b/src/hal-api-uwb.c
@@ -43,10 +43,15 @@ int hal_uwb_get_backend(void)
if (g_uwb_funcs)
return 0;
+ g_uwb_funcs = calloc(1, sizeof(hal_backend_uwb_funcs));
+ if (!g_uwb_funcs)
+ return -ENOMEM;
+
ret = hal_common_get_backend(HAL_MODULE_UWB, (void **)&g_uwb_funcs);
if (ret < 0) {
- _E("Failed to get backend\n");
- return -EINVAL;
+ free(g_uwb_funcs);
+ g_uwb_funcs = NULL;
+ return -ENOTSUP;
}
return 0;
@@ -55,16 +60,12 @@ int hal_uwb_get_backend(void)
EXPORT
int hal_uwb_put_backend(void)
{
- int ret;
-
if (!g_uwb_funcs)
return -EINVAL;
- ret = hal_common_put_backend(HAL_MODULE_UWB, (void *)g_uwb_funcs);
- if (ret < 0) {
- _E("Failed to put backend\n");
- return -EINVAL;
- }
+ hal_common_put_backend(HAL_MODULE_UWB, (void *)g_uwb_funcs);
+
+ free(g_uwb_funcs);
g_uwb_funcs = NULL;
return 0;