From 3fbd0bda53e00fbdc2b4bf3d04b32f685b495736 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 4 Apr 2014 01:00:56 -0700 Subject: [PATCH] shared: Create generic helper for allocating HCI structure --- src/shared/hci.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/shared/hci.c b/src/shared/hci.c index cf677c092..6d0a5f86c 100644 --- a/src/shared/hci.c +++ b/src/shared/hci.c @@ -285,7 +285,7 @@ static bool io_read_callback(struct io *io, void *user_data) return true; } -struct bt_hci *bt_hci_new(int fd) +static struct bt_hci *create_hci(int fd) { struct bt_hci *hci; @@ -344,6 +344,17 @@ struct bt_hci *bt_hci_new(int fd) return bt_hci_ref(hci); } +struct bt_hci *bt_hci_new(int fd) +{ + struct bt_hci *hci; + + hci = create_hci(fd); + if (!hci) + return NULL; + + return hci; +} + static int create_socket(uint16_t index, uint16_t channel) { struct sockaddr_hci addr; @@ -376,7 +387,7 @@ struct bt_hci *bt_hci_new_user_channel(uint16_t index) if (fd < 0) return NULL; - hci = bt_hci_new(fd); + hci = create_hci(fd); if (!hci) { close(fd); return NULL; @@ -409,7 +420,7 @@ struct bt_hci *bt_hci_new_raw_device(uint16_t index) return NULL; } - hci = bt_hci_new(fd); + hci = create_hci(fd); if (!hci) { close(fd); return NULL; -- 2.47.3