Bluetooth: Remove unnecessary headers include
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / bluetooth / hci_conn.c
index 8f352cd1745a60cc574e2848442ac04785ac54bc..3bb2d552a88849468480954055679fc700615aaf 100644 (file)
 
 /* Bluetooth HCI connection handling. */
 
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/fcntl.h>
-#include <linux/init.h>
-#include <linux/skbuff.h>
-#include <linux/interrupt.h>
-#include <net/sock.h>
-
-#include <linux/uaccess.h>
-#include <asm/unaligned.h>
+#include <linux/export.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -185,7 +171,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
 }
 
 void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
-                                       u16 latency, u16 to_multiplier)
+                       u16 latency, u16 to_multiplier)
 {
        struct hci_cp_le_conn_update cp;
        struct hci_dev *hdev = conn->hdev;
@@ -205,7 +191,7 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
 EXPORT_SYMBOL(hci_le_conn_update);
 
 void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
-                                                       __u8 ltk[16])
+                     __u8 ltk[16])
 {
        struct hci_dev *hdev = conn->hdev;
        struct hci_cp_le_start_enc cp;
@@ -223,36 +209,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
 }
 EXPORT_SYMBOL(hci_le_start_enc);
 
-void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
-{
-       struct hci_dev *hdev = conn->hdev;
-       struct hci_cp_le_ltk_reply cp;
-
-       BT_DBG("%p", conn);
-
-       memset(&cp, 0, sizeof(cp));
-
-       cp.handle = cpu_to_le16(conn->handle);
-       memcpy(cp.ltk, ltk, sizeof(ltk));
-
-       hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
-}
-EXPORT_SYMBOL(hci_le_ltk_reply);
-
-void hci_le_ltk_neg_reply(struct hci_conn *conn)
-{
-       struct hci_dev *hdev = conn->hdev;
-       struct hci_cp_le_ltk_neg_reply cp;
-
-       BT_DBG("%p", conn);
-
-       memset(&cp, 0, sizeof(cp));
-
-       cp.handle = cpu_to_le16(conn->handle);
-
-       hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(cp), &cp);
-}
-
 /* Device _must_ be locked */
 void hci_sco_setup(struct hci_conn *conn, __u8 status)
 {
@@ -277,7 +233,7 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
 static void hci_conn_timeout(struct work_struct *work)
 {
        struct hci_conn *conn = container_of(work, struct hci_conn,
-                                                       disc_work.work);
+                                            disc_work.work);
        __u8 reason;
 
        BT_DBG("conn %p state %s", conn, state_to_string(conn->state));
@@ -357,7 +313,7 @@ static void hci_conn_auto_accept(unsigned long arg)
        struct hci_dev *hdev = conn->hdev;
 
        hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
-                                                               &conn->dst);
+                    &conn->dst);
 }
 
 struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
@@ -406,7 +362,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
        INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
        setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
        setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
-                                                       (unsigned long) conn);
+                   (unsigned long) conn);
 
        atomic_set(&conn->refcnt, 0);
 
@@ -455,7 +411,6 @@ int hci_conn_del(struct hci_conn *conn)
                }
        }
 
-
        hci_chan_list_flush(conn);
 
        hci_conn_hash_del(hdev, conn);
@@ -484,7 +439,8 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
        read_lock(&hci_dev_list_lock);
 
        list_for_each_entry(d, &hci_dev_list, list) {
-               if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags))
+               if (!test_bit(HCI_UP, &d->flags) ||
+                   test_bit(HCI_RAW, &d->flags))
                        continue;
 
                /* Simple routing:
@@ -513,7 +469,8 @@ EXPORT_SYMBOL(hci_get_route);
 
 /* Create SCO, ACL or LE connection.
  * Device _must_ be locked */
-struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
+                            __u8 dst_type, __u8 sec_level, __u8 auth_type)
 {
        struct hci_conn *acl;
        struct hci_conn *sco;
@@ -522,19 +479,13 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
        BT_DBG("%s dst %s", hdev->name, batostr(dst));
 
        if (type == LE_LINK) {
-               struct adv_entry *entry = NULL;
-
                le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
                if (!le) {
-                       entry = hci_find_adv_entry(hdev, dst);
-                       if (!entry)
-                               return ERR_PTR(-EHOSTUNREACH);
-
                        le = hci_conn_add(hdev, LE_LINK, dst);
                        if (!le)
                                return ERR_PTR(-ENOMEM);
 
-                       le->dst_type = entry->bdaddr_type;
+                       le->dst_type = bdaddr_to_le(dst_type);
                        hci_le_connect(le);
                }
 
@@ -580,7 +531,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
        hci_conn_hold(sco);
 
        if (acl->state == BT_CONNECTED &&
-                       (sco->state == BT_OPEN || sco->state == BT_CLOSED)) {
+           (sco->state == BT_OPEN || sco->state == BT_CLOSED)) {
                set_bit(HCI_CONN_POWER_SAVE, &acl->flags);
                hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON);
 
@@ -635,7 +586,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 
                cp.handle = cpu_to_le16(conn->handle);
                hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
-                                                       sizeof(cp), &cp);
+                            sizeof(cp), &cp);
                if (conn->key_type != 0xff)
                        set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
        }
@@ -653,7 +604,7 @@ static void hci_conn_encrypt(struct hci_conn *conn)
                cp.handle  = cpu_to_le16(conn->handle);
                cp.encrypt = 0x01;
                hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
-                                                                       &cp);
+                            &cp);
        }
 }
 
@@ -683,8 +634,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
        /* An unauthenticated combination key has sufficient security for
           security level 1 and 2. */
        if (conn->key_type == HCI_LK_UNAUTH_COMBINATION &&
-                       (sec_level == BT_SECURITY_MEDIUM ||
-                       sec_level == BT_SECURITY_LOW))
+           (sec_level == BT_SECURITY_MEDIUM || sec_level == BT_SECURITY_LOW))
                goto encrypt;
 
        /* A combination key has always sufficient security for the security
@@ -692,8 +642,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
           is generated using maximum PIN code length (16).
           For pre 2.1 units. */
        if (conn->key_type == HCI_LK_COMBINATION &&
-                       (sec_level != BT_SECURITY_HIGH ||
-                       conn->pin_length == 16))
+           (sec_level != BT_SECURITY_HIGH || conn->pin_length == 16))
                goto encrypt;
 
 auth:
@@ -736,7 +685,7 @@ int hci_conn_change_link_key(struct hci_conn *conn)
                struct hci_cp_change_conn_link_key cp;
                cp.handle = cpu_to_le16(conn->handle);
                hci_send_cmd(conn->hdev, HCI_OP_CHANGE_CONN_LINK_KEY,
-                                                       sizeof(cp), &cp);
+                            sizeof(cp), &cp);
        }
 
        return 0;
@@ -787,7 +736,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
 timer:
        if (hdev->idle_timeout > 0)
                mod_timer(&conn->idle_timer,
-                       jiffies + msecs_to_jiffies(hdev->idle_timeout));
+                         jiffies + msecs_to_jiffies(hdev->idle_timeout));
 }
 
 /* Drop all connection on the device */
@@ -837,7 +786,7 @@ EXPORT_SYMBOL(hci_conn_put_device);
 
 int hci_get_conn_list(void __user *arg)
 {
-       register struct hci_conn *c;
+       struct hci_conn *c;
        struct hci_conn_list_req req, *cl;
        struct hci_conn_info *ci;
        struct hci_dev *hdev;