OSDN Git Service

Get rid of unneeded btd_adapter_get_conn_handle function
authorJohan Hedberg <johan.hedberg@nokia.com>
Sun, 19 Dec 2010 14:50:27 +0000 (16:50 +0200)
committerJohan Hedberg <johan.hedberg@nokia.com>
Sun, 19 Dec 2010 14:50:27 +0000 (16:50 +0200)
health/mcap_sync.c
plugins/hciops.c
plugins/mgmtops.c
src/adapter.c
src/adapter.h

index a7f6adb..6f90344 100644 (file)
@@ -246,7 +246,7 @@ static gboolean valid_btclock(uint32_t btclk)
 static gboolean read_btclock(struct mcap_mcl *mcl, uint32_t *btclock,
                                                        uint16_t *btaccuracy)
 {
-       int ret, handle, which = 1;
+       int which = 1;
        struct btd_adapter *adapter;
 
        adapter = manager_find_adapter(&mcl->mi->src);
@@ -254,13 +254,11 @@ static gboolean read_btclock(struct mcap_mcl *mcl, uint32_t *btclock,
        if (!adapter)
                return FALSE;
 
-       if (btd_adapter_get_conn_handle(adapter, &mcl->addr, &handle))
+       if (btd_adapter_read_clock(adapter, &mcl->addr, which, 1000,
+                                               btclock, btaccuracy) < 0)
                return FALSE;
 
-       ret = btd_adapter_read_clock(adapter, handle, which, 1000, btclock,
-                                                               btaccuracy);
-
-       return ret < 0 ? FALSE : TRUE;
+       return TRUE;
 }
 
 static gboolean read_btclock_retry(struct mcap_mcl *mcl, uint32_t *btclock,
index 65b7422..62c6684 100644 (file)
@@ -613,6 +613,33 @@ static inline int get_bdaddr(int index, uint16_t handle, bdaddr_t *dba)
        return -ENOENT;
 }
 
+static int get_handle(int index, const bdaddr_t *bdaddr, uint16_t *handle)
+{
+       struct dev_info *dev = &devs[index];
+       struct hci_conn_info_req *cr;
+       char addr[18];
+       int err;
+
+       ba2str(bdaddr, addr);
+       DBG("hci%d dba %s", index, addr);
+
+       cr = g_malloc0(sizeof(*cr) + sizeof(struct hci_conn_info));
+       bacpy(&cr->bdaddr, bdaddr);
+       cr->type = ACL_LINK;
+
+       if (ioctl(dev->sk, HCIGETCONNINFO, (unsigned long) cr) < 0) {
+               err = -errno;
+               goto fail;
+       }
+
+       err = 0;
+       *handle = cr->conn_info->handle;
+
+fail:
+       g_free(cr);
+       return err;
+}
+
 /* Link Key handling */
 
 static void link_key_request(int index, bdaddr_t *dba)
@@ -2704,14 +2731,21 @@ static int hciops_fast_connectable(int index, gboolean enable)
        return 0;
 }
 
-static int hciops_read_clock(int index, uint16_t handle, int which,
+static int hciops_read_clock(int index, bdaddr_t *bdaddr, int which,
                                                int timeout, uint32_t *clock,
                                                uint16_t *accuracy)
 {
        struct dev_info *dev = &devs[index];
+       uint16_t handle = 0;
+       char addr[18];
+       int ret;
 
-       DBG("hci%d handle %d which %d timeout %d", index, handle, which,
-                                                               timeout);
+       ba2str(bdaddr, addr);
+       DBG("hci%d addr %s which %d timeout %d", index, addr, which, timeout);
+
+       ret = get_handle(index, bdaddr, &handle);
+       if (ret < 0)
+               return ret;
 
        if (hci_read_clock(dev->sk, htobs(handle), which, clock, accuracy,
                                                                timeout) < 0)
@@ -2720,33 +2754,6 @@ static int hciops_read_clock(int index, uint16_t handle, int which,
        return 0;
 }
 
-static int hciops_conn_handle(int index, const bdaddr_t *bdaddr, int *handle)
-{
-       struct dev_info *dev = &devs[index];
-       struct hci_conn_info_req *cr;
-       char addr[18];
-       int err;
-
-       ba2str(bdaddr, addr);
-       DBG("hci%d dba %s", index, addr);
-
-       cr = g_malloc0(sizeof(*cr) + sizeof(struct hci_conn_info));
-       bacpy(&cr->bdaddr, bdaddr);
-       cr->type = ACL_LINK;
-
-       if (ioctl(dev->sk, HCIGETCONNINFO, (unsigned long) cr) < 0) {
-               err = -errno;
-               goto fail;
-       }
-
-       err = 0;
-       *handle = cr->conn_info->handle;
-
-fail:
-       g_free(cr);
-       return err;
-}
-
 static int hciops_read_bdaddr(int index, bdaddr_t *bdaddr)
 {
        struct dev_info *dev = &devs[index];
@@ -3212,7 +3219,6 @@ static struct btd_adapter_ops hci_ops = {
        .set_dev_class = hciops_set_dev_class,
        .set_fast_connectable = hciops_fast_connectable,
        .read_clock = hciops_read_clock,
-       .get_conn_handle = hciops_conn_handle,
        .read_bdaddr = hciops_read_bdaddr,
        .block_device = hciops_block_device,
        .unblock_device = hciops_unblock_device,
index c728859..e640fa7 100644 (file)
@@ -580,20 +580,14 @@ static int mgmt_fast_connectable(int index, gboolean enable)
        return -ENOSYS;
 }
 
-static int mgmt_read_clock(int index, uint16_t handle, int which, int timeout,
+static int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
                                        uint32_t *clock, uint16_t *accuracy)
 {
-       DBG("index %d handle %d which %d timeout %d", index, handle,
-                                                       which, timeout);
-       return -ENOSYS;
-}
-
-static int mgmt_conn_handle(int index, const bdaddr_t *bdaddr, int *handle)
-{
        char addr[18];
 
        ba2str(bdaddr, addr);
-       DBG("index %d addr %s", index, addr);
+       DBG("index %d addr %s which %d timeout %d", index, addr, which,
+                                                               timeout);
 
        return -ENOSYS;
 }
@@ -807,7 +801,6 @@ static struct btd_adapter_ops mgmt_ops = {
        .set_dev_class = mgmt_set_dev_class,
        .set_fast_connectable = mgmt_fast_connectable,
        .read_clock = mgmt_read_clock,
-       .get_conn_handle = mgmt_conn_handle,
        .read_bdaddr = mgmt_read_bdaddr,
        .block_device = mgmt_block_device,
        .unblock_device = mgmt_unblock_device,
index 4038efb..669a0ac 100644 (file)
@@ -3307,7 +3307,7 @@ int btd_adapter_set_fast_connectable(struct btd_adapter *adapter,
        return adapter_ops->set_fast_connectable(adapter->dev_id, enable);
 }
 
-int btd_adapter_read_clock(struct btd_adapter *adapter, uint16_t handle,
+int btd_adapter_read_clock(struct btd_adapter *adapter, bdaddr_t *bdaddr,
                                int which, int timeout, uint32_t *clock,
                                uint16_t *accuracy)
 {
@@ -3317,22 +3317,10 @@ int btd_adapter_read_clock(struct btd_adapter *adapter, uint16_t handle,
        if (!adapter->up)
                return -EINVAL;
 
-       return adapter_ops->read_clock(adapter->dev_id, handle, which,
+       return adapter_ops->read_clock(adapter->dev_id, bdaddr, which,
                                                timeout, clock, accuracy);
 }
 
-int btd_adapter_get_conn_handle(struct btd_adapter *adapter,
-                               const bdaddr_t *bdaddr, int *handle)
-{
-       if (!adapter_ops)
-               return -EINVAL;
-
-       if (!adapter->up)
-               return -EINVAL;
-
-       return adapter_ops->get_conn_handle(adapter->dev_id, bdaddr, handle);
-}
-
 int btd_adapter_disconnect_device(struct btd_adapter *adapter, uint16_t handle)
 {
        return adapter_ops->disconnect(adapter->dev_id, handle);
index ec3b21d..a390088 100644 (file)
@@ -215,9 +215,8 @@ struct btd_adapter_ops {
        int (*set_name) (int index, const char *name);
        int (*set_dev_class) (int index, uint8_t major, uint8_t minor);
        int (*set_fast_connectable) (int index, gboolean enable);
-       int (*read_clock) (int index, uint16_t handle, int which, int timeout,
+       int (*read_clock) (int index, bdaddr_t *bdaddr, int which, int timeout,
                                        uint32_t *clock, uint16_t *accuracy);
-       int (*get_conn_handle) (int index, const bdaddr_t *bdaddr, int *handle);
        int (*read_bdaddr) (int index, bdaddr_t *bdaddr);
        int (*block_device) (int index, bdaddr_t *bdaddr);
        int (*unblock_device) (int index, bdaddr_t *bdaddr);
@@ -260,11 +259,9 @@ void btd_adapter_unregister_powered_callback(struct btd_adapter *adapter,
 int btd_adapter_set_fast_connectable(struct btd_adapter *adapter,
                                                        gboolean enable);
 
-int btd_adapter_read_clock(struct btd_adapter *adapter, uint16_t handle,
+int btd_adapter_read_clock(struct btd_adapter *adapter, bdaddr_t *bdaddr,
                                int which, int timeout, uint32_t *clock,
                                uint16_t *accuracy);
-int btd_adapter_get_conn_handle(struct btd_adapter *adapter,
-                               const bdaddr_t *bdaddr, int *handle);
 
 int btd_adapter_block_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 int btd_adapter_unblock_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);