Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/holtmann/bluetooth-2.6

+61 -31
+1
include/net/bluetooth/hci.h
··· 101 /* HCI timeouts */ 102 #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ 103 #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ 104 #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 105 #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 106
··· 101 /* HCI timeouts */ 102 #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ 103 #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ 104 + #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ 105 #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 106 #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 107
+5 -3
include/net/bluetooth/hci_core.h
··· 171 __u8 auth_type; 172 __u8 sec_level; 173 __u8 power_save; 174 unsigned long pend; 175 176 unsigned int sent; ··· 181 struct timer_list disc_timer; 182 struct timer_list idle_timer; 183 184 - struct work_struct work; 185 186 struct device dev; 187 ··· 350 if (conn->type == ACL_LINK) { 351 del_timer(&conn->idle_timer); 352 if (conn->state == BT_CONNECTED) { 353 - timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT); 354 if (!conn->out) 355 - timeo *= 5; 356 } else 357 timeo = msecs_to_jiffies(10); 358 } else
··· 171 __u8 auth_type; 172 __u8 sec_level; 173 __u8 power_save; 174 + __u16 disc_timeout; 175 unsigned long pend; 176 177 unsigned int sent; ··· 180 struct timer_list disc_timer; 181 struct timer_list idle_timer; 182 183 + struct work_struct work_add; 184 + struct work_struct work_del; 185 186 struct device dev; 187 ··· 348 if (conn->type == ACL_LINK) { 349 del_timer(&conn->idle_timer); 350 if (conn->state == BT_CONNECTED) { 351 + timeo = msecs_to_jiffies(conn->disc_timeout); 352 if (!conn->out) 353 + timeo *= 2; 354 } else 355 timeo = msecs_to_jiffies(10); 356 } else
+4 -6
net/bluetooth/hci_conn.c
··· 215 conn->state = BT_OPEN; 216 217 conn->power_save = 1; 218 219 switch (type) { 220 case ACL_LINK: ··· 425 if (sec_level == BT_SECURITY_SDP) 426 return 1; 427 428 - if (sec_level == BT_SECURITY_LOW) { 429 - if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) 430 - return hci_conn_auth(conn, sec_level, auth_type); 431 - else 432 - return 1; 433 - } 434 435 if (conn->link_mode & HCI_LM_ENCRYPT) 436 return hci_conn_auth(conn, sec_level, auth_type);
··· 215 conn->state = BT_OPEN; 216 217 conn->power_save = 1; 218 + conn->disc_timeout = HCI_DISCONN_TIMEOUT; 219 220 switch (type) { 221 case ACL_LINK: ··· 424 if (sec_level == BT_SECURITY_SDP) 425 return 1; 426 427 + if (sec_level == BT_SECURITY_LOW && 428 + (!conn->ssp_mode || !conn->hdev->ssp_mode)) 429 + return 1; 430 431 if (conn->link_mode & HCI_LM_ENCRYPT) 432 return hci_conn_auth(conn, sec_level, auth_type);
+35 -1
net/bluetooth/hci_event.c
··· 883 if (conn->type == ACL_LINK) { 884 conn->state = BT_CONFIG; 885 hci_conn_hold(conn); 886 } else 887 conn->state = BT_CONNECTED; 888 ··· 1064 hci_proto_connect_cfm(conn, ev->status); 1065 hci_conn_put(conn); 1066 } 1067 - } else 1068 hci_auth_cfm(conn, ev->status); 1069 1070 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { 1071 if (!ev->status) { ··· 1485 1486 static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 1487 { 1488 BT_DBG("%s", hdev->name); 1489 } 1490 1491 static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) ··· 1509 1510 static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) 1511 { 1512 BT_DBG("%s", hdev->name); 1513 } 1514 1515 static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb)
··· 883 if (conn->type == ACL_LINK) { 884 conn->state = BT_CONFIG; 885 hci_conn_hold(conn); 886 + conn->disc_timeout = HCI_DISCONN_TIMEOUT; 887 } else 888 conn->state = BT_CONNECTED; 889 ··· 1063 hci_proto_connect_cfm(conn, ev->status); 1064 hci_conn_put(conn); 1065 } 1066 + } else { 1067 hci_auth_cfm(conn, ev->status); 1068 + 1069 + hci_conn_hold(conn); 1070 + conn->disc_timeout = HCI_DISCONN_TIMEOUT; 1071 + hci_conn_put(conn); 1072 + } 1073 1074 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { 1075 if (!ev->status) { ··· 1479 1480 static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 1481 { 1482 + struct hci_ev_pin_code_req *ev = (void *) skb->data; 1483 + struct hci_conn *conn; 1484 + 1485 BT_DBG("%s", hdev->name); 1486 + 1487 + hci_dev_lock(hdev); 1488 + 1489 + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1490 + if (conn) { 1491 + hci_conn_hold(conn); 1492 + conn->disc_timeout = HCI_PAIRING_TIMEOUT; 1493 + hci_conn_put(conn); 1494 + } 1495 + 1496 + hci_dev_unlock(hdev); 1497 } 1498 1499 static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) ··· 1489 1490 static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) 1491 { 1492 + struct hci_ev_link_key_notify *ev = (void *) skb->data; 1493 + struct hci_conn *conn; 1494 + 1495 BT_DBG("%s", hdev->name); 1496 + 1497 + hci_dev_lock(hdev); 1498 + 1499 + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1500 + if (conn) { 1501 + hci_conn_hold(conn); 1502 + conn->disc_timeout = HCI_DISCONN_TIMEOUT; 1503 + hci_conn_put(conn); 1504 + } 1505 + 1506 + hci_dev_unlock(hdev); 1507 } 1508 1509 static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb)
+16 -21
net/bluetooth/hci_sysfs.c
··· 9 struct class *bt_class = NULL; 10 EXPORT_SYMBOL_GPL(bt_class); 11 12 - static struct workqueue_struct *btaddconn; 13 - static struct workqueue_struct *btdelconn; 14 15 static inline char *link_typetostr(int type) 16 { ··· 87 88 static void add_conn(struct work_struct *work) 89 { 90 - struct hci_conn *conn = container_of(work, struct hci_conn, work); 91 92 - flush_workqueue(btdelconn); 93 94 if (device_add(&conn->dev) < 0) { 95 BT_ERR("Failed to register connection device"); ··· 114 115 device_initialize(&conn->dev); 116 117 - INIT_WORK(&conn->work, add_conn); 118 119 - queue_work(btaddconn, &conn->work); 120 } 121 122 /* ··· 131 132 static void del_conn(struct work_struct *work) 133 { 134 - struct hci_conn *conn = container_of(work, struct hci_conn, work); 135 struct hci_dev *hdev = conn->hdev; 136 137 while (1) { 138 struct device *dev; ··· 159 if (!device_is_registered(&conn->dev)) 160 return; 161 162 - INIT_WORK(&conn->work, del_conn); 163 164 - queue_work(btdelconn, &conn->work); 165 } 166 167 static inline char *host_typetostr(int type) ··· 438 439 int __init bt_sysfs_init(void) 440 { 441 - btaddconn = create_singlethread_workqueue("btaddconn"); 442 - if (!btaddconn) 443 return -ENOMEM; 444 - 445 - btdelconn = create_singlethread_workqueue("btdelconn"); 446 - if (!btdelconn) { 447 - destroy_workqueue(btaddconn); 448 - return -ENOMEM; 449 - } 450 451 bt_class = class_create(THIS_MODULE, "bluetooth"); 452 if (IS_ERR(bt_class)) { 453 - destroy_workqueue(btdelconn); 454 - destroy_workqueue(btaddconn); 455 return PTR_ERR(bt_class); 456 } 457 ··· 453 454 void bt_sysfs_cleanup(void) 455 { 456 - destroy_workqueue(btaddconn); 457 - destroy_workqueue(btdelconn); 458 459 class_destroy(bt_class); 460 }
··· 9 struct class *bt_class = NULL; 10 EXPORT_SYMBOL_GPL(bt_class); 11 12 + static struct workqueue_struct *bluetooth; 13 14 static inline char *link_typetostr(int type) 15 { ··· 88 89 static void add_conn(struct work_struct *work) 90 { 91 + struct hci_conn *conn = container_of(work, struct hci_conn, work_add); 92 93 + /* ensure previous add/del is complete */ 94 + flush_workqueue(bluetooth); 95 96 if (device_add(&conn->dev) < 0) { 97 BT_ERR("Failed to register connection device"); ··· 114 115 device_initialize(&conn->dev); 116 117 + INIT_WORK(&conn->work_add, add_conn); 118 119 + queue_work(bluetooth, &conn->work_add); 120 } 121 122 /* ··· 131 132 static void del_conn(struct work_struct *work) 133 { 134 + struct hci_conn *conn = container_of(work, struct hci_conn, work_del); 135 struct hci_dev *hdev = conn->hdev; 136 + 137 + /* ensure previous add/del is complete */ 138 + flush_workqueue(bluetooth); 139 140 while (1) { 141 struct device *dev; ··· 156 if (!device_is_registered(&conn->dev)) 157 return; 158 159 + INIT_WORK(&conn->work_del, del_conn); 160 161 + queue_work(bluetooth, &conn->work_del); 162 } 163 164 static inline char *host_typetostr(int type) ··· 435 436 int __init bt_sysfs_init(void) 437 { 438 + bluetooth = create_singlethread_workqueue("bluetooth"); 439 + if (!bluetooth) 440 return -ENOMEM; 441 442 bt_class = class_create(THIS_MODULE, "bluetooth"); 443 if (IS_ERR(bt_class)) { 444 + destroy_workqueue(bluetooth); 445 return PTR_ERR(bt_class); 446 } 447 ··· 457 458 void bt_sysfs_cleanup(void) 459 { 460 + destroy_workqueue(bluetooth); 461 462 class_destroy(bt_class); 463 }