aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:51 -0400
committerMarcel Holtmann <marcel@holtmann.org>2008-07-14 14:13:51 -0400
commit7d0db0a373195385a2e0b19d1f5e4b186fdcffac (patch)
tree4e82fafd39eb0a32bfb0a340302dd0baf15410e0 /net/bluetooth
parent43cbeee9f9b26300275e4e2d55ed1607f8c5f760 (diff)
[Bluetooth] Use a more unique bus name for connections
When attaching Bluetooth low-level connections to the bus, the bus name is constructed from the remote address since at that time the connection handle is not assigned yet. This has worked so far, but also caused a lot of troubles. It is better to postpone the creation of the sysfs entry to the time when the connection actually has been established and then use its connection handle as unique identifier. This also fixes the case where two different adapters try to connect to the same remote device. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_conn.c8
-rw-r--r--net/bluetooth/hci_event.c7
-rw-r--r--net/bluetooth/hci_sysfs.c8
3 files changed, 14 insertions, 9 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0d4b8aeb8e09..ca8d05245ca0 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -245,8 +245,6 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
245 if (hdev->notify) 245 if (hdev->notify)
246 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD); 246 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
247 247
248 hci_conn_add_sysfs(conn);
249
250 tasklet_enable(&hdev->tx_task); 248 tasklet_enable(&hdev->tx_task);
251 249
252 return conn; 250 return conn;
@@ -278,12 +276,14 @@ int hci_conn_del(struct hci_conn *conn)
278 } 276 }
279 277
280 tasklet_disable(&hdev->tx_task); 278 tasklet_disable(&hdev->tx_task);
279
281 hci_conn_hash_del(hdev, conn); 280 hci_conn_hash_del(hdev, conn);
282 if (hdev->notify) 281 if (hdev->notify)
283 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); 282 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
283
284 tasklet_enable(&hdev->tx_task); 284 tasklet_enable(&hdev->tx_task);
285
285 skb_queue_purge(&conn->data_q); 286 skb_queue_purge(&conn->data_q);
286 hci_conn_del_sysfs(conn);
287 287
288 return 0; 288 return 0;
289} 289}
@@ -532,6 +532,8 @@ void hci_conn_hash_flush(struct hci_dev *hdev)
532 532
533 c->state = BT_CLOSED; 533 c->state = BT_CLOSED;
534 534
535 hci_conn_del_sysfs(c);
536
535 hci_proto_disconn_ind(c, 0x16); 537 hci_proto_disconn_ind(c, 0x16);
536 hci_conn_del(c); 538 hci_conn_del(c);
537 } 539 }
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 64668e2656a5..0e3db289f4be 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -874,6 +874,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
874 } else 874 } else
875 conn->state = BT_CONNECTED; 875 conn->state = BT_CONNECTED;
876 876
877 hci_conn_add_sysfs(conn);
878
877 if (test_bit(HCI_AUTH, &hdev->flags)) 879 if (test_bit(HCI_AUTH, &hdev->flags))
878 conn->link_mode |= HCI_LM_AUTH; 880 conn->link_mode |= HCI_LM_AUTH;
879 881
@@ -1011,6 +1013,9 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
1011 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1013 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
1012 if (conn) { 1014 if (conn) {
1013 conn->state = BT_CLOSED; 1015 conn->state = BT_CLOSED;
1016
1017 hci_conn_del_sysfs(conn);
1018
1014 hci_proto_disconn_ind(conn, ev->reason); 1019 hci_proto_disconn_ind(conn, ev->reason);
1015 hci_conn_del(conn); 1020 hci_conn_del(conn);
1016 } 1021 }
@@ -1643,6 +1648,8 @@ static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_bu
1643 if (!ev->status) { 1648 if (!ev->status) {
1644 conn->handle = __le16_to_cpu(ev->handle); 1649 conn->handle = __le16_to_cpu(ev->handle);
1645 conn->state = BT_CONNECTED; 1650 conn->state = BT_CONNECTED;
1651
1652 hci_conn_add_sysfs(conn);
1646 } else 1653 } else
1647 conn->state = BT_CLOSED; 1654 conn->state = BT_CLOSED;
1648 1655
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index a18871e01582..844ca5f1b2d4 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -311,7 +311,6 @@ static void add_conn(struct work_struct *work)
311void hci_conn_add_sysfs(struct hci_conn *conn) 311void hci_conn_add_sysfs(struct hci_conn *conn)
312{ 312{
313 struct hci_dev *hdev = conn->hdev; 313 struct hci_dev *hdev = conn->hdev;
314 bdaddr_t *ba = &conn->dst;
315 314
316 BT_DBG("conn %p", conn); 315 BT_DBG("conn %p", conn);
317 316
@@ -320,11 +319,8 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
320 319
321 conn->dev.release = bt_release; 320 conn->dev.release = bt_release;
322 321
323 snprintf(conn->dev.bus_id, BUS_ID_SIZE, 322 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d",
324 "%s%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X", 323 hdev->name, conn->handle);
325 conn->type == ACL_LINK ? "acl" : "sco",
326 ba->b[5], ba->b[4], ba->b[3],
327 ba->b[2], ba->b[1], ba->b[0]);
328 324
329 dev_set_drvdata(&conn->dev, conn); 325 dev_set_drvdata(&conn->dev, conn);
330 326