summaryrefslogtreecommitdiff
path: root/src/hal-api-nfc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hal-api-nfc.c')
-rw-r--r--[-rwxr-xr-x]src/hal-api-nfc.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/hal-api-nfc.c b/src/hal-api-nfc.c
index ad25aef..30147cc 100755..100644
--- a/src/hal-api-nfc.c
+++ b/src/hal-api-nfc.c
@@ -43,10 +43,15 @@ int hal_nfc_get_backend(void)
if (g_nfc_funcs)
return 0;
+ g_nfc_funcs = calloc(1, sizeof(hal_backend_nfc_funcs));
+ if (!g_nfc_funcs)
+ return -ENOMEM;
+
ret = hal_common_get_backend(HAL_MODULE_NFC, (void **)&g_nfc_funcs);
if (ret < 0) {
- _E("Failed to get backend\n");
- return -EINVAL;
+ free(g_nfc_funcs);
+ g_nfc_funcs = NULL;
+ return -ENOTSUP;
}
return 0;
@@ -55,16 +60,12 @@ int hal_nfc_get_backend(void)
EXPORT
int hal_nfc_put_backend(void)
{
- int ret;
-
if (!g_nfc_funcs)
return -EINVAL;
- ret = hal_common_put_backend(HAL_MODULE_NFC, (void *)g_nfc_funcs);
- if (ret < 0) {
- _E("Failed to put backend\n");
- return -EINVAL;
- }
+ hal_common_put_backend(HAL_MODULE_NFC, (void *)g_nfc_funcs);
+
+ free(g_nfc_funcs);
g_nfc_funcs = NULL;
return 0;