diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-03-13 05:11:00 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-03-13 06:09:25 -0400 |
commit | d7a5a11d7fa80beb43d5f7cb421c86f9b4d21200 (patch) | |
tree | fe24ddd4137d73c89f7198d9422544d31568ccf7 /net | |
parent | cc91cb042ce5dab66fedeb94260b18f193ed33d9 (diff) |
Bluetooth: Introduce hci_dev_test_flag helper macro
Instead of manually coding test_bit on hdev->dev_flags all the time,
use hci_dev_test_flag helper macro.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_conn.c | 14 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 120 | ||||
-rw-r--r-- | net/bluetooth/hci_debugfs.c | 4 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 92 | ||||
-rw-r--r-- | net/bluetooth/hci_request.c | 28 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 8 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 8 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 224 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 44 |
9 files changed, 270 insertions, 272 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 91ebb9cb31de..5444e194eb4e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -571,7 +571,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) | |||
571 | 571 | ||
572 | list_for_each_entry(d, &hci_dev_list, list) { | 572 | list_for_each_entry(d, &hci_dev_list, list) { |
573 | if (!test_bit(HCI_UP, &d->flags) || | 573 | if (!test_bit(HCI_UP, &d->flags) || |
574 | test_bit(HCI_USER_CHANNEL, &d->dev_flags) || | 574 | hci_dev_test_flag(d, HCI_USER_CHANNEL) || |
575 | d->dev_type != HCI_BREDR) | 575 | d->dev_type != HCI_BREDR) |
576 | continue; | 576 | continue; |
577 | 577 | ||
@@ -734,7 +734,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
734 | int err; | 734 | int err; |
735 | 735 | ||
736 | /* Let's make sure that le is enabled.*/ | 736 | /* Let's make sure that le is enabled.*/ |
737 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 737 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { |
738 | if (lmp_le_capable(hdev)) | 738 | if (lmp_le_capable(hdev)) |
739 | return ERR_PTR(-ECONNREFUSED); | 739 | return ERR_PTR(-ECONNREFUSED); |
740 | 740 | ||
@@ -799,7 +799,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
799 | * anyway have to disable it in order to start directed | 799 | * anyway have to disable it in order to start directed |
800 | * advertising. | 800 | * advertising. |
801 | */ | 801 | */ |
802 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) { | 802 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) { |
803 | u8 enable = 0x00; | 803 | u8 enable = 0x00; |
804 | hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), | 804 | hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), |
805 | &enable); | 805 | &enable); |
@@ -810,7 +810,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
810 | /* If we're active scanning most controllers are unable | 810 | /* If we're active scanning most controllers are unable |
811 | * to initiate advertising. Simply reject the attempt. | 811 | * to initiate advertising. Simply reject the attempt. |
812 | */ | 812 | */ |
813 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags) && | 813 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN) && |
814 | hdev->le_scan_type == LE_SCAN_ACTIVE) { | 814 | hdev->le_scan_type == LE_SCAN_ACTIVE) { |
815 | skb_queue_purge(&req.cmd_q); | 815 | skb_queue_purge(&req.cmd_q); |
816 | hci_conn_del(conn); | 816 | hci_conn_del(conn); |
@@ -840,7 +840,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
840 | * handler for scan disabling knows to set the correct discovery | 840 | * handler for scan disabling knows to set the correct discovery |
841 | * state. | 841 | * state. |
842 | */ | 842 | */ |
843 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) { | 843 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { |
844 | hci_req_add_le_scan_disable(&req); | 844 | hci_req_add_le_scan_disable(&req); |
845 | set_bit(HCI_LE_SCAN_INTERRUPTED, &hdev->dev_flags); | 845 | set_bit(HCI_LE_SCAN_INTERRUPTED, &hdev->dev_flags); |
846 | } | 846 | } |
@@ -864,7 +864,7 @@ struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, | |||
864 | { | 864 | { |
865 | struct hci_conn *acl; | 865 | struct hci_conn *acl; |
866 | 866 | ||
867 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 867 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
868 | if (lmp_bredr_capable(hdev)) | 868 | if (lmp_bredr_capable(hdev)) |
869 | return ERR_PTR(-ECONNREFUSED); | 869 | return ERR_PTR(-ECONNREFUSED); |
870 | 870 | ||
@@ -942,7 +942,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn) | |||
942 | * Connections is used and the link is encrypted with AES-CCM | 942 | * Connections is used and the link is encrypted with AES-CCM |
943 | * using a P-256 authenticated combination key. | 943 | * using a P-256 authenticated combination key. |
944 | */ | 944 | */ |
945 | if (test_bit(HCI_SC_ONLY, &conn->hdev->flags)) { | 945 | if (hci_dev_test_flag(conn->hdev, HCI_SC_ONLY)) { |
946 | if (!hci_conn_sc_enabled(conn) || | 946 | if (!hci_conn_sc_enabled(conn) || |
947 | !test_bit(HCI_CONN_AES_CCM, &conn->flags) || | 947 | !test_bit(HCI_CONN_AES_CCM, &conn->flags) || |
948 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256) | 948 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256) |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e3bbdd537b90..20fe5ef6abc5 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -617,7 +617,7 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt) | |||
617 | */ | 617 | */ |
618 | hdev->max_page = 0x01; | 618 | hdev->max_page = 0x01; |
619 | 619 | ||
620 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 620 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { |
621 | u8 mode = 0x01; | 621 | u8 mode = 0x01; |
622 | 622 | ||
623 | hci_req_add(req, HCI_OP_WRITE_SSP_MODE, | 623 | hci_req_add(req, HCI_OP_WRITE_SSP_MODE, |
@@ -656,7 +656,7 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt) | |||
656 | sizeof(cp), &cp); | 656 | sizeof(cp), &cp); |
657 | } | 657 | } |
658 | 658 | ||
659 | if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) { | 659 | if (hci_dev_test_flag(hdev, HCI_LINK_SECURITY)) { |
660 | u8 enable = 1; | 660 | u8 enable = 1; |
661 | hci_req_add(req, HCI_OP_WRITE_AUTH_ENABLE, sizeof(enable), | 661 | hci_req_add(req, HCI_OP_WRITE_AUTH_ENABLE, sizeof(enable), |
662 | &enable); | 662 | &enable); |
@@ -693,7 +693,7 @@ static void hci_set_le_support(struct hci_request *req) | |||
693 | 693 | ||
694 | memset(&cp, 0, sizeof(cp)); | 694 | memset(&cp, 0, sizeof(cp)); |
695 | 695 | ||
696 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 696 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { |
697 | cp.le = 0x01; | 697 | cp.le = 0x01; |
698 | cp.simul = 0x00; | 698 | cp.simul = 0x00; |
699 | } | 699 | } |
@@ -881,7 +881,7 @@ static void hci_init4_req(struct hci_request *req, unsigned long opt) | |||
881 | hci_req_add(req, HCI_OP_READ_SYNC_TRAIN_PARAMS, 0, NULL); | 881 | hci_req_add(req, HCI_OP_READ_SYNC_TRAIN_PARAMS, 0, NULL); |
882 | 882 | ||
883 | /* Enable Secure Connections if supported and configured */ | 883 | /* Enable Secure Connections if supported and configured */ |
884 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 884 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED) && |
885 | bredr_sc_enabled(hdev)) { | 885 | bredr_sc_enabled(hdev)) { |
886 | u8 support = 0x01; | 886 | u8 support = 0x01; |
887 | 887 | ||
@@ -901,7 +901,7 @@ static int __hci_init(struct hci_dev *hdev) | |||
901 | /* The Device Under Test (DUT) mode is special and available for | 901 | /* The Device Under Test (DUT) mode is special and available for |
902 | * all controller types. So just create it early on. | 902 | * all controller types. So just create it early on. |
903 | */ | 903 | */ |
904 | if (test_bit(HCI_SETUP, &hdev->dev_flags)) { | 904 | if (hci_dev_test_flag(hdev, HCI_SETUP)) { |
905 | debugfs_create_file("dut_mode", 0644, hdev->debugfs, hdev, | 905 | debugfs_create_file("dut_mode", 0644, hdev->debugfs, hdev, |
906 | &dut_mode_fops); | 906 | &dut_mode_fops); |
907 | } | 907 | } |
@@ -937,8 +937,8 @@ static int __hci_init(struct hci_dev *hdev) | |||
937 | * So only when in setup phase or config phase, create the debugfs | 937 | * So only when in setup phase or config phase, create the debugfs |
938 | * entries and register the SMP channels. | 938 | * entries and register the SMP channels. |
939 | */ | 939 | */ |
940 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 940 | if (!hci_dev_test_flag(hdev, HCI_SETUP) && |
941 | !test_bit(HCI_CONFIG, &hdev->dev_flags)) | 941 | !hci_dev_test_flag(hdev, HCI_CONFIG)) |
942 | return 0; | 942 | return 0; |
943 | 943 | ||
944 | hci_debugfs_create_common(hdev); | 944 | hci_debugfs_create_common(hdev); |
@@ -1300,12 +1300,12 @@ int hci_inquiry(void __user *arg) | |||
1300 | if (!hdev) | 1300 | if (!hdev) |
1301 | return -ENODEV; | 1301 | return -ENODEV; |
1302 | 1302 | ||
1303 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1303 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1304 | err = -EBUSY; | 1304 | err = -EBUSY; |
1305 | goto done; | 1305 | goto done; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 1308 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
1309 | err = -EOPNOTSUPP; | 1309 | err = -EOPNOTSUPP; |
1310 | goto done; | 1310 | goto done; |
1311 | } | 1311 | } |
@@ -1315,7 +1315,7 @@ int hci_inquiry(void __user *arg) | |||
1315 | goto done; | 1315 | goto done; |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 1318 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
1319 | err = -EOPNOTSUPP; | 1319 | err = -EOPNOTSUPP; |
1320 | goto done; | 1320 | goto done; |
1321 | } | 1321 | } |
@@ -1387,17 +1387,17 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1387 | 1387 | ||
1388 | hci_req_lock(hdev); | 1388 | hci_req_lock(hdev); |
1389 | 1389 | ||
1390 | if (test_bit(HCI_UNREGISTER, &hdev->dev_flags)) { | 1390 | if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) { |
1391 | ret = -ENODEV; | 1391 | ret = -ENODEV; |
1392 | goto done; | 1392 | goto done; |
1393 | } | 1393 | } |
1394 | 1394 | ||
1395 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 1395 | if (!hci_dev_test_flag(hdev, HCI_SETUP) && |
1396 | !test_bit(HCI_CONFIG, &hdev->dev_flags)) { | 1396 | !hci_dev_test_flag(hdev, HCI_CONFIG)) { |
1397 | /* Check for rfkill but allow the HCI setup stage to | 1397 | /* Check for rfkill but allow the HCI setup stage to |
1398 | * proceed (which in itself doesn't cause any RF activity). | 1398 | * proceed (which in itself doesn't cause any RF activity). |
1399 | */ | 1399 | */ |
1400 | if (test_bit(HCI_RFKILLED, &hdev->dev_flags)) { | 1400 | if (hci_dev_test_flag(hdev, HCI_RFKILLED)) { |
1401 | ret = -ERFKILL; | 1401 | ret = -ERFKILL; |
1402 | goto done; | 1402 | goto done; |
1403 | } | 1403 | } |
@@ -1414,7 +1414,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1414 | * This check is only valid for BR/EDR controllers | 1414 | * This check is only valid for BR/EDR controllers |
1415 | * since AMP controllers do not have an address. | 1415 | * since AMP controllers do not have an address. |
1416 | */ | 1416 | */ |
1417 | if (!test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) && | 1417 | if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && |
1418 | hdev->dev_type == HCI_BREDR && | 1418 | hdev->dev_type == HCI_BREDR && |
1419 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && | 1419 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && |
1420 | !bacmp(&hdev->static_addr, BDADDR_ANY)) { | 1420 | !bacmp(&hdev->static_addr, BDADDR_ANY)) { |
@@ -1436,7 +1436,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1436 | atomic_set(&hdev->cmd_cnt, 1); | 1436 | atomic_set(&hdev->cmd_cnt, 1); |
1437 | set_bit(HCI_INIT, &hdev->flags); | 1437 | set_bit(HCI_INIT, &hdev->flags); |
1438 | 1438 | ||
1439 | if (test_bit(HCI_SETUP, &hdev->dev_flags)) { | 1439 | if (hci_dev_test_flag(hdev, HCI_SETUP)) { |
1440 | if (hdev->setup) | 1440 | if (hdev->setup) |
1441 | ret = hdev->setup(hdev); | 1441 | ret = hdev->setup(hdev); |
1442 | 1442 | ||
@@ -1458,11 +1458,11 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1458 | * also the original Bluetooth public device address | 1458 | * also the original Bluetooth public device address |
1459 | * will be read using the Read BD Address command. | 1459 | * will be read using the Read BD Address command. |
1460 | */ | 1460 | */ |
1461 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 1461 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
1462 | ret = __hci_unconf_init(hdev); | 1462 | ret = __hci_unconf_init(hdev); |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | if (test_bit(HCI_CONFIG, &hdev->dev_flags)) { | 1465 | if (hci_dev_test_flag(hdev, HCI_CONFIG)) { |
1466 | /* If public address change is configured, ensure that | 1466 | /* If public address change is configured, ensure that |
1467 | * the address gets programmed. If the driver does not | 1467 | * the address gets programmed. If the driver does not |
1468 | * support changing the public address, fail the power | 1468 | * support changing the public address, fail the power |
@@ -1476,8 +1476,8 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | if (!ret) { | 1478 | if (!ret) { |
1479 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | 1479 | if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && |
1480 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 1480 | !hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) |
1481 | ret = __hci_init(hdev); | 1481 | ret = __hci_init(hdev); |
1482 | } | 1482 | } |
1483 | 1483 | ||
@@ -1488,10 +1488,10 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1488 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); | 1488 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); |
1489 | set_bit(HCI_UP, &hdev->flags); | 1489 | set_bit(HCI_UP, &hdev->flags); |
1490 | hci_notify(hdev, HCI_DEV_UP); | 1490 | hci_notify(hdev, HCI_DEV_UP); |
1491 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 1491 | if (!hci_dev_test_flag(hdev, HCI_SETUP) && |
1492 | !test_bit(HCI_CONFIG, &hdev->dev_flags) && | 1492 | !hci_dev_test_flag(hdev, HCI_CONFIG) && |
1493 | !test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | 1493 | !hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && |
1494 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) && | 1494 | !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && |
1495 | hdev->dev_type == HCI_BREDR) { | 1495 | hdev->dev_type == HCI_BREDR) { |
1496 | hci_dev_lock(hdev); | 1496 | hci_dev_lock(hdev); |
1497 | mgmt_powered(hdev, 1); | 1497 | mgmt_powered(hdev, 1); |
@@ -1543,8 +1543,8 @@ int hci_dev_open(__u16 dev) | |||
1543 | * HCI_USER_CHANNEL will be set first before attempting to | 1543 | * HCI_USER_CHANNEL will be set first before attempting to |
1544 | * open the device. | 1544 | * open the device. |
1545 | */ | 1545 | */ |
1546 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | 1546 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && |
1547 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1547 | !hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1548 | err = -EOPNOTSUPP; | 1548 | err = -EOPNOTSUPP; |
1549 | goto done; | 1549 | goto done; |
1550 | } | 1550 | } |
@@ -1569,8 +1569,8 @@ int hci_dev_open(__u16 dev) | |||
1569 | * is in use this bit will be cleared again and userspace has | 1569 | * is in use this bit will be cleared again and userspace has |
1570 | * to explicitly enable it. | 1570 | * to explicitly enable it. |
1571 | */ | 1571 | */ |
1572 | if (!test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) && | 1572 | if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && |
1573 | !test_bit(HCI_MGMT, &hdev->dev_flags)) | 1573 | !hci_dev_test_flag(hdev, HCI_MGMT)) |
1574 | set_bit(HCI_BONDABLE, &hdev->dev_flags); | 1574 | set_bit(HCI_BONDABLE, &hdev->dev_flags); |
1575 | 1575 | ||
1576 | err = hci_dev_do_open(hdev); | 1576 | err = hci_dev_do_open(hdev); |
@@ -1601,7 +1601,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
1601 | { | 1601 | { |
1602 | BT_DBG("%s %p", hdev->name, hdev); | 1602 | BT_DBG("%s %p", hdev->name, hdev); |
1603 | 1603 | ||
1604 | if (!test_bit(HCI_UNREGISTER, &hdev->dev_flags)) { | 1604 | if (!hci_dev_test_flag(hdev, HCI_UNREGISTER)) { |
1605 | /* Execute vendor specific shutdown routine */ | 1605 | /* Execute vendor specific shutdown routine */ |
1606 | if (hdev->shutdown) | 1606 | if (hdev->shutdown) |
1607 | hdev->shutdown(hdev); | 1607 | hdev->shutdown(hdev); |
@@ -1635,7 +1635,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
1635 | cancel_delayed_work_sync(&hdev->le_scan_disable); | 1635 | cancel_delayed_work_sync(&hdev->le_scan_disable); |
1636 | cancel_delayed_work_sync(&hdev->le_scan_restart); | 1636 | cancel_delayed_work_sync(&hdev->le_scan_restart); |
1637 | 1637 | ||
1638 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 1638 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
1639 | cancel_delayed_work_sync(&hdev->rpa_expired); | 1639 | cancel_delayed_work_sync(&hdev->rpa_expired); |
1640 | 1640 | ||
1641 | /* Avoid potential lockdep warnings from the *_flush() calls by | 1641 | /* Avoid potential lockdep warnings from the *_flush() calls by |
@@ -1667,8 +1667,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
1667 | /* Reset device */ | 1667 | /* Reset device */ |
1668 | skb_queue_purge(&hdev->cmd_q); | 1668 | skb_queue_purge(&hdev->cmd_q); |
1669 | atomic_set(&hdev->cmd_cnt, 1); | 1669 | atomic_set(&hdev->cmd_cnt, 1); |
1670 | if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags) && | 1670 | if (!hci_dev_test_flag(hdev, HCI_AUTO_OFF) && |
1671 | !test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | 1671 | !hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && |
1672 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { | 1672 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { |
1673 | set_bit(HCI_INIT, &hdev->flags); | 1673 | set_bit(HCI_INIT, &hdev->flags); |
1674 | __hci_req_sync(hdev, hci_reset_req, 0, HCI_CMD_TIMEOUT); | 1674 | __hci_req_sync(hdev, hci_reset_req, 0, HCI_CMD_TIMEOUT); |
@@ -1723,7 +1723,7 @@ int hci_dev_close(__u16 dev) | |||
1723 | if (!hdev) | 1723 | if (!hdev) |
1724 | return -ENODEV; | 1724 | return -ENODEV; |
1725 | 1725 | ||
1726 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1726 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1727 | err = -EBUSY; | 1727 | err = -EBUSY; |
1728 | goto done; | 1728 | goto done; |
1729 | } | 1729 | } |
@@ -1786,12 +1786,12 @@ int hci_dev_reset(__u16 dev) | |||
1786 | goto done; | 1786 | goto done; |
1787 | } | 1787 | } |
1788 | 1788 | ||
1789 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1789 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1790 | err = -EBUSY; | 1790 | err = -EBUSY; |
1791 | goto done; | 1791 | goto done; |
1792 | } | 1792 | } |
1793 | 1793 | ||
1794 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 1794 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
1795 | err = -EOPNOTSUPP; | 1795 | err = -EOPNOTSUPP; |
1796 | goto done; | 1796 | goto done; |
1797 | } | 1797 | } |
@@ -1812,12 +1812,12 @@ int hci_dev_reset_stat(__u16 dev) | |||
1812 | if (!hdev) | 1812 | if (!hdev) |
1813 | return -ENODEV; | 1813 | return -ENODEV; |
1814 | 1814 | ||
1815 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1815 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1816 | ret = -EBUSY; | 1816 | ret = -EBUSY; |
1817 | goto done; | 1817 | goto done; |
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 1820 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
1821 | ret = -EOPNOTSUPP; | 1821 | ret = -EOPNOTSUPP; |
1822 | goto done; | 1822 | goto done; |
1823 | } | 1823 | } |
@@ -1851,14 +1851,14 @@ static void hci_update_scan_state(struct hci_dev *hdev, u8 scan) | |||
1851 | &hdev->dev_flags); | 1851 | &hdev->dev_flags); |
1852 | } | 1852 | } |
1853 | 1853 | ||
1854 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 1854 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
1855 | return; | 1855 | return; |
1856 | 1856 | ||
1857 | if (conn_changed || discov_changed) { | 1857 | if (conn_changed || discov_changed) { |
1858 | /* In case this was disabled through mgmt */ | 1858 | /* In case this was disabled through mgmt */ |
1859 | set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags); | 1859 | set_bit(HCI_BREDR_ENABLED, &hdev->dev_flags); |
1860 | 1860 | ||
1861 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 1861 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
1862 | mgmt_update_adv_data(hdev); | 1862 | mgmt_update_adv_data(hdev); |
1863 | 1863 | ||
1864 | mgmt_new_settings(hdev); | 1864 | mgmt_new_settings(hdev); |
@@ -1878,12 +1878,12 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg) | |||
1878 | if (!hdev) | 1878 | if (!hdev) |
1879 | return -ENODEV; | 1879 | return -ENODEV; |
1880 | 1880 | ||
1881 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 1881 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
1882 | err = -EBUSY; | 1882 | err = -EBUSY; |
1883 | goto done; | 1883 | goto done; |
1884 | } | 1884 | } |
1885 | 1885 | ||
1886 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 1886 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
1887 | err = -EOPNOTSUPP; | 1887 | err = -EOPNOTSUPP; |
1888 | goto done; | 1888 | goto done; |
1889 | } | 1889 | } |
@@ -1893,7 +1893,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg) | |||
1893 | goto done; | 1893 | goto done; |
1894 | } | 1894 | } |
1895 | 1895 | ||
1896 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 1896 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
1897 | err = -EOPNOTSUPP; | 1897 | err = -EOPNOTSUPP; |
1898 | goto done; | 1898 | goto done; |
1899 | } | 1899 | } |
@@ -1997,7 +1997,7 @@ int hci_get_dev_list(void __user *arg) | |||
1997 | * is running, but in that case still indicate that the | 1997 | * is running, but in that case still indicate that the |
1998 | * device is actually down. | 1998 | * device is actually down. |
1999 | */ | 1999 | */ |
2000 | if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) | 2000 | if (hci_dev_test_flag(hdev, HCI_AUTO_OFF)) |
2001 | flags &= ~BIT(HCI_UP); | 2001 | flags &= ~BIT(HCI_UP); |
2002 | 2002 | ||
2003 | (dr + n)->dev_id = hdev->id; | 2003 | (dr + n)->dev_id = hdev->id; |
@@ -2035,7 +2035,7 @@ int hci_get_dev_info(void __user *arg) | |||
2035 | * is running, but in that case still indicate that the | 2035 | * is running, but in that case still indicate that the |
2036 | * device is actually down. | 2036 | * device is actually down. |
2037 | */ | 2037 | */ |
2038 | if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) | 2038 | if (hci_dev_test_flag(hdev, HCI_AUTO_OFF)) |
2039 | flags = hdev->flags & ~BIT(HCI_UP); | 2039 | flags = hdev->flags & ~BIT(HCI_UP); |
2040 | else | 2040 | else |
2041 | flags = hdev->flags; | 2041 | flags = hdev->flags; |
@@ -2078,13 +2078,13 @@ static int hci_rfkill_set_block(void *data, bool blocked) | |||
2078 | 2078 | ||
2079 | BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked); | 2079 | BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked); |
2080 | 2080 | ||
2081 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 2081 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) |
2082 | return -EBUSY; | 2082 | return -EBUSY; |
2083 | 2083 | ||
2084 | if (blocked) { | 2084 | if (blocked) { |
2085 | set_bit(HCI_RFKILLED, &hdev->dev_flags); | 2085 | set_bit(HCI_RFKILLED, &hdev->dev_flags); |
2086 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 2086 | if (!hci_dev_test_flag(hdev, HCI_SETUP) && |
2087 | !test_bit(HCI_CONFIG, &hdev->dev_flags)) | 2087 | !hci_dev_test_flag(hdev, HCI_CONFIG)) |
2088 | hci_dev_do_close(hdev); | 2088 | hci_dev_do_close(hdev); |
2089 | } else { | 2089 | } else { |
2090 | clear_bit(HCI_RFKILLED, &hdev->dev_flags); | 2090 | clear_bit(HCI_RFKILLED, &hdev->dev_flags); |
@@ -2116,14 +2116,14 @@ static void hci_power_on(struct work_struct *work) | |||
2116 | * ignored and they need to be checked now. If they are still | 2116 | * ignored and they need to be checked now. If they are still |
2117 | * valid, it is important to turn the device back off. | 2117 | * valid, it is important to turn the device back off. |
2118 | */ | 2118 | */ |
2119 | if (test_bit(HCI_RFKILLED, &hdev->dev_flags) || | 2119 | if (hci_dev_test_flag(hdev, HCI_RFKILLED) || |
2120 | test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) || | 2120 | hci_dev_test_flag(hdev, HCI_UNCONFIGURED) || |
2121 | (hdev->dev_type == HCI_BREDR && | 2121 | (hdev->dev_type == HCI_BREDR && |
2122 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && | 2122 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && |
2123 | !bacmp(&hdev->static_addr, BDADDR_ANY))) { | 2123 | !bacmp(&hdev->static_addr, BDADDR_ANY))) { |
2124 | clear_bit(HCI_AUTO_OFF, &hdev->dev_flags); | 2124 | clear_bit(HCI_AUTO_OFF, &hdev->dev_flags); |
2125 | hci_dev_do_close(hdev); | 2125 | hci_dev_do_close(hdev); |
2126 | } else if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { | 2126 | } else if (hci_dev_test_flag(hdev, HCI_AUTO_OFF)) { |
2127 | queue_delayed_work(hdev->req_workqueue, &hdev->power_off, | 2127 | queue_delayed_work(hdev->req_workqueue, &hdev->power_off, |
2128 | HCI_AUTO_OFF_TIMEOUT); | 2128 | HCI_AUTO_OFF_TIMEOUT); |
2129 | } | 2129 | } |
@@ -2132,7 +2132,7 @@ static void hci_power_on(struct work_struct *work) | |||
2132 | /* For unconfigured devices, set the HCI_RAW flag | 2132 | /* For unconfigured devices, set the HCI_RAW flag |
2133 | * so that userspace can easily identify them. | 2133 | * so that userspace can easily identify them. |
2134 | */ | 2134 | */ |
2135 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 2135 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
2136 | set_bit(HCI_RAW, &hdev->flags); | 2136 | set_bit(HCI_RAW, &hdev->flags); |
2137 | 2137 | ||
2138 | /* For fully configured devices, this will send | 2138 | /* For fully configured devices, this will send |
@@ -2147,7 +2147,7 @@ static void hci_power_on(struct work_struct *work) | |||
2147 | /* When the controller is now configured, then it | 2147 | /* When the controller is now configured, then it |
2148 | * is important to clear the HCI_RAW flag. | 2148 | * is important to clear the HCI_RAW flag. |
2149 | */ | 2149 | */ |
2150 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 2150 | if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
2151 | clear_bit(HCI_RAW, &hdev->flags); | 2151 | clear_bit(HCI_RAW, &hdev->flags); |
2152 | 2152 | ||
2153 | /* Powering on the controller with HCI_CONFIG set only | 2153 | /* Powering on the controller with HCI_CONFIG set only |
@@ -2986,7 +2986,7 @@ static void le_scan_restart_work(struct work_struct *work) | |||
2986 | BT_DBG("%s", hdev->name); | 2986 | BT_DBG("%s", hdev->name); |
2987 | 2987 | ||
2988 | /* If controller is not scanning we are done. */ | 2988 | /* If controller is not scanning we are done. */ |
2989 | if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags)) | 2989 | if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) |
2990 | return; | 2990 | return; |
2991 | 2991 | ||
2992 | hci_req_init(&req, hdev); | 2992 | hci_req_init(&req, hdev); |
@@ -3021,7 +3021,7 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
3021 | { | 3021 | { |
3022 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || | 3022 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || |
3023 | !bacmp(&hdev->bdaddr, BDADDR_ANY) || | 3023 | !bacmp(&hdev->bdaddr, BDADDR_ANY) || |
3024 | (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && | 3024 | (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) && |
3025 | bacmp(&hdev->static_addr, BDADDR_ANY))) { | 3025 | bacmp(&hdev->static_addr, BDADDR_ANY))) { |
3026 | bacpy(bdaddr, &hdev->static_addr); | 3026 | bacpy(bdaddr, &hdev->static_addr); |
3027 | *bdaddr_type = ADDR_LE_DEV_RANDOM; | 3027 | *bdaddr_type = ADDR_LE_DEV_RANDOM; |
@@ -3251,8 +3251,8 @@ void hci_unregister_dev(struct hci_dev *hdev) | |||
3251 | cancel_work_sync(&hdev->power_on); | 3251 | cancel_work_sync(&hdev->power_on); |
3252 | 3252 | ||
3253 | if (!test_bit(HCI_INIT, &hdev->flags) && | 3253 | if (!test_bit(HCI_INIT, &hdev->flags) && |
3254 | !test_bit(HCI_SETUP, &hdev->dev_flags) && | 3254 | !hci_dev_test_flag(hdev, HCI_SETUP) && |
3255 | !test_bit(HCI_CONFIG, &hdev->dev_flags)) { | 3255 | !hci_dev_test_flag(hdev, HCI_CONFIG)) { |
3256 | hci_dev_lock(hdev); | 3256 | hci_dev_lock(hdev); |
3257 | mgmt_index_removed(hdev); | 3257 | mgmt_index_removed(hdev); |
3258 | hci_dev_unlock(hdev); | 3258 | hci_dev_unlock(hdev); |
@@ -3926,7 +3926,7 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) | |||
3926 | 3926 | ||
3927 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) | 3927 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) |
3928 | { | 3928 | { |
3929 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 3929 | if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
3930 | /* ACL tx timeout must be longer than maximum | 3930 | /* ACL tx timeout must be longer than maximum |
3931 | * link supervision timeout (40.9 seconds) */ | 3931 | * link supervision timeout (40.9 seconds) */ |
3932 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + | 3932 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + |
@@ -4109,7 +4109,7 @@ static void hci_sched_le(struct hci_dev *hdev) | |||
4109 | if (!hci_conn_num(hdev, LE_LINK)) | 4109 | if (!hci_conn_num(hdev, LE_LINK)) |
4110 | return; | 4110 | return; |
4111 | 4111 | ||
4112 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 4112 | if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { |
4113 | /* LE tx timeout must be longer than maximum | 4113 | /* LE tx timeout must be longer than maximum |
4114 | * link supervision timeout (40.9 seconds) */ | 4114 | * link supervision timeout (40.9 seconds) */ |
4115 | if (!hdev->le_cnt && hdev->le_pkts && | 4115 | if (!hdev->le_cnt && hdev->le_pkts && |
@@ -4157,7 +4157,7 @@ static void hci_tx_work(struct work_struct *work) | |||
4157 | BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt, | 4157 | BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt, |
4158 | hdev->sco_cnt, hdev->le_cnt); | 4158 | hdev->sco_cnt, hdev->le_cnt); |
4159 | 4159 | ||
4160 | if (!test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 4160 | if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
4161 | /* Schedule queues and send stuff to HCI driver */ | 4161 | /* Schedule queues and send stuff to HCI driver */ |
4162 | hci_sched_acl(hdev); | 4162 | hci_sched_acl(hdev); |
4163 | hci_sched_sco(hdev); | 4163 | hci_sched_sco(hdev); |
@@ -4354,7 +4354,7 @@ static void hci_rx_work(struct work_struct *work) | |||
4354 | hci_send_to_sock(hdev, skb); | 4354 | hci_send_to_sock(hdev, skb); |
4355 | } | 4355 | } |
4356 | 4356 | ||
4357 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 4357 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
4358 | kfree_skb(skb); | 4358 | kfree_skb(skb); |
4359 | continue; | 4359 | continue; |
4360 | } | 4360 | } |
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c index 65261e5d4b84..3c025ee5572c 100644 --- a/net/bluetooth/hci_debugfs.c +++ b/net/bluetooth/hci_debugfs.c | |||
@@ -247,7 +247,7 @@ static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf, | |||
247 | struct hci_dev *hdev = file->private_data; | 247 | struct hci_dev *hdev = file->private_data; |
248 | char buf[3]; | 248 | char buf[3]; |
249 | 249 | ||
250 | buf[0] = test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags) ? 'Y': 'N'; | 250 | buf[0] = hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS) ? 'Y': 'N'; |
251 | buf[1] = '\n'; | 251 | buf[1] = '\n'; |
252 | buf[2] = '\0'; | 252 | buf[2] = '\0'; |
253 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | 253 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); |
@@ -265,7 +265,7 @@ static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf, | |||
265 | struct hci_dev *hdev = file->private_data; | 265 | struct hci_dev *hdev = file->private_data; |
266 | char buf[3]; | 266 | char buf[3]; |
267 | 267 | ||
268 | buf[0] = test_bit(HCI_SC_ONLY, &hdev->dev_flags) ? 'Y': 'N'; | 268 | buf[0] = hci_dev_test_flag(hdev, HCI_SC_ONLY) ? 'Y': 'N'; |
269 | buf[1] = '\n'; | 269 | buf[1] = '\n'; |
270 | buf[2] = '\0'; | 270 | buf[2] = '\0'; |
271 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | 271 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 39653d46932b..f1ed3fe9e0df 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -265,7 +265,7 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) | |||
265 | 265 | ||
266 | hci_dev_lock(hdev); | 266 | hci_dev_lock(hdev); |
267 | 267 | ||
268 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 268 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
269 | mgmt_set_local_name_complete(hdev, sent, status); | 269 | mgmt_set_local_name_complete(hdev, sent, status); |
270 | else if (!status) | 270 | else if (!status) |
271 | memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); | 271 | memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); |
@@ -282,8 +282,8 @@ static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) | |||
282 | if (rp->status) | 282 | if (rp->status) |
283 | return; | 283 | return; |
284 | 284 | ||
285 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 285 | if (hci_dev_test_flag(hdev, HCI_SETUP) || |
286 | test_bit(HCI_CONFIG, &hdev->dev_flags)) | 286 | hci_dev_test_flag(hdev, HCI_CONFIG)) |
287 | memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); | 287 | memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); |
288 | } | 288 | } |
289 | 289 | ||
@@ -309,7 +309,7 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) | |||
309 | clear_bit(HCI_AUTH, &hdev->flags); | 309 | clear_bit(HCI_AUTH, &hdev->flags); |
310 | } | 310 | } |
311 | 311 | ||
312 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 312 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
313 | mgmt_auth_enable_complete(hdev, status); | 313 | mgmt_auth_enable_complete(hdev, status); |
314 | 314 | ||
315 | hci_dev_unlock(hdev); | 315 | hci_dev_unlock(hdev); |
@@ -404,7 +404,7 @@ static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) | |||
404 | if (status == 0) | 404 | if (status == 0) |
405 | memcpy(hdev->dev_class, sent, 3); | 405 | memcpy(hdev->dev_class, sent, 3); |
406 | 406 | ||
407 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 407 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
408 | mgmt_set_class_of_dev_complete(hdev, sent, status); | 408 | mgmt_set_class_of_dev_complete(hdev, sent, status); |
409 | 409 | ||
410 | hci_dev_unlock(hdev); | 410 | hci_dev_unlock(hdev); |
@@ -497,7 +497,7 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | |||
497 | hdev->features[1][0] &= ~LMP_HOST_SSP; | 497 | hdev->features[1][0] &= ~LMP_HOST_SSP; |
498 | } | 498 | } |
499 | 499 | ||
500 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 500 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
501 | mgmt_ssp_enable_complete(hdev, sent->mode, status); | 501 | mgmt_ssp_enable_complete(hdev, sent->mode, status); |
502 | else if (!status) { | 502 | else if (!status) { |
503 | if (sent->mode) | 503 | if (sent->mode) |
@@ -529,7 +529,7 @@ static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb) | |||
529 | hdev->features[1][0] &= ~LMP_HOST_SC; | 529 | hdev->features[1][0] &= ~LMP_HOST_SC; |
530 | } | 530 | } |
531 | 531 | ||
532 | if (!test_bit(HCI_MGMT, &hdev->dev_flags) && !status) { | 532 | if (!hci_dev_test_flag(hdev, HCI_MGMT) && !status) { |
533 | if (sent->support) | 533 | if (sent->support) |
534 | set_bit(HCI_SC_ENABLED, &hdev->dev_flags); | 534 | set_bit(HCI_SC_ENABLED, &hdev->dev_flags); |
535 | else | 535 | else |
@@ -548,8 +548,8 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) | |||
548 | if (rp->status) | 548 | if (rp->status) |
549 | return; | 549 | return; |
550 | 550 | ||
551 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 551 | if (hci_dev_test_flag(hdev, HCI_SETUP) || |
552 | test_bit(HCI_CONFIG, &hdev->dev_flags)) { | 552 | hci_dev_test_flag(hdev, HCI_CONFIG)) { |
553 | hdev->hci_ver = rp->hci_ver; | 553 | hdev->hci_ver = rp->hci_ver; |
554 | hdev->hci_rev = __le16_to_cpu(rp->hci_rev); | 554 | hdev->hci_rev = __le16_to_cpu(rp->hci_rev); |
555 | hdev->lmp_ver = rp->lmp_ver; | 555 | hdev->lmp_ver = rp->lmp_ver; |
@@ -568,8 +568,8 @@ static void hci_cc_read_local_commands(struct hci_dev *hdev, | |||
568 | if (rp->status) | 568 | if (rp->status) |
569 | return; | 569 | return; |
570 | 570 | ||
571 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 571 | if (hci_dev_test_flag(hdev, HCI_SETUP) || |
572 | test_bit(HCI_CONFIG, &hdev->dev_flags)) | 572 | hci_dev_test_flag(hdev, HCI_CONFIG)) |
573 | memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); | 573 | memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); |
574 | } | 574 | } |
575 | 575 | ||
@@ -691,7 +691,7 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb) | |||
691 | if (test_bit(HCI_INIT, &hdev->flags)) | 691 | if (test_bit(HCI_INIT, &hdev->flags)) |
692 | bacpy(&hdev->bdaddr, &rp->bdaddr); | 692 | bacpy(&hdev->bdaddr, &rp->bdaddr); |
693 | 693 | ||
694 | if (test_bit(HCI_SETUP, &hdev->dev_flags)) | 694 | if (hci_dev_test_flag(hdev, HCI_SETUP)) |
695 | bacpy(&hdev->setup_addr, &rp->bdaddr); | 695 | bacpy(&hdev->setup_addr, &rp->bdaddr); |
696 | } | 696 | } |
697 | 697 | ||
@@ -900,7 +900,7 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) | |||
900 | 900 | ||
901 | hci_dev_lock(hdev); | 901 | hci_dev_lock(hdev); |
902 | 902 | ||
903 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 903 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
904 | mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); | 904 | mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); |
905 | 905 | ||
906 | if (rp->status) | 906 | if (rp->status) |
@@ -926,7 +926,7 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) | |||
926 | 926 | ||
927 | hci_dev_lock(hdev); | 927 | hci_dev_lock(hdev); |
928 | 928 | ||
929 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 929 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
930 | mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, | 930 | mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, |
931 | rp->status); | 931 | rp->status); |
932 | 932 | ||
@@ -985,7 +985,7 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) | |||
985 | 985 | ||
986 | hci_dev_lock(hdev); | 986 | hci_dev_lock(hdev); |
987 | 987 | ||
988 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 988 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
989 | mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, | 989 | mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK, 0, |
990 | rp->status); | 990 | rp->status); |
991 | 991 | ||
@@ -1001,7 +1001,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, | |||
1001 | 1001 | ||
1002 | hci_dev_lock(hdev); | 1002 | hci_dev_lock(hdev); |
1003 | 1003 | ||
1004 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 1004 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
1005 | mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, | 1005 | mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, |
1006 | ACL_LINK, 0, rp->status); | 1006 | ACL_LINK, 0, rp->status); |
1007 | 1007 | ||
@@ -1016,7 +1016,7 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) | |||
1016 | 1016 | ||
1017 | hci_dev_lock(hdev); | 1017 | hci_dev_lock(hdev); |
1018 | 1018 | ||
1019 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 1019 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
1020 | mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, | 1020 | mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK, |
1021 | 0, rp->status); | 1021 | 0, rp->status); |
1022 | 1022 | ||
@@ -1032,7 +1032,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, | |||
1032 | 1032 | ||
1033 | hci_dev_lock(hdev); | 1033 | hci_dev_lock(hdev); |
1034 | 1034 | ||
1035 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 1035 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
1036 | mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, | 1036 | mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, |
1037 | ACL_LINK, 0, rp->status); | 1037 | ACL_LINK, 0, rp->status); |
1038 | 1038 | ||
@@ -1229,7 +1229,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | |||
1229 | if (test_and_clear_bit(HCI_LE_SCAN_INTERRUPTED, | 1229 | if (test_and_clear_bit(HCI_LE_SCAN_INTERRUPTED, |
1230 | &hdev->dev_flags)) | 1230 | &hdev->dev_flags)) |
1231 | hci_discovery_set_state(hdev, DISCOVERY_STOPPED); | 1231 | hci_discovery_set_state(hdev, DISCOVERY_STOPPED); |
1232 | else if (!test_bit(HCI_LE_ADV, &hdev->dev_flags) && | 1232 | else if (!hci_dev_test_flag(hdev, HCI_LE_ADV) && |
1233 | hdev->discovery.state == DISCOVERY_FINDING) | 1233 | hdev->discovery.state == DISCOVERY_FINDING) |
1234 | mgmt_reenable_advertising(hdev); | 1234 | mgmt_reenable_advertising(hdev); |
1235 | 1235 | ||
@@ -1769,7 +1769,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) | |||
1769 | 1769 | ||
1770 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); | 1770 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); |
1771 | 1771 | ||
1772 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 1772 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
1773 | hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); | 1773 | hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0); |
1774 | 1774 | ||
1775 | if (!conn) | 1775 | if (!conn) |
@@ -2118,7 +2118,7 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2118 | smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */ | 2118 | smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */ |
2119 | wake_up_bit(&hdev->flags, HCI_INQUIRY); | 2119 | wake_up_bit(&hdev->flags, HCI_INQUIRY); |
2120 | 2120 | ||
2121 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 2121 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
2122 | return; | 2122 | return; |
2123 | 2123 | ||
2124 | hci_dev_lock(hdev); | 2124 | hci_dev_lock(hdev); |
@@ -2154,7 +2154,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2154 | if (!num_rsp) | 2154 | if (!num_rsp) |
2155 | return; | 2155 | return; |
2156 | 2156 | ||
2157 | if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) | 2157 | if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) |
2158 | return; | 2158 | return; |
2159 | 2159 | ||
2160 | hci_dev_lock(hdev); | 2160 | hci_dev_lock(hdev); |
@@ -2304,8 +2304,8 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2304 | * connection. These features are only touched through mgmt so | 2304 | * connection. These features are only touched through mgmt so |
2305 | * only do the checks if HCI_MGMT is set. | 2305 | * only do the checks if HCI_MGMT is set. |
2306 | */ | 2306 | */ |
2307 | if (test_bit(HCI_MGMT, &hdev->dev_flags) && | 2307 | if (hci_dev_test_flag(hdev, HCI_MGMT) && |
2308 | !test_bit(HCI_CONNECTABLE, &hdev->dev_flags) && | 2308 | !hci_dev_test_flag(hdev, HCI_CONNECTABLE) && |
2309 | !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr, | 2309 | !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr, |
2310 | BDADDR_BREDR)) { | 2310 | BDADDR_BREDR)) { |
2311 | hci_reject_conn(hdev, &ev->bdaddr); | 2311 | hci_reject_conn(hdev, &ev->bdaddr); |
@@ -2542,7 +2542,7 @@ static void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2542 | 2542 | ||
2543 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); | 2543 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); |
2544 | 2544 | ||
2545 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 2545 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
2546 | goto check_auth; | 2546 | goto check_auth; |
2547 | 2547 | ||
2548 | if (ev->status == 0) | 2548 | if (ev->status == 0) |
@@ -2626,7 +2626,7 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2626 | * connections that are not encrypted with AES-CCM | 2626 | * connections that are not encrypted with AES-CCM |
2627 | * using a P-256 authenticated combination key. | 2627 | * using a P-256 authenticated combination key. |
2628 | */ | 2628 | */ |
2629 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && | 2629 | if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && |
2630 | (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || | 2630 | (!test_bit(HCI_CONN_AES_CCM, &conn->flags) || |
2631 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { | 2631 | conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) { |
2632 | hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); | 2632 | hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE); |
@@ -3331,11 +3331,11 @@ static void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3331 | hci_conn_drop(conn); | 3331 | hci_conn_drop(conn); |
3332 | } | 3332 | } |
3333 | 3333 | ||
3334 | if (!test_bit(HCI_BONDABLE, &hdev->dev_flags) && | 3334 | if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && |
3335 | !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { | 3335 | !test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags)) { |
3336 | hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, | 3336 | hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, |
3337 | sizeof(ev->bdaddr), &ev->bdaddr); | 3337 | sizeof(ev->bdaddr), &ev->bdaddr); |
3338 | } else if (test_bit(HCI_MGMT, &hdev->dev_flags)) { | 3338 | } else if (hci_dev_test_flag(hdev, HCI_MGMT)) { |
3339 | u8 secure; | 3339 | u8 secure; |
3340 | 3340 | ||
3341 | if (conn->pending_sec_level == BT_SECURITY_HIGH) | 3341 | if (conn->pending_sec_level == BT_SECURITY_HIGH) |
@@ -3391,7 +3391,7 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3391 | 3391 | ||
3392 | BT_DBG("%s", hdev->name); | 3392 | BT_DBG("%s", hdev->name); |
3393 | 3393 | ||
3394 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 3394 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
3395 | return; | 3395 | return; |
3396 | 3396 | ||
3397 | hci_dev_lock(hdev); | 3397 | hci_dev_lock(hdev); |
@@ -3465,7 +3465,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3465 | set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); | 3465 | set_bit(HCI_CONN_NEW_LINK_KEY, &conn->flags); |
3466 | conn_set_key(conn, ev->key_type, conn->pin_length); | 3466 | conn_set_key(conn, ev->key_type, conn->pin_length); |
3467 | 3467 | ||
3468 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 3468 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
3469 | goto unlock; | 3469 | goto unlock; |
3470 | 3470 | ||
3471 | key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, | 3471 | key = hci_add_link_key(hdev, conn, &ev->bdaddr, ev->link_key, |
@@ -3487,7 +3487,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3487 | * store_hint being 0). | 3487 | * store_hint being 0). |
3488 | */ | 3488 | */ |
3489 | if (key->type == HCI_LK_DEBUG_COMBINATION && | 3489 | if (key->type == HCI_LK_DEBUG_COMBINATION && |
3490 | !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags)) { | 3490 | !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) { |
3491 | list_del_rcu(&key->list); | 3491 | list_del_rcu(&key->list); |
3492 | kfree_rcu(key, rcu); | 3492 | kfree_rcu(key, rcu); |
3493 | goto unlock; | 3493 | goto unlock; |
@@ -3570,7 +3570,7 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, | |||
3570 | if (!num_rsp) | 3570 | if (!num_rsp) |
3571 | return; | 3571 | return; |
3572 | 3572 | ||
3573 | if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) | 3573 | if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) |
3574 | return; | 3574 | return; |
3575 | 3575 | ||
3576 | hci_dev_lock(hdev); | 3576 | hci_dev_lock(hdev); |
@@ -3776,7 +3776,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, | |||
3776 | if (!num_rsp) | 3776 | if (!num_rsp) |
3777 | return; | 3777 | return; |
3778 | 3778 | ||
3779 | if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) | 3779 | if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) |
3780 | return; | 3780 | return; |
3781 | 3781 | ||
3782 | hci_dev_lock(hdev); | 3782 | hci_dev_lock(hdev); |
@@ -3794,7 +3794,7 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev, | |||
3794 | data.rssi = info->rssi; | 3794 | data.rssi = info->rssi; |
3795 | data.ssp_mode = 0x01; | 3795 | data.ssp_mode = 0x01; |
3796 | 3796 | ||
3797 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 3797 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
3798 | name_known = eir_has_data_type(info->data, | 3798 | name_known = eir_has_data_type(info->data, |
3799 | sizeof(info->data), | 3799 | sizeof(info->data), |
3800 | EIR_NAME_COMPLETE); | 3800 | EIR_NAME_COMPLETE); |
@@ -3898,7 +3898,7 @@ static u8 bredr_oob_data_present(struct hci_conn *conn) | |||
3898 | * information. However it can only be trusted when | 3898 | * information. However it can only be trusted when |
3899 | * not in Secure Connection Only mode. | 3899 | * not in Secure Connection Only mode. |
3900 | */ | 3900 | */ |
3901 | if (!test_bit(HCI_SC_ONLY, &hdev->dev_flags)) | 3901 | if (!hci_dev_test_flag(hdev, HCI_SC_ONLY)) |
3902 | return data->present; | 3902 | return data->present; |
3903 | 3903 | ||
3904 | /* When Secure Connections Only mode is enabled, then | 3904 | /* When Secure Connections Only mode is enabled, then |
@@ -3942,13 +3942,13 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3942 | 3942 | ||
3943 | hci_conn_hold(conn); | 3943 | hci_conn_hold(conn); |
3944 | 3944 | ||
3945 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 3945 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
3946 | goto unlock; | 3946 | goto unlock; |
3947 | 3947 | ||
3948 | /* Allow pairing if we're pairable, the initiators of the | 3948 | /* Allow pairing if we're pairable, the initiators of the |
3949 | * pairing or if the remote is not requesting bonding. | 3949 | * pairing or if the remote is not requesting bonding. |
3950 | */ | 3950 | */ |
3951 | if (test_bit(HCI_BONDABLE, &hdev->dev_flags) || | 3951 | if (hci_dev_test_flag(hdev, HCI_BONDABLE) || |
3952 | test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || | 3952 | test_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags) || |
3953 | (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { | 3953 | (conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) { |
3954 | struct hci_cp_io_capability_reply cp; | 3954 | struct hci_cp_io_capability_reply cp; |
@@ -3974,7 +3974,7 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3974 | /* If we're not bondable, force one of the non-bondable | 3974 | /* If we're not bondable, force one of the non-bondable |
3975 | * authentication requirement values. | 3975 | * authentication requirement values. |
3976 | */ | 3976 | */ |
3977 | if (!test_bit(HCI_BONDABLE, &hdev->dev_flags)) | 3977 | if (!hci_dev_test_flag(hdev, HCI_BONDABLE)) |
3978 | conn->auth_type &= HCI_AT_NO_BONDING_MITM; | 3978 | conn->auth_type &= HCI_AT_NO_BONDING_MITM; |
3979 | 3979 | ||
3980 | cp.authentication = conn->auth_type; | 3980 | cp.authentication = conn->auth_type; |
@@ -4029,7 +4029,7 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev, | |||
4029 | 4029 | ||
4030 | hci_dev_lock(hdev); | 4030 | hci_dev_lock(hdev); |
4031 | 4031 | ||
4032 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 4032 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
4033 | goto unlock; | 4033 | goto unlock; |
4034 | 4034 | ||
4035 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); | 4035 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); |
@@ -4100,7 +4100,7 @@ static void hci_user_passkey_request_evt(struct hci_dev *hdev, | |||
4100 | 4100 | ||
4101 | BT_DBG("%s", hdev->name); | 4101 | BT_DBG("%s", hdev->name); |
4102 | 4102 | ||
4103 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 4103 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
4104 | mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); | 4104 | mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0); |
4105 | } | 4105 | } |
4106 | 4106 | ||
@@ -4119,7 +4119,7 @@ static void hci_user_passkey_notify_evt(struct hci_dev *hdev, | |||
4119 | conn->passkey_notify = __le32_to_cpu(ev->passkey); | 4119 | conn->passkey_notify = __le32_to_cpu(ev->passkey); |
4120 | conn->passkey_entered = 0; | 4120 | conn->passkey_entered = 0; |
4121 | 4121 | ||
4122 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 4122 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
4123 | mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, | 4123 | mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, |
4124 | conn->dst_type, conn->passkey_notify, | 4124 | conn->dst_type, conn->passkey_notify, |
4125 | conn->passkey_entered); | 4125 | conn->passkey_entered); |
@@ -4157,7 +4157,7 @@ static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4157 | return; | 4157 | return; |
4158 | } | 4158 | } |
4159 | 4159 | ||
4160 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 4160 | if (hci_dev_test_flag(hdev, HCI_MGMT)) |
4161 | mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, | 4161 | mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, |
4162 | conn->dst_type, conn->passkey_notify, | 4162 | conn->dst_type, conn->passkey_notify, |
4163 | conn->passkey_entered); | 4163 | conn->passkey_entered); |
@@ -4226,7 +4226,7 @@ static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, | |||
4226 | 4226 | ||
4227 | hci_dev_lock(hdev); | 4227 | hci_dev_lock(hdev); |
4228 | 4228 | ||
4229 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 4229 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
4230 | goto unlock; | 4230 | goto unlock; |
4231 | 4231 | ||
4232 | data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); | 4232 | data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR); |
@@ -4243,7 +4243,7 @@ static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, | |||
4243 | struct hci_cp_remote_oob_ext_data_reply cp; | 4243 | struct hci_cp_remote_oob_ext_data_reply cp; |
4244 | 4244 | ||
4245 | bacpy(&cp.bdaddr, &ev->bdaddr); | 4245 | bacpy(&cp.bdaddr, &ev->bdaddr); |
4246 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags)) { | 4246 | if (hci_dev_test_flag(hdev, HCI_SC_ONLY)) { |
4247 | memset(cp.hash192, 0, sizeof(cp.hash192)); | 4247 | memset(cp.hash192, 0, sizeof(cp.hash192)); |
4248 | memset(cp.rand192, 0, sizeof(cp.rand192)); | 4248 | memset(cp.rand192, 0, sizeof(cp.rand192)); |
4249 | } else { | 4249 | } else { |
@@ -4432,7 +4432,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4432 | if (conn->out) { | 4432 | if (conn->out) { |
4433 | conn->resp_addr_type = ev->bdaddr_type; | 4433 | conn->resp_addr_type = ev->bdaddr_type; |
4434 | bacpy(&conn->resp_addr, &ev->bdaddr); | 4434 | bacpy(&conn->resp_addr, &ev->bdaddr); |
4435 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) { | 4435 | if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { |
4436 | conn->init_addr_type = ADDR_LE_DEV_RANDOM; | 4436 | conn->init_addr_type = ADDR_LE_DEV_RANDOM; |
4437 | bacpy(&conn->init_addr, &hdev->rpa); | 4437 | bacpy(&conn->init_addr, &hdev->rpa); |
4438 | } else { | 4438 | } else { |
@@ -4658,7 +4658,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr, | |||
4658 | /* If the controller is not using resolvable random | 4658 | /* If the controller is not using resolvable random |
4659 | * addresses, then this report can be ignored. | 4659 | * addresses, then this report can be ignored. |
4660 | */ | 4660 | */ |
4661 | if (!test_bit(HCI_PRIVACY, &hdev->dev_flags)) | 4661 | if (!hci_dev_test_flag(hdev, HCI_PRIVACY)) |
4662 | return; | 4662 | return; |
4663 | 4663 | ||
4664 | /* If the local IRK of the controller does not match | 4664 | /* If the local IRK of the controller does not match |
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index f857e765e081..42fa10522e89 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c | |||
@@ -270,7 +270,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) | |||
270 | * and 0x01 (whitelist enabled) use the new filter policies | 270 | * and 0x01 (whitelist enabled) use the new filter policies |
271 | * 0x02 (no whitelist) and 0x03 (whitelist enabled). | 271 | * 0x02 (no whitelist) and 0x03 (whitelist enabled). |
272 | */ | 272 | */ |
273 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags) && | 273 | if (hci_dev_test_flag(hdev, HCI_PRIVACY) && |
274 | (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)) | 274 | (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)) |
275 | filter_policy |= 0x02; | 275 | filter_policy |= 0x02; |
276 | 276 | ||
@@ -304,7 +304,7 @@ static void set_random_addr(struct hci_request *req, bdaddr_t *rpa) | |||
304 | * In this kind of scenario skip the update and let the random | 304 | * In this kind of scenario skip the update and let the random |
305 | * address be updated at the next cycle. | 305 | * address be updated at the next cycle. |
306 | */ | 306 | */ |
307 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags) || | 307 | if (hci_dev_test_flag(hdev, HCI_LE_ADV) || |
308 | hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) { | 308 | hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT)) { |
309 | BT_DBG("Deferring random address update"); | 309 | BT_DBG("Deferring random address update"); |
310 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); | 310 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); |
@@ -324,7 +324,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, | |||
324 | * current RPA has expired or there is something else than | 324 | * current RPA has expired or there is something else than |
325 | * the current RPA in use, then generate a new one. | 325 | * the current RPA in use, then generate a new one. |
326 | */ | 326 | */ |
327 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) { | 327 | if (hci_dev_test_flag(hdev, HCI_PRIVACY)) { |
328 | int to; | 328 | int to; |
329 | 329 | ||
330 | *own_addr_type = ADDR_LE_DEV_RANDOM; | 330 | *own_addr_type = ADDR_LE_DEV_RANDOM; |
@@ -385,7 +385,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, | |||
385 | */ | 385 | */ |
386 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || | 386 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || |
387 | !bacmp(&hdev->bdaddr, BDADDR_ANY) || | 387 | !bacmp(&hdev->bdaddr, BDADDR_ANY) || |
388 | (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && | 388 | (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) && |
389 | bacmp(&hdev->static_addr, BDADDR_ANY))) { | 389 | bacmp(&hdev->static_addr, BDADDR_ANY))) { |
390 | *own_addr_type = ADDR_LE_DEV_RANDOM; | 390 | *own_addr_type = ADDR_LE_DEV_RANDOM; |
391 | if (bacmp(&hdev->static_addr, &hdev->random_addr)) | 391 | if (bacmp(&hdev->static_addr, &hdev->random_addr)) |
@@ -425,7 +425,7 @@ void __hci_update_page_scan(struct hci_request *req) | |||
425 | struct hci_dev *hdev = req->hdev; | 425 | struct hci_dev *hdev = req->hdev; |
426 | u8 scan; | 426 | u8 scan; |
427 | 427 | ||
428 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 428 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
429 | return; | 429 | return; |
430 | 430 | ||
431 | if (!hdev_is_powered(hdev)) | 431 | if (!hdev_is_powered(hdev)) |
@@ -434,7 +434,7 @@ void __hci_update_page_scan(struct hci_request *req) | |||
434 | if (mgmt_powering_down(hdev)) | 434 | if (mgmt_powering_down(hdev)) |
435 | return; | 435 | return; |
436 | 436 | ||
437 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags) || | 437 | if (hci_dev_test_flag(hdev, HCI_CONNECTABLE) || |
438 | disconnected_whitelist_entries(hdev)) | 438 | disconnected_whitelist_entries(hdev)) |
439 | scan = SCAN_PAGE; | 439 | scan = SCAN_PAGE; |
440 | else | 440 | else |
@@ -443,7 +443,7 @@ void __hci_update_page_scan(struct hci_request *req) | |||
443 | if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE)) | 443 | if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE)) |
444 | return; | 444 | return; |
445 | 445 | ||
446 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | 446 | if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) |
447 | scan |= SCAN_INQUIRY; | 447 | scan |= SCAN_INQUIRY; |
448 | 448 | ||
449 | hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); | 449 | hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); |
@@ -471,14 +471,14 @@ void __hci_update_background_scan(struct hci_request *req) | |||
471 | 471 | ||
472 | if (!test_bit(HCI_UP, &hdev->flags) || | 472 | if (!test_bit(HCI_UP, &hdev->flags) || |
473 | test_bit(HCI_INIT, &hdev->flags) || | 473 | test_bit(HCI_INIT, &hdev->flags) || |
474 | test_bit(HCI_SETUP, &hdev->dev_flags) || | 474 | hci_dev_test_flag(hdev, HCI_SETUP) || |
475 | test_bit(HCI_CONFIG, &hdev->dev_flags) || | 475 | hci_dev_test_flag(hdev, HCI_CONFIG) || |
476 | test_bit(HCI_AUTO_OFF, &hdev->dev_flags) || | 476 | hci_dev_test_flag(hdev, HCI_AUTO_OFF) || |
477 | test_bit(HCI_UNREGISTER, &hdev->dev_flags)) | 477 | hci_dev_test_flag(hdev, HCI_UNREGISTER)) |
478 | return; | 478 | return; |
479 | 479 | ||
480 | /* No point in doing scanning if LE support hasn't been enabled */ | 480 | /* No point in doing scanning if LE support hasn't been enabled */ |
481 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 481 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
482 | return; | 482 | return; |
483 | 483 | ||
484 | /* If discovery is active don't interfere with it */ | 484 | /* If discovery is active don't interfere with it */ |
@@ -502,7 +502,7 @@ void __hci_update_background_scan(struct hci_request *req) | |||
502 | */ | 502 | */ |
503 | 503 | ||
504 | /* If controller is not scanning we are done. */ | 504 | /* If controller is not scanning we are done. */ |
505 | if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags)) | 505 | if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) |
506 | return; | 506 | return; |
507 | 507 | ||
508 | hci_req_add_le_scan_disable(req); | 508 | hci_req_add_le_scan_disable(req); |
@@ -524,7 +524,7 @@ void __hci_update_background_scan(struct hci_request *req) | |||
524 | /* If controller is currently scanning, we stop it to ensure we | 524 | /* If controller is currently scanning, we stop it to ensure we |
525 | * don't miss any advertising (due to duplicates filter). | 525 | * don't miss any advertising (due to duplicates filter). |
526 | */ | 526 | */ |
527 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) | 527 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) |
528 | hci_req_add_le_scan_disable(req); | 528 | hci_req_add_le_scan_disable(req); |
529 | 529 | ||
530 | hci_req_add_le_passive_scan(req); | 530 | hci_req_add_le_passive_scan(req); |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index aa9ffcb9481f..b297709d82bf 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -534,10 +534,10 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, | |||
534 | if (!hdev) | 534 | if (!hdev) |
535 | return -EBADFD; | 535 | return -EBADFD; |
536 | 536 | ||
537 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 537 | if (hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) |
538 | return -EBUSY; | 538 | return -EBUSY; |
539 | 539 | ||
540 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 540 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
541 | return -EOPNOTSUPP; | 541 | return -EOPNOTSUPP; |
542 | 542 | ||
543 | if (hdev->dev_type != HCI_BREDR) | 543 | if (hdev->dev_type != HCI_BREDR) |
@@ -713,8 +713,8 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
713 | 713 | ||
714 | if (test_bit(HCI_UP, &hdev->flags) || | 714 | if (test_bit(HCI_UP, &hdev->flags) || |
715 | test_bit(HCI_INIT, &hdev->flags) || | 715 | test_bit(HCI_INIT, &hdev->flags) || |
716 | test_bit(HCI_SETUP, &hdev->dev_flags) || | 716 | hci_dev_test_flag(hdev, HCI_SETUP) || |
717 | test_bit(HCI_CONFIG, &hdev->dev_flags)) { | 717 | hci_dev_test_flag(hdev, HCI_CONFIG)) { |
718 | err = -EBUSY; | 718 | err = -EBUSY; |
719 | hci_dev_put(hdev); | 719 | hci_dev_put(hdev); |
720 | goto done; | 720 | goto done; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 91c682846bcf..af30d8240c80 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -3900,7 +3900,7 @@ static int l2cap_connect_req(struct l2cap_conn *conn, | |||
3900 | return -EPROTO; | 3900 | return -EPROTO; |
3901 | 3901 | ||
3902 | hci_dev_lock(hdev); | 3902 | hci_dev_lock(hdev); |
3903 | if (test_bit(HCI_MGMT, &hdev->dev_flags) && | 3903 | if (hci_dev_test_flag(hdev, HCI_MGMT) && |
3904 | !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags)) | 3904 | !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &hcon->flags)) |
3905 | mgmt_device_connected(hdev, hcon, 0, NULL, 0); | 3905 | mgmt_device_connected(hdev, hcon, 0, NULL, 0); |
3906 | hci_dev_unlock(hdev); | 3906 | hci_dev_unlock(hdev); |
@@ -6987,10 +6987,10 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) | |||
6987 | conn->local_fixed_chan = L2CAP_FC_SIG_BREDR | L2CAP_FC_CONNLESS; | 6987 | conn->local_fixed_chan = L2CAP_FC_SIG_BREDR | L2CAP_FC_CONNLESS; |
6988 | 6988 | ||
6989 | if (hcon->type == ACL_LINK && | 6989 | if (hcon->type == ACL_LINK && |
6990 | test_bit(HCI_HS_ENABLED, &hcon->hdev->dev_flags)) | 6990 | hci_dev_test_flag(hcon->hdev, HCI_HS_ENABLED)) |
6991 | conn->local_fixed_chan |= L2CAP_FC_A2MP; | 6991 | conn->local_fixed_chan |= L2CAP_FC_A2MP; |
6992 | 6992 | ||
6993 | if (test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags) && | 6993 | if (hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED) && |
6994 | (bredr_sc_enabled(hcon->hdev) || | 6994 | (bredr_sc_enabled(hcon->hdev) || |
6995 | test_bit(HCI_FORCE_BREDR_SMP, &hcon->hdev->dbg_flags))) | 6995 | test_bit(HCI_FORCE_BREDR_SMP, &hcon->hdev->dbg_flags))) |
6996 | conn->local_fixed_chan |= L2CAP_FC_SMP_BREDR; | 6996 | conn->local_fixed_chan |= L2CAP_FC_SMP_BREDR; |
@@ -7112,7 +7112,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
7112 | else | 7112 | else |
7113 | dst_type = ADDR_LE_DEV_RANDOM; | 7113 | dst_type = ADDR_LE_DEV_RANDOM; |
7114 | 7114 | ||
7115 | if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 7115 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
7116 | role = HCI_ROLE_SLAVE; | 7116 | role = HCI_ROLE_SLAVE; |
7117 | else | 7117 | else |
7118 | role = HCI_ROLE_MASTER; | 7118 | role = HCI_ROLE_MASTER; |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0761f2e0fefa..596b36111e64 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -385,7 +385,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
385 | count = 0; | 385 | count = 0; |
386 | list_for_each_entry(d, &hci_dev_list, list) { | 386 | list_for_each_entry(d, &hci_dev_list, list) { |
387 | if (d->dev_type == HCI_BREDR && | 387 | if (d->dev_type == HCI_BREDR && |
388 | !test_bit(HCI_UNCONFIGURED, &d->dev_flags)) | 388 | !hci_dev_test_flag(d, HCI_UNCONFIGURED)) |
389 | count++; | 389 | count++; |
390 | } | 390 | } |
391 | 391 | ||
@@ -398,9 +398,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
398 | 398 | ||
399 | count = 0; | 399 | count = 0; |
400 | list_for_each_entry(d, &hci_dev_list, list) { | 400 | list_for_each_entry(d, &hci_dev_list, list) { |
401 | if (test_bit(HCI_SETUP, &d->dev_flags) || | 401 | if (hci_dev_test_flag(d, HCI_SETUP) || |
402 | test_bit(HCI_CONFIG, &d->dev_flags) || | 402 | hci_dev_test_flag(d, HCI_CONFIG) || |
403 | test_bit(HCI_USER_CHANNEL, &d->dev_flags)) | 403 | hci_dev_test_flag(d, HCI_USER_CHANNEL)) |
404 | continue; | 404 | continue; |
405 | 405 | ||
406 | /* Devices marked as raw-only are neither configured | 406 | /* Devices marked as raw-only are neither configured |
@@ -410,7 +410,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
410 | continue; | 410 | continue; |
411 | 411 | ||
412 | if (d->dev_type == HCI_BREDR && | 412 | if (d->dev_type == HCI_BREDR && |
413 | !test_bit(HCI_UNCONFIGURED, &d->dev_flags)) { | 413 | !hci_dev_test_flag(d, HCI_UNCONFIGURED)) { |
414 | rp->index[count++] = cpu_to_le16(d->id); | 414 | rp->index[count++] = cpu_to_le16(d->id); |
415 | BT_DBG("Added hci%u", d->id); | 415 | BT_DBG("Added hci%u", d->id); |
416 | } | 416 | } |
@@ -445,7 +445,7 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev, | |||
445 | count = 0; | 445 | count = 0; |
446 | list_for_each_entry(d, &hci_dev_list, list) { | 446 | list_for_each_entry(d, &hci_dev_list, list) { |
447 | if (d->dev_type == HCI_BREDR && | 447 | if (d->dev_type == HCI_BREDR && |
448 | test_bit(HCI_UNCONFIGURED, &d->dev_flags)) | 448 | hci_dev_test_flag(d, HCI_UNCONFIGURED)) |
449 | count++; | 449 | count++; |
450 | } | 450 | } |
451 | 451 | ||
@@ -458,9 +458,9 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev, | |||
458 | 458 | ||
459 | count = 0; | 459 | count = 0; |
460 | list_for_each_entry(d, &hci_dev_list, list) { | 460 | list_for_each_entry(d, &hci_dev_list, list) { |
461 | if (test_bit(HCI_SETUP, &d->dev_flags) || | 461 | if (hci_dev_test_flag(d, HCI_SETUP) || |
462 | test_bit(HCI_CONFIG, &d->dev_flags) || | 462 | hci_dev_test_flag(d, HCI_CONFIG) || |
463 | test_bit(HCI_USER_CHANNEL, &d->dev_flags)) | 463 | hci_dev_test_flag(d, HCI_USER_CHANNEL)) |
464 | continue; | 464 | continue; |
465 | 465 | ||
466 | /* Devices marked as raw-only are neither configured | 466 | /* Devices marked as raw-only are neither configured |
@@ -470,7 +470,7 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev, | |||
470 | continue; | 470 | continue; |
471 | 471 | ||
472 | if (d->dev_type == HCI_BREDR && | 472 | if (d->dev_type == HCI_BREDR && |
473 | test_bit(HCI_UNCONFIGURED, &d->dev_flags)) { | 473 | hci_dev_test_flag(d, HCI_UNCONFIGURED)) { |
474 | rp->index[count++] = cpu_to_le16(d->id); | 474 | rp->index[count++] = cpu_to_le16(d->id); |
475 | BT_DBG("Added hci%u", d->id); | 475 | BT_DBG("Added hci%u", d->id); |
476 | } | 476 | } |
@@ -492,7 +492,7 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev, | |||
492 | static bool is_configured(struct hci_dev *hdev) | 492 | static bool is_configured(struct hci_dev *hdev) |
493 | { | 493 | { |
494 | if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && | 494 | if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && |
495 | !test_bit(HCI_EXT_CONFIGURED, &hdev->dev_flags)) | 495 | !hci_dev_test_flag(hdev, HCI_EXT_CONFIGURED)) |
496 | return false; | 496 | return false; |
497 | 497 | ||
498 | if (test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) && | 498 | if (test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) && |
@@ -507,7 +507,7 @@ static __le32 get_missing_options(struct hci_dev *hdev) | |||
507 | u32 options = 0; | 507 | u32 options = 0; |
508 | 508 | ||
509 | if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && | 509 | if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) && |
510 | !test_bit(HCI_EXT_CONFIGURED, &hdev->dev_flags)) | 510 | !hci_dev_test_flag(hdev, HCI_EXT_CONFIGURED)) |
511 | options |= MGMT_OPTION_EXTERNAL_CONFIG; | 511 | options |= MGMT_OPTION_EXTERNAL_CONFIG; |
512 | 512 | ||
513 | if (test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) && | 513 | if (test_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks) && |
@@ -608,43 +608,43 @@ static u32 get_current_settings(struct hci_dev *hdev) | |||
608 | if (hdev_is_powered(hdev)) | 608 | if (hdev_is_powered(hdev)) |
609 | settings |= MGMT_SETTING_POWERED; | 609 | settings |= MGMT_SETTING_POWERED; |
610 | 610 | ||
611 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | 611 | if (hci_dev_test_flag(hdev, HCI_CONNECTABLE)) |
612 | settings |= MGMT_SETTING_CONNECTABLE; | 612 | settings |= MGMT_SETTING_CONNECTABLE; |
613 | 613 | ||
614 | if (test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) | 614 | if (hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) |
615 | settings |= MGMT_SETTING_FAST_CONNECTABLE; | 615 | settings |= MGMT_SETTING_FAST_CONNECTABLE; |
616 | 616 | ||
617 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | 617 | if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) |
618 | settings |= MGMT_SETTING_DISCOVERABLE; | 618 | settings |= MGMT_SETTING_DISCOVERABLE; |
619 | 619 | ||
620 | if (test_bit(HCI_BONDABLE, &hdev->dev_flags)) | 620 | if (hci_dev_test_flag(hdev, HCI_BONDABLE)) |
621 | settings |= MGMT_SETTING_BONDABLE; | 621 | settings |= MGMT_SETTING_BONDABLE; |
622 | 622 | ||
623 | if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 623 | if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
624 | settings |= MGMT_SETTING_BREDR; | 624 | settings |= MGMT_SETTING_BREDR; |
625 | 625 | ||
626 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 626 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
627 | settings |= MGMT_SETTING_LE; | 627 | settings |= MGMT_SETTING_LE; |
628 | 628 | ||
629 | if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags)) | 629 | if (hci_dev_test_flag(hdev, HCI_LINK_SECURITY)) |
630 | settings |= MGMT_SETTING_LINK_SECURITY; | 630 | settings |= MGMT_SETTING_LINK_SECURITY; |
631 | 631 | ||
632 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) | 632 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) |
633 | settings |= MGMT_SETTING_SSP; | 633 | settings |= MGMT_SETTING_SSP; |
634 | 634 | ||
635 | if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags)) | 635 | if (hci_dev_test_flag(hdev, HCI_HS_ENABLED)) |
636 | settings |= MGMT_SETTING_HS; | 636 | settings |= MGMT_SETTING_HS; |
637 | 637 | ||
638 | if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 638 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
639 | settings |= MGMT_SETTING_ADVERTISING; | 639 | settings |= MGMT_SETTING_ADVERTISING; |
640 | 640 | ||
641 | if (test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) | 641 | if (hci_dev_test_flag(hdev, HCI_SC_ENABLED)) |
642 | settings |= MGMT_SETTING_SECURE_CONN; | 642 | settings |= MGMT_SETTING_SECURE_CONN; |
643 | 643 | ||
644 | if (test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags)) | 644 | if (hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) |
645 | settings |= MGMT_SETTING_DEBUG_KEYS; | 645 | settings |= MGMT_SETTING_DEBUG_KEYS; |
646 | 646 | ||
647 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) | 647 | if (hci_dev_test_flag(hdev, HCI_PRIVACY)) |
648 | settings |= MGMT_SETTING_PRIVACY; | 648 | settings |= MGMT_SETTING_PRIVACY; |
649 | 649 | ||
650 | /* The current setting for static address has two purposes. The | 650 | /* The current setting for static address has two purposes. The |
@@ -660,7 +660,7 @@ static u32 get_current_settings(struct hci_dev *hdev) | |||
660 | * be evaluated. | 660 | * be evaluated. |
661 | */ | 661 | */ |
662 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || | 662 | if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) || |
663 | !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) || | 663 | !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) || |
664 | !bacmp(&hdev->bdaddr, BDADDR_ANY)) { | 664 | !bacmp(&hdev->bdaddr, BDADDR_ANY)) { |
665 | if (bacmp(&hdev->static_addr, BDADDR_ANY)) | 665 | if (bacmp(&hdev->static_addr, BDADDR_ANY)) |
666 | settings |= MGMT_SETTING_STATIC_ADDRESS; | 666 | settings |= MGMT_SETTING_STATIC_ADDRESS; |
@@ -840,7 +840,7 @@ static void update_scan_rsp_data(struct hci_request *req) | |||
840 | struct hci_cp_le_set_scan_rsp_data cp; | 840 | struct hci_cp_le_set_scan_rsp_data cp; |
841 | u8 len; | 841 | u8 len; |
842 | 842 | ||
843 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 843 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
844 | return; | 844 | return; |
845 | 845 | ||
846 | memset(&cp, 0, sizeof(cp)); | 846 | memset(&cp, 0, sizeof(cp)); |
@@ -874,9 +874,9 @@ static u8 get_adv_discov_flags(struct hci_dev *hdev) | |||
874 | else if (cp->val == 0x02) | 874 | else if (cp->val == 0x02) |
875 | return LE_AD_LIMITED; | 875 | return LE_AD_LIMITED; |
876 | } else { | 876 | } else { |
877 | if (test_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags)) | 877 | if (hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) |
878 | return LE_AD_LIMITED; | 878 | return LE_AD_LIMITED; |
879 | else if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | 879 | else if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) |
880 | return LE_AD_GENERAL; | 880 | return LE_AD_GENERAL; |
881 | } | 881 | } |
882 | 882 | ||
@@ -889,7 +889,7 @@ static u8 create_adv_data(struct hci_dev *hdev, u8 *ptr) | |||
889 | 889 | ||
890 | flags |= get_adv_discov_flags(hdev); | 890 | flags |= get_adv_discov_flags(hdev); |
891 | 891 | ||
892 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 892 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
893 | flags |= LE_AD_NO_BREDR; | 893 | flags |= LE_AD_NO_BREDR; |
894 | 894 | ||
895 | if (flags) { | 895 | if (flags) { |
@@ -921,7 +921,7 @@ static void update_adv_data(struct hci_request *req) | |||
921 | struct hci_cp_le_set_adv_data cp; | 921 | struct hci_cp_le_set_adv_data cp; |
922 | u8 len; | 922 | u8 len; |
923 | 923 | ||
924 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 924 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
925 | return; | 925 | return; |
926 | 926 | ||
927 | memset(&cp, 0, sizeof(cp)); | 927 | memset(&cp, 0, sizeof(cp)); |
@@ -1009,10 +1009,10 @@ static void update_eir(struct hci_request *req) | |||
1009 | if (!lmp_ext_inq_capable(hdev)) | 1009 | if (!lmp_ext_inq_capable(hdev)) |
1010 | return; | 1010 | return; |
1011 | 1011 | ||
1012 | if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) | 1012 | if (!hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) |
1013 | return; | 1013 | return; |
1014 | 1014 | ||
1015 | if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) | 1015 | if (hci_dev_test_flag(hdev, HCI_SERVICE_CACHE)) |
1016 | return; | 1016 | return; |
1017 | 1017 | ||
1018 | memset(&cp, 0, sizeof(cp)); | 1018 | memset(&cp, 0, sizeof(cp)); |
@@ -1048,17 +1048,17 @@ static void update_class(struct hci_request *req) | |||
1048 | if (!hdev_is_powered(hdev)) | 1048 | if (!hdev_is_powered(hdev)) |
1049 | return; | 1049 | return; |
1050 | 1050 | ||
1051 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1051 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1052 | return; | 1052 | return; |
1053 | 1053 | ||
1054 | if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) | 1054 | if (hci_dev_test_flag(hdev, HCI_SERVICE_CACHE)) |
1055 | return; | 1055 | return; |
1056 | 1056 | ||
1057 | cod[0] = hdev->minor_class; | 1057 | cod[0] = hdev->minor_class; |
1058 | cod[1] = hdev->major_class; | 1058 | cod[1] = hdev->major_class; |
1059 | cod[2] = get_service_classes(hdev); | 1059 | cod[2] = get_service_classes(hdev); |
1060 | 1060 | ||
1061 | if (test_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags)) | 1061 | if (hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) |
1062 | cod[1] |= 0x20; | 1062 | cod[1] |= 0x20; |
1063 | 1063 | ||
1064 | if (memcmp(cod, hdev->dev_class, 3) == 0) | 1064 | if (memcmp(cod, hdev->dev_class, 3) == 0) |
@@ -1080,7 +1080,7 @@ static bool get_connectable(struct hci_dev *hdev) | |||
1080 | return cp->val; | 1080 | return cp->val; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | return test_bit(HCI_CONNECTABLE, &hdev->dev_flags); | 1083 | return hci_dev_test_flag(hdev, HCI_CONNECTABLE); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | static void disable_advertising(struct hci_request *req) | 1086 | static void disable_advertising(struct hci_request *req) |
@@ -1100,7 +1100,7 @@ static void enable_advertising(struct hci_request *req) | |||
1100 | if (hci_conn_num(hdev, LE_LINK) > 0) | 1100 | if (hci_conn_num(hdev, LE_LINK) > 0) |
1101 | return; | 1101 | return; |
1102 | 1102 | ||
1103 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) | 1103 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) |
1104 | disable_advertising(req); | 1104 | disable_advertising(req); |
1105 | 1105 | ||
1106 | /* Clear the HCI_LE_ADV bit temporarily so that the | 1106 | /* Clear the HCI_LE_ADV bit temporarily so that the |
@@ -1110,7 +1110,7 @@ static void enable_advertising(struct hci_request *req) | |||
1110 | */ | 1110 | */ |
1111 | clear_bit(HCI_LE_ADV, &hdev->dev_flags); | 1111 | clear_bit(HCI_LE_ADV, &hdev->dev_flags); |
1112 | 1112 | ||
1113 | if (test_bit(HCI_ADVERTISING_CONNECTABLE, &hdev->dev_flags)) | 1113 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING_CONNECTABLE)) |
1114 | connectable = true; | 1114 | connectable = true; |
1115 | else | 1115 | else |
1116 | connectable = get_connectable(hdev); | 1116 | connectable = get_connectable(hdev); |
@@ -1165,7 +1165,7 @@ static void rpa_expired(struct work_struct *work) | |||
1165 | 1165 | ||
1166 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); | 1166 | set_bit(HCI_RPA_EXPIRED, &hdev->dev_flags); |
1167 | 1167 | ||
1168 | if (!test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 1168 | if (!hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
1169 | return; | 1169 | return; |
1170 | 1170 | ||
1171 | /* The generation of a new RPA and programming it into the | 1171 | /* The generation of a new RPA and programming it into the |
@@ -1328,7 +1328,7 @@ static bool hci_stop_discovery(struct hci_request *req) | |||
1328 | 1328 | ||
1329 | default: | 1329 | default: |
1330 | /* Passive scanning */ | 1330 | /* Passive scanning */ |
1331 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) { | 1331 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { |
1332 | hci_req_add_le_scan_disable(req); | 1332 | hci_req_add_le_scan_disable(req); |
1333 | return true; | 1333 | return true; |
1334 | } | 1334 | } |
@@ -1354,7 +1354,7 @@ static int clean_up_hci_state(struct hci_dev *hdev) | |||
1354 | hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); | 1354 | hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) | 1357 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) |
1358 | disable_advertising(&req); | 1358 | disable_advertising(&req); |
1359 | 1359 | ||
1360 | discov_stopped = hci_stop_discovery(&req); | 1360 | discov_stopped = hci_stop_discovery(&req); |
@@ -1538,7 +1538,7 @@ static u8 mgmt_bredr_support(struct hci_dev *hdev) | |||
1538 | { | 1538 | { |
1539 | if (!lmp_bredr_capable(hdev)) | 1539 | if (!lmp_bredr_capable(hdev)) |
1540 | return MGMT_STATUS_NOT_SUPPORTED; | 1540 | return MGMT_STATUS_NOT_SUPPORTED; |
1541 | else if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1541 | else if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1542 | return MGMT_STATUS_REJECTED; | 1542 | return MGMT_STATUS_REJECTED; |
1543 | else | 1543 | else |
1544 | return MGMT_STATUS_SUCCESS; | 1544 | return MGMT_STATUS_SUCCESS; |
@@ -1548,7 +1548,7 @@ static u8 mgmt_le_support(struct hci_dev *hdev) | |||
1548 | { | 1548 | { |
1549 | if (!lmp_le_capable(hdev)) | 1549 | if (!lmp_le_capable(hdev)) |
1550 | return MGMT_STATUS_NOT_SUPPORTED; | 1550 | return MGMT_STATUS_NOT_SUPPORTED; |
1551 | else if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 1551 | else if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
1552 | return MGMT_STATUS_REJECTED; | 1552 | return MGMT_STATUS_REJECTED; |
1553 | else | 1553 | else |
1554 | return MGMT_STATUS_SUCCESS; | 1554 | return MGMT_STATUS_SUCCESS; |
@@ -1626,8 +1626,8 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1626 | 1626 | ||
1627 | BT_DBG("request for %s", hdev->name); | 1627 | BT_DBG("request for %s", hdev->name); |
1628 | 1628 | ||
1629 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && | 1629 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED) && |
1630 | !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1630 | !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1631 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, | 1631 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, |
1632 | MGMT_STATUS_REJECTED); | 1632 | MGMT_STATUS_REJECTED); |
1633 | 1633 | ||
@@ -1660,7 +1660,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1660 | goto failed; | 1660 | goto failed; |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) { | 1663 | if (!hci_dev_test_flag(hdev, HCI_CONNECTABLE)) { |
1664 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, | 1664 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, |
1665 | MGMT_STATUS_REJECTED); | 1665 | MGMT_STATUS_REJECTED); |
1666 | goto failed; | 1666 | goto failed; |
@@ -1673,7 +1673,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1673 | * not a valid operation since it requires a timeout | 1673 | * not a valid operation since it requires a timeout |
1674 | * and so no need to check HCI_LIMITED_DISCOVERABLE. | 1674 | * and so no need to check HCI_LIMITED_DISCOVERABLE. |
1675 | */ | 1675 | */ |
1676 | if (!!cp->val != test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) { | 1676 | if (!!cp->val != hci_dev_test_flag(hdev, HCI_DISCOVERABLE)) { |
1677 | change_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 1677 | change_bit(HCI_DISCOVERABLE, &hdev->dev_flags); |
1678 | changed = true; | 1678 | changed = true; |
1679 | } | 1679 | } |
@@ -1692,9 +1692,9 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1692 | * value with the new value. And if only the timeout gets updated, | 1692 | * value with the new value. And if only the timeout gets updated, |
1693 | * then no need for any HCI transactions. | 1693 | * then no need for any HCI transactions. |
1694 | */ | 1694 | */ |
1695 | if (!!cp->val == test_bit(HCI_DISCOVERABLE, &hdev->dev_flags) && | 1695 | if (!!cp->val == hci_dev_test_flag(hdev, HCI_DISCOVERABLE) && |
1696 | (cp->val == 0x02) == test_bit(HCI_LIMITED_DISCOVERABLE, | 1696 | (cp->val == 0x02) == hci_dev_test_flag(hdev, |
1697 | &hdev->dev_flags)) { | 1697 | HCI_LIMITED_DISCOVERABLE)) { |
1698 | cancel_delayed_work(&hdev->discov_off); | 1698 | cancel_delayed_work(&hdev->discov_off); |
1699 | hdev->discov_timeout = timeout; | 1699 | hdev->discov_timeout = timeout; |
1700 | 1700 | ||
@@ -1732,7 +1732,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1732 | /* The procedure for LE-only controllers is much simpler - just | 1732 | /* The procedure for LE-only controllers is much simpler - just |
1733 | * update the advertising data. | 1733 | * update the advertising data. |
1734 | */ | 1734 | */ |
1735 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1735 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1736 | goto update_ad; | 1736 | goto update_ad; |
1737 | 1737 | ||
1738 | scan = SCAN_PAGE; | 1738 | scan = SCAN_PAGE; |
@@ -1785,7 +1785,7 @@ static void write_fast_connectable(struct hci_request *req, bool enable) | |||
1785 | struct hci_cp_write_page_scan_activity acp; | 1785 | struct hci_cp_write_page_scan_activity acp; |
1786 | u8 type; | 1786 | u8 type; |
1787 | 1787 | ||
1788 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1788 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1789 | return; | 1789 | return; |
1790 | 1790 | ||
1791 | if (hdev->hci_ver < BLUETOOTH_VER_1_2) | 1791 | if (hdev->hci_ver < BLUETOOTH_VER_1_2) |
@@ -1870,7 +1870,7 @@ static int set_connectable_update_settings(struct hci_dev *hdev, | |||
1870 | bool changed = false; | 1870 | bool changed = false; |
1871 | int err; | 1871 | int err; |
1872 | 1872 | ||
1873 | if (!!val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | 1873 | if (!!val != hci_dev_test_flag(hdev, HCI_CONNECTABLE)) |
1874 | changed = true; | 1874 | changed = true; |
1875 | 1875 | ||
1876 | if (val) { | 1876 | if (val) { |
@@ -1904,8 +1904,8 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1904 | 1904 | ||
1905 | BT_DBG("request for %s", hdev->name); | 1905 | BT_DBG("request for %s", hdev->name); |
1906 | 1906 | ||
1907 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && | 1907 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED) && |
1908 | !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 1908 | !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
1909 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, | 1909 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, |
1910 | MGMT_STATUS_REJECTED); | 1910 | MGMT_STATUS_REJECTED); |
1911 | 1911 | ||
@@ -1939,7 +1939,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1939 | * by-product of disabling connectable, we need to update the | 1939 | * by-product of disabling connectable, we need to update the |
1940 | * advertising flags. | 1940 | * advertising flags. |
1941 | */ | 1941 | */ |
1942 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 1942 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
1943 | if (!cp->val) { | 1943 | if (!cp->val) { |
1944 | clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags); | 1944 | clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags); |
1945 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 1945 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); |
@@ -1972,7 +1972,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1972 | 1972 | ||
1973 | no_scan_update: | 1973 | no_scan_update: |
1974 | /* Update the advertising parameters if necessary */ | 1974 | /* Update the advertising parameters if necessary */ |
1975 | if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 1975 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
1976 | enable_advertising(&req); | 1976 | enable_advertising(&req); |
1977 | 1977 | ||
1978 | err = hci_req_run(&req, set_connectable_complete); | 1978 | err = hci_req_run(&req, set_connectable_complete); |
@@ -2045,8 +2045,7 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2045 | if (!hdev_is_powered(hdev)) { | 2045 | if (!hdev_is_powered(hdev)) { |
2046 | bool changed = false; | 2046 | bool changed = false; |
2047 | 2047 | ||
2048 | if (!!cp->val != test_bit(HCI_LINK_SECURITY, | 2048 | if (!!cp->val != hci_dev_test_flag(hdev, HCI_LINK_SECURITY)) { |
2049 | &hdev->dev_flags)) { | ||
2050 | change_bit(HCI_LINK_SECURITY, &hdev->dev_flags); | 2049 | change_bit(HCI_LINK_SECURITY, &hdev->dev_flags); |
2051 | changed = true; | 2050 | changed = true; |
2052 | } | 2051 | } |
@@ -2146,7 +2145,7 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2146 | goto failed; | 2145 | goto failed; |
2147 | } | 2146 | } |
2148 | 2147 | ||
2149 | if (!!cp->val == test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 2148 | if (!!cp->val == hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { |
2150 | err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev); | 2149 | err = send_settings_rsp(sk, MGMT_OP_SET_SSP, hdev); |
2151 | goto failed; | 2150 | goto failed; |
2152 | } | 2151 | } |
@@ -2157,7 +2156,7 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2157 | goto failed; | 2156 | goto failed; |
2158 | } | 2157 | } |
2159 | 2158 | ||
2160 | if (!cp->val && test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags)) | 2159 | if (!cp->val && hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) |
2161 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, | 2160 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, |
2162 | sizeof(cp->val), &cp->val); | 2161 | sizeof(cp->val), &cp->val); |
2163 | 2162 | ||
@@ -2189,7 +2188,7 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2189 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, | 2188 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, |
2190 | MGMT_STATUS_NOT_SUPPORTED); | 2189 | MGMT_STATUS_NOT_SUPPORTED); |
2191 | 2190 | ||
2192 | if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) | 2191 | if (!hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) |
2193 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, | 2192 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, |
2194 | MGMT_STATUS_REJECTED); | 2193 | MGMT_STATUS_REJECTED); |
2195 | 2194 | ||
@@ -2255,7 +2254,7 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) | |||
2255 | * has actually been enabled. During power on, the | 2254 | * has actually been enabled. During power on, the |
2256 | * update in powered_update_hci will take care of it. | 2255 | * update in powered_update_hci will take care of it. |
2257 | */ | 2256 | */ |
2258 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 2257 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { |
2259 | struct hci_request req; | 2258 | struct hci_request req; |
2260 | 2259 | ||
2261 | hci_req_init(&req, hdev); | 2260 | hci_req_init(&req, hdev); |
@@ -2289,7 +2288,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2289 | MGMT_STATUS_INVALID_PARAMS); | 2288 | MGMT_STATUS_INVALID_PARAMS); |
2290 | 2289 | ||
2291 | /* LE-only devices do not allow toggling LE on/off */ | 2290 | /* LE-only devices do not allow toggling LE on/off */ |
2292 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) | 2291 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) |
2293 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, | 2292 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE, |
2294 | MGMT_STATUS_REJECTED); | 2293 | MGMT_STATUS_REJECTED); |
2295 | 2294 | ||
@@ -2301,12 +2300,12 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2301 | if (!hdev_is_powered(hdev) || val == enabled) { | 2300 | if (!hdev_is_powered(hdev) || val == enabled) { |
2302 | bool changed = false; | 2301 | bool changed = false; |
2303 | 2302 | ||
2304 | if (val != test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 2303 | if (val != hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { |
2305 | change_bit(HCI_LE_ENABLED, &hdev->dev_flags); | 2304 | change_bit(HCI_LE_ENABLED, &hdev->dev_flags); |
2306 | changed = true; | 2305 | changed = true; |
2307 | } | 2306 | } |
2308 | 2307 | ||
2309 | if (!val && test_bit(HCI_ADVERTISING, &hdev->dev_flags)) { | 2308 | if (!val && hci_dev_test_flag(hdev, HCI_ADVERTISING)) { |
2310 | clear_bit(HCI_ADVERTISING, &hdev->dev_flags); | 2309 | clear_bit(HCI_ADVERTISING, &hdev->dev_flags); |
2311 | changed = true; | 2310 | changed = true; |
2312 | } | 2311 | } |
@@ -2342,7 +2341,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
2342 | hci_cp.le = val; | 2341 | hci_cp.le = val; |
2343 | hci_cp.simul = 0x00; | 2342 | hci_cp.simul = 0x00; |
2344 | } else { | 2343 | } else { |
2345 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) | 2344 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) |
2346 | disable_advertising(&req); | 2345 | disable_advertising(&req); |
2347 | } | 2346 | } |
2348 | 2347 | ||
@@ -3860,12 +3859,12 @@ static bool trigger_discovery(struct hci_request *req, u8 *status) | |||
3860 | return false; | 3859 | return false; |
3861 | 3860 | ||
3862 | if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED && | 3861 | if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED && |
3863 | !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 3862 | !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
3864 | *status = MGMT_STATUS_NOT_SUPPORTED; | 3863 | *status = MGMT_STATUS_NOT_SUPPORTED; |
3865 | return false; | 3864 | return false; |
3866 | } | 3865 | } |
3867 | 3866 | ||
3868 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) { | 3867 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) { |
3869 | /* Don't let discovery abort an outgoing | 3868 | /* Don't let discovery abort an outgoing |
3870 | * connection attempt that's using directed | 3869 | * connection attempt that's using directed |
3871 | * advertising. | 3870 | * advertising. |
@@ -3883,7 +3882,7 @@ static bool trigger_discovery(struct hci_request *req, u8 *status) | |||
3883 | * is running. Thus, we should temporarily stop it in order to | 3882 | * is running. Thus, we should temporarily stop it in order to |
3884 | * set the discovery scanning parameters. | 3883 | * set the discovery scanning parameters. |
3885 | */ | 3884 | */ |
3886 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) | 3885 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) |
3887 | hci_req_add_le_scan_disable(req); | 3886 | hci_req_add_le_scan_disable(req); |
3888 | 3887 | ||
3889 | memset(¶m_cp, 0, sizeof(param_cp)); | 3888 | memset(¶m_cp, 0, sizeof(param_cp)); |
@@ -4007,7 +4006,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, | |||
4007 | } | 4006 | } |
4008 | 4007 | ||
4009 | if (hdev->discovery.state != DISCOVERY_STOPPED || | 4008 | if (hdev->discovery.state != DISCOVERY_STOPPED || |
4010 | test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) { | 4009 | hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) { |
4011 | err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY, | 4010 | err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY, |
4012 | MGMT_STATUS_BUSY, &cp->type, | 4011 | MGMT_STATUS_BUSY, &cp->type, |
4013 | sizeof(cp->type)); | 4012 | sizeof(cp->type)); |
@@ -4083,7 +4082,7 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, | |||
4083 | } | 4082 | } |
4084 | 4083 | ||
4085 | if (hdev->discovery.state != DISCOVERY_STOPPED || | 4084 | if (hdev->discovery.state != DISCOVERY_STOPPED || |
4086 | test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) { | 4085 | hci_dev_test_flag(hdev, HCI_PERIODIC_INQ)) { |
4087 | err = mgmt_cmd_complete(sk, hdev->id, | 4086 | err = mgmt_cmd_complete(sk, hdev->id, |
4088 | MGMT_OP_START_SERVICE_DISCOVERY, | 4087 | MGMT_OP_START_SERVICE_DISCOVERY, |
4089 | MGMT_STATUS_BUSY, &cp->type, | 4088 | MGMT_STATUS_BUSY, &cp->type, |
@@ -4410,7 +4409,7 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status, | |||
4410 | goto unlock; | 4409 | goto unlock; |
4411 | } | 4410 | } |
4412 | 4411 | ||
4413 | if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) | 4412 | if (hci_dev_test_flag(hdev, HCI_LE_ADV)) |
4414 | set_bit(HCI_ADVERTISING, &hdev->dev_flags); | 4413 | set_bit(HCI_ADVERTISING, &hdev->dev_flags); |
4415 | else | 4414 | else |
4416 | clear_bit(HCI_ADVERTISING, &hdev->dev_flags); | 4415 | clear_bit(HCI_ADVERTISING, &hdev->dev_flags); |
@@ -4457,11 +4456,10 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, | |||
4457 | * necessary). | 4456 | * necessary). |
4458 | */ | 4457 | */ |
4459 | if (!hdev_is_powered(hdev) || | 4458 | if (!hdev_is_powered(hdev) || |
4460 | (val == test_bit(HCI_ADVERTISING, &hdev->dev_flags) && | 4459 | (val == hci_dev_test_flag(hdev, HCI_ADVERTISING) && |
4461 | (cp->val == 0x02) == test_bit(HCI_ADVERTISING_CONNECTABLE, | 4460 | (cp->val == 0x02) == hci_dev_test_flag(hdev, HCI_ADVERTISING_CONNECTABLE)) || |
4462 | &hdev->dev_flags)) || | ||
4463 | hci_conn_num(hdev, LE_LINK) > 0 || | 4461 | hci_conn_num(hdev, LE_LINK) > 0 || |
4464 | (test_bit(HCI_LE_SCAN, &hdev->dev_flags) && | 4462 | (hci_dev_test_flag(hdev, HCI_LE_SCAN) && |
4465 | hdev->le_scan_type == LE_SCAN_ACTIVE)) { | 4463 | hdev->le_scan_type == LE_SCAN_ACTIVE)) { |
4466 | bool changed; | 4464 | bool changed; |
4467 | 4465 | ||
@@ -4609,7 +4607,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, | |||
4609 | /* If background scan is running, restart it so new parameters are | 4607 | /* If background scan is running, restart it so new parameters are |
4610 | * loaded. | 4608 | * loaded. |
4611 | */ | 4609 | */ |
4612 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags) && | 4610 | if (hci_dev_test_flag(hdev, HCI_LE_SCAN) && |
4613 | hdev->discovery.state == DISCOVERY_STOPPED) { | 4611 | hdev->discovery.state == DISCOVERY_STOPPED) { |
4614 | struct hci_request req; | 4612 | struct hci_request req; |
4615 | 4613 | ||
@@ -4670,7 +4668,7 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, | |||
4670 | 4668 | ||
4671 | BT_DBG("%s", hdev->name); | 4669 | BT_DBG("%s", hdev->name); |
4672 | 4670 | ||
4673 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) || | 4671 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) || |
4674 | hdev->hci_ver < BLUETOOTH_VER_1_2) | 4672 | hdev->hci_ver < BLUETOOTH_VER_1_2) |
4675 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, | 4673 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, |
4676 | MGMT_STATUS_NOT_SUPPORTED); | 4674 | MGMT_STATUS_NOT_SUPPORTED); |
@@ -4687,7 +4685,7 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, | |||
4687 | goto unlock; | 4685 | goto unlock; |
4688 | } | 4686 | } |
4689 | 4687 | ||
4690 | if (!!cp->val == test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) { | 4688 | if (!!cp->val == hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) { |
4691 | err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE, | 4689 | err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE, |
4692 | hdev); | 4690 | hdev); |
4693 | goto unlock; | 4691 | goto unlock; |
@@ -4770,7 +4768,7 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
4770 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, | 4768 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, |
4771 | MGMT_STATUS_NOT_SUPPORTED); | 4769 | MGMT_STATUS_NOT_SUPPORTED); |
4772 | 4770 | ||
4773 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 4771 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
4774 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, | 4772 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, |
4775 | MGMT_STATUS_REJECTED); | 4773 | MGMT_STATUS_REJECTED); |
4776 | 4774 | ||
@@ -4780,7 +4778,7 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
4780 | 4778 | ||
4781 | hci_dev_lock(hdev); | 4779 | hci_dev_lock(hdev); |
4782 | 4780 | ||
4783 | if (cp->val == test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 4781 | if (cp->val == hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
4784 | err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev); | 4782 | err = send_settings_rsp(sk, MGMT_OP_SET_BREDR, hdev); |
4785 | goto unlock; | 4783 | goto unlock; |
4786 | } | 4784 | } |
@@ -4824,9 +4822,9 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
4824 | * switching BR/EDR back on when secure connections has been | 4822 | * switching BR/EDR back on when secure connections has been |
4825 | * enabled is not a supported transaction. | 4823 | * enabled is not a supported transaction. |
4826 | */ | 4824 | */ |
4827 | if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && | 4825 | if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) && |
4828 | (bacmp(&hdev->static_addr, BDADDR_ANY) || | 4826 | (bacmp(&hdev->static_addr, BDADDR_ANY) || |
4829 | test_bit(HCI_SC_ENABLED, &hdev->dev_flags))) { | 4827 | hci_dev_test_flag(hdev, HCI_SC_ENABLED))) { |
4830 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, | 4828 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, |
4831 | MGMT_STATUS_REJECTED); | 4829 | MGMT_STATUS_REJECTED); |
4832 | goto unlock; | 4830 | goto unlock; |
@@ -4926,13 +4924,13 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev, | |||
4926 | BT_DBG("request for %s", hdev->name); | 4924 | BT_DBG("request for %s", hdev->name); |
4927 | 4925 | ||
4928 | if (!lmp_sc_capable(hdev) && | 4926 | if (!lmp_sc_capable(hdev) && |
4929 | !test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 4927 | !hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
4930 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, | 4928 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, |
4931 | MGMT_STATUS_NOT_SUPPORTED); | 4929 | MGMT_STATUS_NOT_SUPPORTED); |
4932 | 4930 | ||
4933 | if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && | 4931 | if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) && |
4934 | lmp_sc_capable(hdev) && | 4932 | lmp_sc_capable(hdev) && |
4935 | !test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) | 4933 | !hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) |
4936 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, | 4934 | return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, |
4937 | MGMT_STATUS_REJECTED); | 4935 | MGMT_STATUS_REJECTED); |
4938 | 4936 | ||
@@ -4943,7 +4941,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev, | |||
4943 | hci_dev_lock(hdev); | 4941 | hci_dev_lock(hdev); |
4944 | 4942 | ||
4945 | if (!hdev_is_powered(hdev) || !lmp_sc_capable(hdev) || | 4943 | if (!hdev_is_powered(hdev) || !lmp_sc_capable(hdev) || |
4946 | !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 4944 | !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
4947 | bool changed; | 4945 | bool changed; |
4948 | 4946 | ||
4949 | if (cp->val) { | 4947 | if (cp->val) { |
@@ -4977,8 +4975,8 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev, | |||
4977 | 4975 | ||
4978 | val = !!cp->val; | 4976 | val = !!cp->val; |
4979 | 4977 | ||
4980 | if (val == test_bit(HCI_SC_ENABLED, &hdev->dev_flags) && | 4978 | if (val == hci_dev_test_flag(hdev, HCI_SC_ENABLED) && |
4981 | (cp->val == 0x02) == test_bit(HCI_SC_ONLY, &hdev->dev_flags)) { | 4979 | (cp->val == 0x02) == hci_dev_test_flag(hdev, HCI_SC_ONLY)) { |
4982 | err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev); | 4980 | err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev); |
4983 | goto failed; | 4981 | goto failed; |
4984 | } | 4982 | } |
@@ -5032,7 +5030,7 @@ static int set_debug_keys(struct sock *sk, struct hci_dev *hdev, | |||
5032 | &hdev->dev_flags); | 5030 | &hdev->dev_flags); |
5033 | 5031 | ||
5034 | if (hdev_is_powered(hdev) && use_changed && | 5032 | if (hdev_is_powered(hdev) && use_changed && |
5035 | test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 5033 | hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { |
5036 | u8 mode = (cp->val == 0x02) ? 0x01 : 0x00; | 5034 | u8 mode = (cp->val == 0x02) ? 0x01 : 0x00; |
5037 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, | 5035 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, |
5038 | sizeof(mode), &mode); | 5036 | sizeof(mode), &mode); |
@@ -6104,7 +6102,7 @@ static int set_external_config(struct sock *sk, struct hci_dev *hdev, | |||
6104 | 6102 | ||
6105 | err = new_options(hdev, sk); | 6103 | err = new_options(hdev, sk); |
6106 | 6104 | ||
6107 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) == is_configured(hdev)) { | 6105 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED) == is_configured(hdev)) { |
6108 | mgmt_index_removed(hdev); | 6106 | mgmt_index_removed(hdev); |
6109 | 6107 | ||
6110 | if (test_and_change_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { | 6108 | if (test_and_change_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
@@ -6156,7 +6154,7 @@ static int set_public_address(struct sock *sk, struct hci_dev *hdev, | |||
6156 | if (!changed) | 6154 | if (!changed) |
6157 | goto unlock; | 6155 | goto unlock; |
6158 | 6156 | ||
6159 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 6157 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
6160 | err = new_options(hdev, sk); | 6158 | err = new_options(hdev, sk); |
6161 | 6159 | ||
6162 | if (is_configured(hdev)) { | 6160 | if (is_configured(hdev)) { |
@@ -6304,15 +6302,15 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk, | |||
6304 | goto done; | 6302 | goto done; |
6305 | } | 6303 | } |
6306 | 6304 | ||
6307 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 6305 | if (hci_dev_test_flag(hdev, HCI_SETUP) || |
6308 | test_bit(HCI_CONFIG, &hdev->dev_flags) || | 6306 | hci_dev_test_flag(hdev, HCI_CONFIG) || |
6309 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 6307 | hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { |
6310 | err = mgmt_cmd_status(sk, index, opcode, | 6308 | err = mgmt_cmd_status(sk, index, opcode, |
6311 | MGMT_STATUS_INVALID_INDEX); | 6309 | MGMT_STATUS_INVALID_INDEX); |
6312 | goto done; | 6310 | goto done; |
6313 | } | 6311 | } |
6314 | 6312 | ||
6315 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | 6313 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED) && |
6316 | !(handler->flags & HCI_MGMT_UNCONFIGURED)) { | 6314 | !(handler->flags & HCI_MGMT_UNCONFIGURED)) { |
6317 | err = mgmt_cmd_status(sk, index, opcode, | 6315 | err = mgmt_cmd_status(sk, index, opcode, |
6318 | MGMT_STATUS_INVALID_INDEX); | 6316 | MGMT_STATUS_INVALID_INDEX); |
@@ -6362,7 +6360,7 @@ void mgmt_index_added(struct hci_dev *hdev) | |||
6362 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 6360 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
6363 | return; | 6361 | return; |
6364 | 6362 | ||
6365 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 6363 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
6366 | mgmt_event(MGMT_EV_UNCONF_INDEX_ADDED, hdev, NULL, 0, NULL); | 6364 | mgmt_event(MGMT_EV_UNCONF_INDEX_ADDED, hdev, NULL, 0, NULL); |
6367 | else | 6365 | else |
6368 | mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); | 6366 | mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); |
@@ -6380,7 +6378,7 @@ void mgmt_index_removed(struct hci_dev *hdev) | |||
6380 | 6378 | ||
6381 | mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status); | 6379 | mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status); |
6382 | 6380 | ||
6383 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | 6381 | if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) |
6384 | mgmt_event(MGMT_EV_UNCONF_INDEX_REMOVED, hdev, NULL, 0, NULL); | 6382 | mgmt_event(MGMT_EV_UNCONF_INDEX_REMOVED, hdev, NULL, 0, NULL); |
6385 | else | 6383 | else |
6386 | mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); | 6384 | mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); |
@@ -6448,7 +6446,7 @@ static int powered_update_hci(struct hci_dev *hdev) | |||
6448 | 6446 | ||
6449 | hci_req_init(&req, hdev); | 6447 | hci_req_init(&req, hdev); |
6450 | 6448 | ||
6451 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 6449 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED) && |
6452 | !lmp_host_ssp_capable(hdev)) { | 6450 | !lmp_host_ssp_capable(hdev)) { |
6453 | u8 mode = 0x01; | 6451 | u8 mode = 0x01; |
6454 | 6452 | ||
@@ -6462,7 +6460,7 @@ static int powered_update_hci(struct hci_dev *hdev) | |||
6462 | } | 6460 | } |
6463 | } | 6461 | } |
6464 | 6462 | ||
6465 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && | 6463 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED) && |
6466 | lmp_bredr_capable(hdev)) { | 6464 | lmp_bredr_capable(hdev)) { |
6467 | struct hci_cp_write_le_host_supported cp; | 6465 | struct hci_cp_write_le_host_supported cp; |
6468 | 6466 | ||
@@ -6483,24 +6481,24 @@ static int powered_update_hci(struct hci_dev *hdev) | |||
6483 | * advertising data. This also applies to the case | 6481 | * advertising data. This also applies to the case |
6484 | * where BR/EDR was toggled during the AUTO_OFF phase. | 6482 | * where BR/EDR was toggled during the AUTO_OFF phase. |
6485 | */ | 6483 | */ |
6486 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 6484 | if (hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { |
6487 | update_adv_data(&req); | 6485 | update_adv_data(&req); |
6488 | update_scan_rsp_data(&req); | 6486 | update_scan_rsp_data(&req); |
6489 | } | 6487 | } |
6490 | 6488 | ||
6491 | if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 6489 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
6492 | enable_advertising(&req); | 6490 | enable_advertising(&req); |
6493 | 6491 | ||
6494 | restart_le_actions(&req); | 6492 | restart_le_actions(&req); |
6495 | } | 6493 | } |
6496 | 6494 | ||
6497 | link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags); | 6495 | link_sec = hci_dev_test_flag(hdev, HCI_LINK_SECURITY); |
6498 | if (link_sec != test_bit(HCI_AUTH, &hdev->flags)) | 6496 | if (link_sec != test_bit(HCI_AUTH, &hdev->flags)) |
6499 | hci_req_add(&req, HCI_OP_WRITE_AUTH_ENABLE, | 6497 | hci_req_add(&req, HCI_OP_WRITE_AUTH_ENABLE, |
6500 | sizeof(link_sec), &link_sec); | 6498 | sizeof(link_sec), &link_sec); |
6501 | 6499 | ||
6502 | if (lmp_bredr_capable(hdev)) { | 6500 | if (lmp_bredr_capable(hdev)) { |
6503 | if (test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) | 6501 | if (hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) |
6504 | write_fast_connectable(&req, true); | 6502 | write_fast_connectable(&req, true); |
6505 | else | 6503 | else |
6506 | write_fast_connectable(&req, false); | 6504 | write_fast_connectable(&req, false); |
@@ -6519,7 +6517,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
6519 | u8 status, zero_cod[] = { 0, 0, 0 }; | 6517 | u8 status, zero_cod[] = { 0, 0, 0 }; |
6520 | int err; | 6518 | int err; |
6521 | 6519 | ||
6522 | if (!test_bit(HCI_MGMT, &hdev->dev_flags)) | 6520 | if (!hci_dev_test_flag(hdev, HCI_MGMT)) |
6523 | return 0; | 6521 | return 0; |
6524 | 6522 | ||
6525 | if (powered) { | 6523 | if (powered) { |
@@ -6540,7 +6538,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
6540 | * been triggered, potentially causing misleading DISCONNECTED | 6538 | * been triggered, potentially causing misleading DISCONNECTED |
6541 | * status responses. | 6539 | * status responses. |
6542 | */ | 6540 | */ |
6543 | if (test_bit(HCI_UNREGISTER, &hdev->dev_flags)) | 6541 | if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) |
6544 | status = MGMT_STATUS_INVALID_INDEX; | 6542 | status = MGMT_STATUS_INVALID_INDEX; |
6545 | else | 6543 | else |
6546 | status = MGMT_STATUS_NOT_POWERED; | 6544 | status = MGMT_STATUS_NOT_POWERED; |
@@ -6594,7 +6592,7 @@ void mgmt_discoverable_timeout(struct hci_dev *hdev) | |||
6594 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 6592 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); |
6595 | 6593 | ||
6596 | hci_req_init(&req, hdev); | 6594 | hci_req_init(&req, hdev); |
6597 | if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) { | 6595 | if (hci_dev_test_flag(hdev, HCI_BREDR_ENABLED)) { |
6598 | u8 scan = SCAN_PAGE; | 6596 | u8 scan = SCAN_PAGE; |
6599 | hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, | 6597 | hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, |
6600 | sizeof(scan), &scan); | 6598 | sizeof(scan), &scan); |
@@ -7170,8 +7168,8 @@ void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) | |||
7170 | 7168 | ||
7171 | hci_req_init(&req, hdev); | 7169 | hci_req_init(&req, hdev); |
7172 | 7170 | ||
7173 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 7171 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { |
7174 | if (test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags)) | 7172 | if (hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) |
7175 | hci_req_add(&req, HCI_OP_WRITE_SSP_DEBUG_MODE, | 7173 | hci_req_add(&req, HCI_OP_WRITE_SSP_DEBUG_MODE, |
7176 | sizeof(enable), &enable); | 7174 | sizeof(enable), &enable); |
7177 | update_eir(&req); | 7175 | update_eir(&req); |
@@ -7343,7 +7341,7 @@ static bool eir_has_uuids(u8 *eir, u16 eir_len, u16 uuid_count, u8 (*uuids)[16]) | |||
7343 | static void restart_le_scan(struct hci_dev *hdev) | 7341 | static void restart_le_scan(struct hci_dev *hdev) |
7344 | { | 7342 | { |
7345 | /* If controller is not scanning we are done. */ | 7343 | /* If controller is not scanning we are done. */ |
7346 | if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags)) | 7344 | if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) |
7347 | return; | 7345 | return; |
7348 | 7346 | ||
7349 | if (time_after(jiffies + DISCOV_LE_RESTART_DELAY, | 7347 | if (time_after(jiffies + DISCOV_LE_RESTART_DELAY, |
@@ -7514,7 +7512,7 @@ void mgmt_reenable_advertising(struct hci_dev *hdev) | |||
7514 | { | 7512 | { |
7515 | struct hci_request req; | 7513 | struct hci_request req; |
7516 | 7514 | ||
7517 | if (!test_bit(HCI_ADVERTISING, &hdev->dev_flags)) | 7515 | if (!hci_dev_test_flag(hdev, HCI_ADVERTISING)) |
7518 | return; | 7516 | return; |
7519 | 7517 | ||
7520 | hci_req_init(&req, hdev); | 7518 | hci_req_init(&req, hdev); |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index d6ef7e48c2c3..81975f274c2b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -52,7 +52,7 @@ | |||
52 | 52 | ||
53 | #define SMP_TIMEOUT msecs_to_jiffies(30000) | 53 | #define SMP_TIMEOUT msecs_to_jiffies(30000) |
54 | 54 | ||
55 | #define AUTH_REQ_MASK(dev) (test_bit(HCI_SC_ENABLED, &(dev)->dev_flags) ? \ | 55 | #define AUTH_REQ_MASK(dev) (hci_dev_test_flag(dev, HCI_SC_ENABLED) ? \ |
56 | 0x1f : 0x07) | 56 | 0x1f : 0x07) |
57 | #define KEY_DIST_MASK 0x07 | 57 | #define KEY_DIST_MASK 0x07 |
58 | 58 | ||
@@ -589,7 +589,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
589 | struct hci_dev *hdev = hcon->hdev; | 589 | struct hci_dev *hdev = hcon->hdev; |
590 | u8 local_dist = 0, remote_dist = 0, oob_flag = SMP_OOB_NOT_PRESENT; | 590 | u8 local_dist = 0, remote_dist = 0, oob_flag = SMP_OOB_NOT_PRESENT; |
591 | 591 | ||
592 | if (test_bit(HCI_BONDABLE, &conn->hcon->hdev->dev_flags)) { | 592 | if (hci_dev_test_flag(hdev, HCI_BONDABLE)) { |
593 | local_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; | 593 | local_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; |
594 | remote_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; | 594 | remote_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; |
595 | authreq |= SMP_AUTH_BONDING; | 595 | authreq |= SMP_AUTH_BONDING; |
@@ -597,18 +597,18 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
597 | authreq &= ~SMP_AUTH_BONDING; | 597 | authreq &= ~SMP_AUTH_BONDING; |
598 | } | 598 | } |
599 | 599 | ||
600 | if (test_bit(HCI_RPA_RESOLVING, &hdev->dev_flags)) | 600 | if (hci_dev_test_flag(hdev, HCI_RPA_RESOLVING)) |
601 | remote_dist |= SMP_DIST_ID_KEY; | 601 | remote_dist |= SMP_DIST_ID_KEY; |
602 | 602 | ||
603 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) | 603 | if (hci_dev_test_flag(hdev, HCI_PRIVACY)) |
604 | local_dist |= SMP_DIST_ID_KEY; | 604 | local_dist |= SMP_DIST_ID_KEY; |
605 | 605 | ||
606 | if (test_bit(HCI_SC_ENABLED, &hdev->dev_flags) && | 606 | if (hci_dev_test_flag(hdev, HCI_SC_ENABLED) && |
607 | (authreq & SMP_AUTH_SC)) { | 607 | (authreq & SMP_AUTH_SC)) { |
608 | struct oob_data *oob_data; | 608 | struct oob_data *oob_data; |
609 | u8 bdaddr_type; | 609 | u8 bdaddr_type; |
610 | 610 | ||
611 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 611 | if (hci_dev_test_flag(hdev, HCI_SSP_ENABLED)) { |
612 | local_dist |= SMP_DIST_LINK_KEY; | 612 | local_dist |= SMP_DIST_LINK_KEY; |
613 | remote_dist |= SMP_DIST_LINK_KEY; | 613 | remote_dist |= SMP_DIST_LINK_KEY; |
614 | } | 614 | } |
@@ -692,7 +692,7 @@ static void smp_chan_destroy(struct l2cap_conn *conn) | |||
692 | * support hasn't been explicitly enabled. | 692 | * support hasn't been explicitly enabled. |
693 | */ | 693 | */ |
694 | if (smp->ltk && smp->ltk->type == SMP_LTK_P256_DEBUG && | 694 | if (smp->ltk && smp->ltk->type == SMP_LTK_P256_DEBUG && |
695 | !test_bit(HCI_KEEP_DEBUG_KEYS, &hcon->hdev->dev_flags)) { | 695 | !hci_dev_test_flag(hcon->hdev, HCI_KEEP_DEBUG_KEYS)) { |
696 | list_del_rcu(&smp->ltk->list); | 696 | list_del_rcu(&smp->ltk->list); |
697 | kfree_rcu(smp->ltk, rcu); | 697 | kfree_rcu(smp->ltk, rcu); |
698 | smp->ltk = NULL; | 698 | smp->ltk = NULL; |
@@ -1052,7 +1052,7 @@ static void smp_notify_keys(struct l2cap_conn *conn) | |||
1052 | /* Don't keep debug keys around if the relevant | 1052 | /* Don't keep debug keys around if the relevant |
1053 | * flag is not set. | 1053 | * flag is not set. |
1054 | */ | 1054 | */ |
1055 | if (!test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags) && | 1055 | if (!hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS) && |
1056 | key->type == HCI_LK_DEBUG_COMBINATION) { | 1056 | key->type == HCI_LK_DEBUG_COMBINATION) { |
1057 | list_del_rcu(&key->list); | 1057 | list_del_rcu(&key->list); |
1058 | kfree_rcu(key, rcu); | 1058 | kfree_rcu(key, rcu); |
@@ -1604,15 +1604,15 @@ static void build_bredr_pairing_cmd(struct smp_chan *smp, | |||
1604 | struct hci_dev *hdev = conn->hcon->hdev; | 1604 | struct hci_dev *hdev = conn->hcon->hdev; |
1605 | u8 local_dist = 0, remote_dist = 0; | 1605 | u8 local_dist = 0, remote_dist = 0; |
1606 | 1606 | ||
1607 | if (test_bit(HCI_BONDABLE, &hdev->dev_flags)) { | 1607 | if (hci_dev_test_flag(hdev, HCI_BONDABLE)) { |
1608 | local_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; | 1608 | local_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; |
1609 | remote_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; | 1609 | remote_dist = SMP_DIST_ENC_KEY | SMP_DIST_SIGN; |
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | if (test_bit(HCI_RPA_RESOLVING, &hdev->dev_flags)) | 1612 | if (hci_dev_test_flag(hdev, HCI_RPA_RESOLVING)) |
1613 | remote_dist |= SMP_DIST_ID_KEY; | 1613 | remote_dist |= SMP_DIST_ID_KEY; |
1614 | 1614 | ||
1615 | if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) | 1615 | if (hci_dev_test_flag(hdev, HCI_PRIVACY)) |
1616 | local_dist |= SMP_DIST_ID_KEY; | 1616 | local_dist |= SMP_DIST_ID_KEY; |
1617 | 1617 | ||
1618 | if (!rsp) { | 1618 | if (!rsp) { |
@@ -1664,11 +1664,11 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1664 | /* We didn't start the pairing, so match remote */ | 1664 | /* We didn't start the pairing, so match remote */ |
1665 | auth = req->auth_req & AUTH_REQ_MASK(hdev); | 1665 | auth = req->auth_req & AUTH_REQ_MASK(hdev); |
1666 | 1666 | ||
1667 | if (!test_bit(HCI_BONDABLE, &hdev->dev_flags) && | 1667 | if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && |
1668 | (auth & SMP_AUTH_BONDING)) | 1668 | (auth & SMP_AUTH_BONDING)) |
1669 | return SMP_PAIRING_NOTSUPP; | 1669 | return SMP_PAIRING_NOTSUPP; |
1670 | 1670 | ||
1671 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && !(auth & SMP_AUTH_SC)) | 1671 | if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC)) |
1672 | return SMP_AUTH_REQUIREMENTS; | 1672 | return SMP_AUTH_REQUIREMENTS; |
1673 | 1673 | ||
1674 | smp->preq[0] = SMP_CMD_PAIRING_REQ; | 1674 | smp->preq[0] = SMP_CMD_PAIRING_REQ; |
@@ -1761,7 +1761,7 @@ static u8 sc_send_public_key(struct smp_chan *smp) | |||
1761 | 1761 | ||
1762 | BT_DBG(""); | 1762 | BT_DBG(""); |
1763 | 1763 | ||
1764 | if (test_bit(HCI_USE_DEBUG_KEYS, &hdev->dev_flags)) { | 1764 | if (hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS)) { |
1765 | BT_DBG("Using debug keys"); | 1765 | BT_DBG("Using debug keys"); |
1766 | memcpy(smp->local_pk, debug_pk, 64); | 1766 | memcpy(smp->local_pk, debug_pk, 64); |
1767 | memcpy(smp->local_sk, debug_sk, 32); | 1767 | memcpy(smp->local_sk, debug_sk, 32); |
@@ -1816,7 +1816,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1816 | 1816 | ||
1817 | auth = rsp->auth_req & AUTH_REQ_MASK(hdev); | 1817 | auth = rsp->auth_req & AUTH_REQ_MASK(hdev); |
1818 | 1818 | ||
1819 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && !(auth & SMP_AUTH_SC)) | 1819 | if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC)) |
1820 | return SMP_AUTH_REQUIREMENTS; | 1820 | return SMP_AUTH_REQUIREMENTS; |
1821 | 1821 | ||
1822 | smp->prsp[0] = SMP_CMD_PAIRING_RSP; | 1822 | smp->prsp[0] = SMP_CMD_PAIRING_RSP; |
@@ -2086,7 +2086,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
2086 | 2086 | ||
2087 | auth = rp->auth_req & AUTH_REQ_MASK(hdev); | 2087 | auth = rp->auth_req & AUTH_REQ_MASK(hdev); |
2088 | 2088 | ||
2089 | if (test_bit(HCI_SC_ONLY, &hdev->dev_flags) && !(auth & SMP_AUTH_SC)) | 2089 | if (hci_dev_test_flag(hdev, HCI_SC_ONLY) && !(auth & SMP_AUTH_SC)) |
2090 | return SMP_AUTH_REQUIREMENTS; | 2090 | return SMP_AUTH_REQUIREMENTS; |
2091 | 2091 | ||
2092 | if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) | 2092 | if (hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT) |
@@ -2107,7 +2107,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
2107 | if (!smp) | 2107 | if (!smp) |
2108 | return SMP_UNSPECIFIED; | 2108 | return SMP_UNSPECIFIED; |
2109 | 2109 | ||
2110 | if (!test_bit(HCI_BONDABLE, &hcon->hdev->dev_flags) && | 2110 | if (!hci_dev_test_flag(hdev, HCI_BONDABLE) && |
2111 | (auth & SMP_AUTH_BONDING)) | 2111 | (auth & SMP_AUTH_BONDING)) |
2112 | return SMP_PAIRING_NOTSUPP; | 2112 | return SMP_PAIRING_NOTSUPP; |
2113 | 2113 | ||
@@ -2141,7 +2141,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
2141 | 2141 | ||
2142 | chan = conn->smp; | 2142 | chan = conn->smp; |
2143 | 2143 | ||
2144 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) | 2144 | if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) |
2145 | return 1; | 2145 | return 1; |
2146 | 2146 | ||
2147 | if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) | 2147 | if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) |
@@ -2170,7 +2170,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
2170 | 2170 | ||
2171 | authreq = seclevel_to_authreq(sec_level); | 2171 | authreq = seclevel_to_authreq(sec_level); |
2172 | 2172 | ||
2173 | if (test_bit(HCI_SC_ENABLED, &hcon->hdev->dev_flags)) | 2173 | if (hci_dev_test_flag(hcon->hdev, HCI_SC_ENABLED)) |
2174 | authreq |= SMP_AUTH_SC; | 2174 | authreq |= SMP_AUTH_SC; |
2175 | 2175 | ||
2176 | /* Require MITM if IO Capability allows or the security level | 2176 | /* Require MITM if IO Capability allows or the security level |
@@ -2606,7 +2606,7 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) | |||
2606 | if (skb->len < 1) | 2606 | if (skb->len < 1) |
2607 | return -EILSEQ; | 2607 | return -EILSEQ; |
2608 | 2608 | ||
2609 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) { | 2609 | if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED)) { |
2610 | reason = SMP_PAIRING_NOTSUPP; | 2610 | reason = SMP_PAIRING_NOTSUPP; |
2611 | goto done; | 2611 | goto done; |
2612 | } | 2612 | } |
@@ -2744,7 +2744,7 @@ static void bredr_pairing(struct l2cap_chan *chan) | |||
2744 | return; | 2744 | return; |
2745 | 2745 | ||
2746 | /* Secure Connections support must be enabled */ | 2746 | /* Secure Connections support must be enabled */ |
2747 | if (!test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) | 2747 | if (!hci_dev_test_flag(hdev, HCI_SC_ENABLED)) |
2748 | return; | 2748 | return; |
2749 | 2749 | ||
2750 | /* BR/EDR must use Secure Connections for SMP */ | 2750 | /* BR/EDR must use Secure Connections for SMP */ |
@@ -2753,7 +2753,7 @@ static void bredr_pairing(struct l2cap_chan *chan) | |||
2753 | return; | 2753 | return; |
2754 | 2754 | ||
2755 | /* If our LE support is not enabled don't do anything */ | 2755 | /* If our LE support is not enabled don't do anything */ |
2756 | if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) | 2756 | if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) |
2757 | return; | 2757 | return; |
2758 | 2758 | ||
2759 | /* Don't bother if remote LE support is not enabled */ | 2759 | /* Don't bother if remote LE support is not enabled */ |