diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-11-08 13:40:14 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-09 09:33:26 -0500 |
commit | 744cf19eadcf4de914394e0eb227f94f4318f5e4 (patch) | |
tree | a8c06c43be956e5db8db1bc1e052b773626892c6 /net/bluetooth/hci_core.c | |
parent | 4c659c3976e81f9def48993cd00988d53d7379f2 (diff) |
Bluetooth: Pass full hci_dev struct to mgmt callbacks
The current global pending command list in mgmt.c is racy. Possibly the
simplest way to fix it is to have per-hci dev lists instead of a global
one (all commands that need a pending struct are hci_dev specific).
This way the list can be protected using the already existing per-hci
dev lock. To enable this refactoring the first thing that needs to be
done is to ensure that the mgmt functions have access to the hci_dev
struct (instead of just the dev id).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r-- | net/bluetooth/hci_core.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 693c0dfc6b9d..e4b5c6345095 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -550,7 +550,7 @@ int hci_dev_open(__u16 dev) | |||
550 | set_bit(HCI_UP, &hdev->flags); | 550 | set_bit(HCI_UP, &hdev->flags); |
551 | hci_notify(hdev, HCI_DEV_UP); | 551 | hci_notify(hdev, HCI_DEV_UP); |
552 | if (!test_bit(HCI_SETUP, &hdev->flags)) | 552 | if (!test_bit(HCI_SETUP, &hdev->flags)) |
553 | mgmt_powered(hdev->id, 1); | 553 | mgmt_powered(hdev, 1); |
554 | } else { | 554 | } else { |
555 | /* Init failed, cleanup */ | 555 | /* Init failed, cleanup */ |
556 | tasklet_kill(&hdev->rx_task); | 556 | tasklet_kill(&hdev->rx_task); |
@@ -642,7 +642,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
642 | * and no tasks are scheduled. */ | 642 | * and no tasks are scheduled. */ |
643 | hdev->close(hdev); | 643 | hdev->close(hdev); |
644 | 644 | ||
645 | mgmt_powered(hdev->id, 0); | 645 | mgmt_powered(hdev, 0); |
646 | 646 | ||
647 | /* Clear flags */ | 647 | /* Clear flags */ |
648 | hdev->flags = 0; | 648 | hdev->flags = 0; |
@@ -947,7 +947,7 @@ static void hci_power_on(struct work_struct *work) | |||
947 | msecs_to_jiffies(AUTO_OFF_TIMEOUT)); | 947 | msecs_to_jiffies(AUTO_OFF_TIMEOUT)); |
948 | 948 | ||
949 | if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) | 949 | if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) |
950 | mgmt_index_added(hdev->id); | 950 | mgmt_index_added(hdev); |
951 | } | 951 | } |
952 | 952 | ||
953 | static void hci_power_off(struct work_struct *work) | 953 | static void hci_power_off(struct work_struct *work) |
@@ -1140,7 +1140,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | |||
1140 | 1140 | ||
1141 | persistent = hci_persistent_key(hdev, conn, type, old_key_type); | 1141 | persistent = hci_persistent_key(hdev, conn, type, old_key_type); |
1142 | 1142 | ||
1143 | mgmt_new_link_key(hdev->id, key, persistent); | 1143 | mgmt_new_link_key(hdev, key, persistent); |
1144 | 1144 | ||
1145 | if (!persistent) { | 1145 | if (!persistent) { |
1146 | list_del(&key->list); | 1146 | list_del(&key->list); |
@@ -1183,7 +1183,7 @@ int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, | |||
1183 | memcpy(id->rand, rand, sizeof(id->rand)); | 1183 | memcpy(id->rand, rand, sizeof(id->rand)); |
1184 | 1184 | ||
1185 | if (new_key) | 1185 | if (new_key) |
1186 | mgmt_new_link_key(hdev->id, key, old_key_type); | 1186 | mgmt_new_link_key(hdev, key, old_key_type); |
1187 | 1187 | ||
1188 | return 0; | 1188 | return 0; |
1189 | } | 1189 | } |
@@ -1324,7 +1324,7 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1324 | 1324 | ||
1325 | list_add(&entry->list, &hdev->blacklist); | 1325 | list_add(&entry->list, &hdev->blacklist); |
1326 | 1326 | ||
1327 | return mgmt_device_blocked(hdev->id, bdaddr); | 1327 | return mgmt_device_blocked(hdev, bdaddr); |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) | 1330 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) |
@@ -1343,7 +1343,7 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1343 | list_del(&entry->list); | 1343 | list_del(&entry->list); |
1344 | kfree(entry); | 1344 | kfree(entry); |
1345 | 1345 | ||
1346 | return mgmt_device_unblocked(hdev->id, bdaddr); | 1346 | return mgmt_device_unblocked(hdev, bdaddr); |
1347 | } | 1347 | } |
1348 | 1348 | ||
1349 | static void hci_clear_adv_cache(unsigned long arg) | 1349 | static void hci_clear_adv_cache(unsigned long arg) |
@@ -1560,7 +1560,7 @@ void hci_unregister_dev(struct hci_dev *hdev) | |||
1560 | 1560 | ||
1561 | if (!test_bit(HCI_INIT, &hdev->flags) && | 1561 | if (!test_bit(HCI_INIT, &hdev->flags) && |
1562 | !test_bit(HCI_SETUP, &hdev->flags)) | 1562 | !test_bit(HCI_SETUP, &hdev->flags)) |
1563 | mgmt_index_removed(hdev->id); | 1563 | mgmt_index_removed(hdev); |
1564 | 1564 | ||
1565 | hci_notify(hdev, HCI_DEV_UNREG); | 1565 | hci_notify(hdev, HCI_DEV_UNREG); |
1566 | 1566 | ||