Loading include/net/bluetooth/hci.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,7 @@ enum { /* HCI timeouts */ /* HCI timeouts */ #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ Loading include/net/bluetooth/hci_core.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,7 @@ struct hci_conn { __u8 auth_type; __u8 auth_type; __u8 sec_level; __u8 sec_level; __u8 power_save; __u8 power_save; __u16 disc_timeout; unsigned long pend; unsigned long pend; unsigned int sent; unsigned int sent; Loading @@ -180,7 +181,8 @@ struct hci_conn { struct timer_list disc_timer; struct timer_list disc_timer; struct timer_list idle_timer; struct timer_list idle_timer; struct work_struct work; struct work_struct work_add; struct work_struct work_del; struct device dev; struct device dev; Loading Loading @@ -348,9 +350,9 @@ static inline void hci_conn_put(struct hci_conn *conn) if (conn->type == ACL_LINK) { if (conn->type == ACL_LINK) { del_timer(&conn->idle_timer); del_timer(&conn->idle_timer); if (conn->state == BT_CONNECTED) { if (conn->state == BT_CONNECTED) { timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT); timeo = msecs_to_jiffies(conn->disc_timeout); if (!conn->out) if (!conn->out) timeo *= 5; timeo *= 2; } else } else timeo = msecs_to_jiffies(10); timeo = msecs_to_jiffies(10); } else } else Loading net/bluetooth/hci_conn.c +4 −6 Original line number Original line Diff line number Diff line Loading @@ -215,6 +215,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) conn->state = BT_OPEN; conn->state = BT_OPEN; conn->power_save = 1; conn->power_save = 1; conn->disc_timeout = HCI_DISCONN_TIMEOUT; switch (type) { switch (type) { case ACL_LINK: case ACL_LINK: Loading Loading @@ -424,12 +425,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) if (sec_level == BT_SECURITY_SDP) if (sec_level == BT_SECURITY_SDP) return 1; return 1; if (sec_level == BT_SECURITY_LOW) { if (sec_level == BT_SECURITY_LOW && if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) (!conn->ssp_mode || !conn->hdev->ssp_mode)) return hci_conn_auth(conn, sec_level, auth_type); else return 1; return 1; } if (conn->link_mode & HCI_LM_ENCRYPT) if (conn->link_mode & HCI_LM_ENCRYPT) return hci_conn_auth(conn, sec_level, auth_type); return hci_conn_auth(conn, sec_level, auth_type); Loading net/bluetooth/hci_event.c +35 −1 Original line number Original line Diff line number Diff line Loading @@ -883,6 +883,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s if (conn->type == ACL_LINK) { if (conn->type == ACL_LINK) { conn->state = BT_CONFIG; conn->state = BT_CONFIG; hci_conn_hold(conn); hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; } else } else conn->state = BT_CONNECTED; conn->state = BT_CONNECTED; Loading Loading @@ -1063,9 +1064,14 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s hci_proto_connect_cfm(conn, ev->status); hci_proto_connect_cfm(conn, ev->status); hci_conn_put(conn); hci_conn_put(conn); } } } else } else { hci_auth_cfm(conn, ev->status); hci_auth_cfm(conn, ev->status); hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_put(conn); } if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { if (!ev->status) { if (!ev->status) { struct hci_cp_set_conn_encrypt cp; struct hci_cp_set_conn_encrypt cp; Loading Loading @@ -1479,7 +1485,21 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) { { struct hci_ev_pin_code_req *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (conn) { hci_conn_hold(conn); conn->disc_timeout = HCI_PAIRING_TIMEOUT; hci_conn_put(conn); } hci_dev_unlock(hdev); } } static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) Loading @@ -1489,7 +1509,21 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) { { struct hci_ev_link_key_notify *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (conn) { hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_put(conn); } hci_dev_unlock(hdev); } } static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) Loading net/bluetooth/hci_sysfs.c +16 −21 Original line number Original line Diff line number Diff line Loading @@ -9,8 +9,7 @@ struct class *bt_class = NULL; struct class *bt_class = NULL; EXPORT_SYMBOL_GPL(bt_class); EXPORT_SYMBOL_GPL(bt_class); static struct workqueue_struct *btaddconn; static struct workqueue_struct *bluetooth; static struct workqueue_struct *btdelconn; static inline char *link_typetostr(int type) static inline char *link_typetostr(int type) { { Loading Loading @@ -88,9 +87,10 @@ static struct device_type bt_link = { static void add_conn(struct work_struct *work) static void add_conn(struct work_struct *work) { { struct hci_conn *conn = container_of(work, struct hci_conn, work); struct hci_conn *conn = container_of(work, struct hci_conn, work_add); flush_workqueue(btdelconn); /* ensure previous add/del is complete */ flush_workqueue(bluetooth); if (device_add(&conn->dev) < 0) { if (device_add(&conn->dev) < 0) { BT_ERR("Failed to register connection device"); BT_ERR("Failed to register connection device"); Loading @@ -114,9 +114,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn) device_initialize(&conn->dev); device_initialize(&conn->dev); INIT_WORK(&conn->work, add_conn); INIT_WORK(&conn->work_add, add_conn); queue_work(btaddconn, &conn->work); queue_work(bluetooth, &conn->work_add); } } /* /* Loading @@ -131,9 +131,12 @@ static int __match_tty(struct device *dev, void *data) static void del_conn(struct work_struct *work) static void del_conn(struct work_struct *work) { { struct hci_conn *conn = container_of(work, struct hci_conn, work); struct hci_conn *conn = container_of(work, struct hci_conn, work_del); struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev; /* ensure previous add/del is complete */ flush_workqueue(bluetooth); while (1) { while (1) { struct device *dev; struct device *dev; Loading @@ -156,9 +159,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn) if (!device_is_registered(&conn->dev)) if (!device_is_registered(&conn->dev)) return; return; INIT_WORK(&conn->work, del_conn); INIT_WORK(&conn->work_del, del_conn); queue_work(btdelconn, &conn->work); queue_work(bluetooth, &conn->work_del); } } static inline char *host_typetostr(int type) static inline char *host_typetostr(int type) Loading Loading @@ -435,20 +438,13 @@ void hci_unregister_sysfs(struct hci_dev *hdev) int __init bt_sysfs_init(void) int __init bt_sysfs_init(void) { { btaddconn = create_singlethread_workqueue("btaddconn"); bluetooth = create_singlethread_workqueue("bluetooth"); if (!btaddconn) if (!bluetooth) return -ENOMEM; btdelconn = create_singlethread_workqueue("btdelconn"); if (!btdelconn) { destroy_workqueue(btaddconn); return -ENOMEM; return -ENOMEM; } bt_class = class_create(THIS_MODULE, "bluetooth"); bt_class = class_create(THIS_MODULE, "bluetooth"); if (IS_ERR(bt_class)) { if (IS_ERR(bt_class)) { destroy_workqueue(btdelconn); destroy_workqueue(bluetooth); destroy_workqueue(btaddconn); return PTR_ERR(bt_class); return PTR_ERR(bt_class); } } Loading @@ -457,8 +453,7 @@ int __init bt_sysfs_init(void) void bt_sysfs_cleanup(void) void bt_sysfs_cleanup(void) { { destroy_workqueue(btaddconn); destroy_workqueue(bluetooth); destroy_workqueue(btdelconn); class_destroy(bt_class); class_destroy(bt_class); } } Loading
include/net/bluetooth/hci.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,7 @@ enum { /* HCI timeouts */ /* HCI timeouts */ #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ Loading
include/net/bluetooth/hci_core.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -171,6 +171,7 @@ struct hci_conn { __u8 auth_type; __u8 auth_type; __u8 sec_level; __u8 sec_level; __u8 power_save; __u8 power_save; __u16 disc_timeout; unsigned long pend; unsigned long pend; unsigned int sent; unsigned int sent; Loading @@ -180,7 +181,8 @@ struct hci_conn { struct timer_list disc_timer; struct timer_list disc_timer; struct timer_list idle_timer; struct timer_list idle_timer; struct work_struct work; struct work_struct work_add; struct work_struct work_del; struct device dev; struct device dev; Loading Loading @@ -348,9 +350,9 @@ static inline void hci_conn_put(struct hci_conn *conn) if (conn->type == ACL_LINK) { if (conn->type == ACL_LINK) { del_timer(&conn->idle_timer); del_timer(&conn->idle_timer); if (conn->state == BT_CONNECTED) { if (conn->state == BT_CONNECTED) { timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT); timeo = msecs_to_jiffies(conn->disc_timeout); if (!conn->out) if (!conn->out) timeo *= 5; timeo *= 2; } else } else timeo = msecs_to_jiffies(10); timeo = msecs_to_jiffies(10); } else } else Loading
net/bluetooth/hci_conn.c +4 −6 Original line number Original line Diff line number Diff line Loading @@ -215,6 +215,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) conn->state = BT_OPEN; conn->state = BT_OPEN; conn->power_save = 1; conn->power_save = 1; conn->disc_timeout = HCI_DISCONN_TIMEOUT; switch (type) { switch (type) { case ACL_LINK: case ACL_LINK: Loading Loading @@ -424,12 +425,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) if (sec_level == BT_SECURITY_SDP) if (sec_level == BT_SECURITY_SDP) return 1; return 1; if (sec_level == BT_SECURITY_LOW) { if (sec_level == BT_SECURITY_LOW && if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) (!conn->ssp_mode || !conn->hdev->ssp_mode)) return hci_conn_auth(conn, sec_level, auth_type); else return 1; return 1; } if (conn->link_mode & HCI_LM_ENCRYPT) if (conn->link_mode & HCI_LM_ENCRYPT) return hci_conn_auth(conn, sec_level, auth_type); return hci_conn_auth(conn, sec_level, auth_type); Loading
net/bluetooth/hci_event.c +35 −1 Original line number Original line Diff line number Diff line Loading @@ -883,6 +883,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s if (conn->type == ACL_LINK) { if (conn->type == ACL_LINK) { conn->state = BT_CONFIG; conn->state = BT_CONFIG; hci_conn_hold(conn); hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; } else } else conn->state = BT_CONNECTED; conn->state = BT_CONNECTED; Loading Loading @@ -1063,9 +1064,14 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s hci_proto_connect_cfm(conn, ev->status); hci_proto_connect_cfm(conn, ev->status); hci_conn_put(conn); hci_conn_put(conn); } } } else } else { hci_auth_cfm(conn, ev->status); hci_auth_cfm(conn, ev->status); hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_put(conn); } if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { if (!ev->status) { if (!ev->status) { struct hci_cp_set_conn_encrypt cp; struct hci_cp_set_conn_encrypt cp; Loading Loading @@ -1479,7 +1485,21 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) { { struct hci_ev_pin_code_req *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (conn) { hci_conn_hold(conn); conn->disc_timeout = HCI_PAIRING_TIMEOUT; hci_conn_put(conn); } hci_dev_unlock(hdev); } } static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) Loading @@ -1489,7 +1509,21 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) { { struct hci_ev_link_key_notify *ev = (void *) skb->data; struct hci_conn *conn; BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name); hci_dev_lock(hdev); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (conn) { hci_conn_hold(conn); conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_put(conn); } hci_dev_unlock(hdev); } } static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) Loading
net/bluetooth/hci_sysfs.c +16 −21 Original line number Original line Diff line number Diff line Loading @@ -9,8 +9,7 @@ struct class *bt_class = NULL; struct class *bt_class = NULL; EXPORT_SYMBOL_GPL(bt_class); EXPORT_SYMBOL_GPL(bt_class); static struct workqueue_struct *btaddconn; static struct workqueue_struct *bluetooth; static struct workqueue_struct *btdelconn; static inline char *link_typetostr(int type) static inline char *link_typetostr(int type) { { Loading Loading @@ -88,9 +87,10 @@ static struct device_type bt_link = { static void add_conn(struct work_struct *work) static void add_conn(struct work_struct *work) { { struct hci_conn *conn = container_of(work, struct hci_conn, work); struct hci_conn *conn = container_of(work, struct hci_conn, work_add); flush_workqueue(btdelconn); /* ensure previous add/del is complete */ flush_workqueue(bluetooth); if (device_add(&conn->dev) < 0) { if (device_add(&conn->dev) < 0) { BT_ERR("Failed to register connection device"); BT_ERR("Failed to register connection device"); Loading @@ -114,9 +114,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn) device_initialize(&conn->dev); device_initialize(&conn->dev); INIT_WORK(&conn->work, add_conn); INIT_WORK(&conn->work_add, add_conn); queue_work(btaddconn, &conn->work); queue_work(bluetooth, &conn->work_add); } } /* /* Loading @@ -131,9 +131,12 @@ static int __match_tty(struct device *dev, void *data) static void del_conn(struct work_struct *work) static void del_conn(struct work_struct *work) { { struct hci_conn *conn = container_of(work, struct hci_conn, work); struct hci_conn *conn = container_of(work, struct hci_conn, work_del); struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev; /* ensure previous add/del is complete */ flush_workqueue(bluetooth); while (1) { while (1) { struct device *dev; struct device *dev; Loading @@ -156,9 +159,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn) if (!device_is_registered(&conn->dev)) if (!device_is_registered(&conn->dev)) return; return; INIT_WORK(&conn->work, del_conn); INIT_WORK(&conn->work_del, del_conn); queue_work(btdelconn, &conn->work); queue_work(bluetooth, &conn->work_del); } } static inline char *host_typetostr(int type) static inline char *host_typetostr(int type) Loading Loading @@ -435,20 +438,13 @@ void hci_unregister_sysfs(struct hci_dev *hdev) int __init bt_sysfs_init(void) int __init bt_sysfs_init(void) { { btaddconn = create_singlethread_workqueue("btaddconn"); bluetooth = create_singlethread_workqueue("bluetooth"); if (!btaddconn) if (!bluetooth) return -ENOMEM; btdelconn = create_singlethread_workqueue("btdelconn"); if (!btdelconn) { destroy_workqueue(btaddconn); return -ENOMEM; return -ENOMEM; } bt_class = class_create(THIS_MODULE, "bluetooth"); bt_class = class_create(THIS_MODULE, "bluetooth"); if (IS_ERR(bt_class)) { if (IS_ERR(bt_class)) { destroy_workqueue(btdelconn); destroy_workqueue(bluetooth); destroy_workqueue(btaddconn); return PTR_ERR(bt_class); return PTR_ERR(bt_class); } } Loading @@ -457,8 +453,7 @@ int __init bt_sysfs_init(void) void bt_sysfs_cleanup(void) void bt_sysfs_cleanup(void) { { destroy_workqueue(btaddconn); destroy_workqueue(bluetooth); destroy_workqueue(btdelconn); class_destroy(bt_class); class_destroy(bt_class); } }