diff options
author | Jakub Tyszkowski <jakub.tyszkowski@tieto.com> | 2013-12-05 11:37:14 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-12-08 17:47:42 +0200 |
commit | ddbd2e9e62116c88e2addcb665f836a495fa713b (patch) | |
tree | 795c8817ada8761e958192e11cfc26a0d2cf98e6 /android/hal-pan.c | |
parent | 83d88bebd74fac27346d3fd2ad8dc5b306607e20 (diff) | |
download | bluez-ddbd2e9e62116c88e2addcb665f836a495fa713b.tar.gz |
android/pan: Unregister ipc handlers if init fails
Add ipc handlers cleanup if init fails. Send proper status if
already initialized.
Diffstat (limited to 'android/hal-pan.c')
-rw-r--r-- | android/hal-pan.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/android/hal-pan.c b/android/hal-pan.c index e7b8a2091..6aaf8af2c 100644 --- a/android/hal-pan.c +++ b/android/hal-pan.c @@ -152,9 +152,13 @@ static bt_status_t pan_disconnect(const bt_bdaddr_t *bd_addr) static bt_status_t pan_init(const btpan_callbacks_t *callbacks) { struct hal_cmd_register_module cmd; + int ret; DBG(""); + if (interface_ready()) + return BT_STATUS_DONE; + cbs = callbacks; hal_ipc_register(HAL_SERVICE_ID_PAN, ev_handlers, @@ -162,8 +166,15 @@ static bt_status_t pan_init(const btpan_callbacks_t *callbacks) cmd.service_id = HAL_SERVICE_ID_PAN; - return hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, + ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, sizeof(cmd), &cmd, 0, NULL, NULL); + + if (ret != BT_STATUS_SUCCESS) { + cbs = NULL; + hal_ipc_unregister(HAL_SERVICE_ID_PAN); + } + + return ret; } static void pan_cleanup() |