From 6f94a3838a888a07003ddfa5c859b64fc4373ffe Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 4 Dec 2012 11:19:56 +0200 Subject: [PATCH] core: Remove event.c as middle-man for device block events --- src/event.c | 24 ------------------------ src/event.h | 2 -- src/mgmt.c | 18 ++++++++++++++++-- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/event.c b/src/event.c index 29931a3b2..783deb555 100644 --- a/src/event.c +++ b/src/event.c @@ -276,30 +276,6 @@ int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type, return 0; } -void btd_event_device_blocked(bdaddr_t *local, bdaddr_t *peer) -{ - struct btd_adapter *adapter; - struct btd_device *device; - - if (!get_adapter_and_device(local, peer, &adapter, &device, FALSE)) - return; - - if (device) - device_block(device, TRUE); -} - -void btd_event_device_unblocked(bdaddr_t *local, bdaddr_t *peer) -{ - struct btd_adapter *adapter; - struct btd_device *device; - - if (!get_adapter_and_device(local, peer, &adapter, &device, FALSE)) - return; - - if (device) - device_unblock(device, FALSE, TRUE); -} - void btd_event_device_unpaired(bdaddr_t *local, bdaddr_t *peer) { struct btd_adapter *adapter; diff --git a/src/event.h b/src/event.h index ddaa24e90..487421705 100644 --- a/src/event.h +++ b/src/event.h @@ -25,8 +25,6 @@ void btd_event_remote_name(const bdaddr_t *local, bdaddr_t *peer, const char *name); void btd_event_returned_link_key(bdaddr_t *local, bdaddr_t *peer); -void btd_event_device_blocked(bdaddr_t *local, bdaddr_t *peer); -void btd_event_device_unblocked(bdaddr_t *local, bdaddr_t *peer); void btd_event_device_unpaired(bdaddr_t *local, bdaddr_t *peer); int btd_event_link_key_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t *key, uint8_t key_type, uint8_t pin_length); diff --git a/src/mgmt.c b/src/mgmt.c index c32e756cd..961cab90e 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -1798,6 +1798,8 @@ static void mgmt_discovering(int sk, uint16_t index, void *buf, size_t len) static void mgmt_device_blocked(int sk, uint16_t index, void *buf, size_t len) { struct controller_info *info; + struct btd_adapter *adapter; + struct btd_device *device; struct mgmt_ev_device_blocked *ev = buf; char addr[18]; @@ -1816,12 +1818,19 @@ static void mgmt_device_blocked(int sk, uint16_t index, void *buf, size_t len) info = &controllers[index]; - btd_event_device_blocked(&info->bdaddr, &ev->addr.bdaddr); + if (!get_adapter_and_device(&info->bdaddr, &ev->addr.bdaddr, + &adapter, &device, false)) + return; + + if (device) + device_block(device, TRUE); } static void mgmt_device_unblocked(int sk, uint16_t index, void *buf, size_t len) { struct controller_info *info; + struct btd_adapter *adapter; + struct btd_device *device; struct mgmt_ev_device_unblocked *ev = buf; char addr[18]; @@ -1840,7 +1849,12 @@ static void mgmt_device_unblocked(int sk, uint16_t index, void *buf, size_t len) info = &controllers[index]; - btd_event_device_unblocked(&info->bdaddr, &ev->addr.bdaddr); + if (!get_adapter_and_device(&info->bdaddr, &ev->addr.bdaddr, + &adapter, &device, false)) + return; + + if (device) + device_unblock(device, FALSE, TRUE); } static void mgmt_device_unpaired(int sk, uint16_t index, void *buf, size_t len) -- 2.47.3