aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_conn.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r--net/bluetooth/hci_conn.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ff04b051792d..ba5366c320da 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -317,8 +317,10 @@ static void hci_conn_timeout(struct work_struct *work)
317} 317}
318 318
319/* Enter sniff mode */ 319/* Enter sniff mode */
320static void hci_conn_enter_sniff_mode(struct hci_conn *conn) 320static void hci_conn_idle(struct work_struct *work)
321{ 321{
322 struct hci_conn *conn = container_of(work, struct hci_conn,
323 idle_work.work);
322 struct hci_dev *hdev = conn->hdev; 324 struct hci_dev *hdev = conn->hdev;
323 325
324 BT_DBG("hcon %p mode %d", conn, conn->mode); 326 BT_DBG("hcon %p mode %d", conn, conn->mode);
@@ -352,21 +354,12 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
352 } 354 }
353} 355}
354 356
355static void hci_conn_idle(unsigned long arg) 357static void hci_conn_auto_accept(struct work_struct *work)
356{
357 struct hci_conn *conn = (void *) arg;
358
359 BT_DBG("hcon %p mode %d", conn, conn->mode);
360
361 hci_conn_enter_sniff_mode(conn);
362}
363
364static void hci_conn_auto_accept(unsigned long arg)
365{ 358{
366 struct hci_conn *conn = (void *) arg; 359 struct hci_conn *conn = container_of(work, struct hci_conn,
367 struct hci_dev *hdev = conn->hdev; 360 auto_accept_work.work);
368 361
369 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst), 362 hci_send_cmd(conn->hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
370 &conn->dst); 363 &conn->dst);
371} 364}
372 365
@@ -415,9 +408,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
415 INIT_LIST_HEAD(&conn->chan_list); 408 INIT_LIST_HEAD(&conn->chan_list);
416 409
417 INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout); 410 INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
418 setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn); 411 INIT_DELAYED_WORK(&conn->auto_accept_work, hci_conn_auto_accept);
419 setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept, 412 INIT_DELAYED_WORK(&conn->idle_work, hci_conn_idle);
420 (unsigned long) conn);
421 413
422 atomic_set(&conn->refcnt, 0); 414 atomic_set(&conn->refcnt, 0);
423 415
@@ -438,11 +430,9 @@ int hci_conn_del(struct hci_conn *conn)
438 430
439 BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle); 431 BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
440 432
441 del_timer(&conn->idle_timer);
442
443 cancel_delayed_work_sync(&conn->disc_work); 433 cancel_delayed_work_sync(&conn->disc_work);
444 434 cancel_delayed_work_sync(&conn->auto_accept_work);
445 del_timer(&conn->auto_accept_timer); 435 cancel_delayed_work_sync(&conn->idle_work);
446 436
447 if (conn->type == ACL_LINK) { 437 if (conn->type == ACL_LINK) {
448 struct hci_conn *sco = conn->link; 438 struct hci_conn *sco = conn->link;
@@ -568,11 +558,12 @@ static int hci_create_le_conn(struct hci_conn *conn)
568 bacpy(&cp.peer_addr, &conn->dst); 558 bacpy(&cp.peer_addr, &conn->dst);
569 cp.peer_addr_type = conn->dst_type; 559 cp.peer_addr_type = conn->dst_type;
570 cp.own_address_type = conn->src_type; 560 cp.own_address_type = conn->src_type;
571 cp.conn_interval_min = __constant_cpu_to_le16(0x0028); 561 cp.conn_interval_min = cpu_to_le16(hdev->le_conn_min_interval);
572 cp.conn_interval_max = __constant_cpu_to_le16(0x0038); 562 cp.conn_interval_max = cpu_to_le16(hdev->le_conn_max_interval);
573 cp.supervision_timeout = __constant_cpu_to_le16(0x002a); 563 cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
574 cp.min_ce_len = __constant_cpu_to_le16(0x0000); 564 cp.min_ce_len = __constant_cpu_to_le16(0x0000);
575 cp.max_ce_len = __constant_cpu_to_le16(0x0000); 565 cp.max_ce_len = __constant_cpu_to_le16(0x0000);
566
576 hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp); 567 hci_req_add(&req, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
577 568
578 err = hci_req_run(&req, create_le_conn_complete); 569 err = hci_req_run(&req, create_le_conn_complete);
@@ -625,12 +616,7 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
625 else 616 else
626 conn->dst_type = ADDR_LE_DEV_RANDOM; 617 conn->dst_type = ADDR_LE_DEV_RANDOM;
627 618
628 if (bacmp(&conn->src, BDADDR_ANY)) { 619 conn->src_type = hdev->own_addr_type;
629 conn->src_type = ADDR_LE_DEV_PUBLIC;
630 } else {
631 bacpy(&conn->src, &hdev->static_addr);
632 conn->src_type = ADDR_LE_DEV_RANDOM;
633 }
634 620
635 conn->state = BT_CONNECT; 621 conn->state = BT_CONNECT;
636 conn->out = true; 622 conn->out = true;
@@ -922,8 +908,8 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
922 908
923timer: 909timer:
924 if (hdev->idle_timeout > 0) 910 if (hdev->idle_timeout > 0)
925 mod_timer(&conn->idle_timer, 911 queue_delayed_work(hdev->workqueue, &conn->idle_work,
926 jiffies + msecs_to_jiffies(hdev->idle_timeout)); 912 msecs_to_jiffies(hdev->idle_timeout));
927} 913}
928 914
929/* Drop all connection on the device */ 915/* Drop all connection on the device */