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 | |
| 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>
| -rw-r--r-- | include/net/bluetooth/hci_core.h | 14 | ||||
| -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 |
10 files changed, 278 insertions, 278 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5cc5a192359d..05e95a75aba5 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
| @@ -502,6 +502,8 @@ extern struct list_head hci_cb_list; | |||
| 502 | extern rwlock_t hci_dev_list_lock; | 502 | extern rwlock_t hci_dev_list_lock; |
| 503 | extern struct mutex hci_cb_list_lock; | 503 | extern struct mutex hci_cb_list_lock; |
| 504 | 504 | ||
| 505 | #define hci_dev_test_flag(hdev, nr) test_bit((nr), &(hdev)->dev_flags) | ||
| 506 | |||
| 505 | /* ----- HCI interface to upper protocols ----- */ | 507 | /* ----- HCI interface to upper protocols ----- */ |
| 506 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | 508 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 507 | int l2cap_disconn_ind(struct hci_conn *hcon); | 509 | int l2cap_disconn_ind(struct hci_conn *hcon); |
| @@ -598,14 +600,14 @@ enum { | |||
| 598 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) | 600 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) |
| 599 | { | 601 | { |
| 600 | struct hci_dev *hdev = conn->hdev; | 602 | struct hci_dev *hdev = conn->hdev; |
| 601 | return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 603 | return hci_dev_test_flag(hdev, HCI_SSP_ENABLED) && |
| 602 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); | 604 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); |
| 603 | } | 605 | } |
| 604 | 606 | ||
| 605 | static inline bool hci_conn_sc_enabled(struct hci_conn *conn) | 607 | static inline bool hci_conn_sc_enabled(struct hci_conn *conn) |
| 606 | { | 608 | { |
| 607 | struct hci_dev *hdev = conn->hdev; | 609 | struct hci_dev *hdev = conn->hdev; |
| 608 | return test_bit(HCI_SC_ENABLED, &hdev->dev_flags) && | 610 | return hci_dev_test_flag(hdev, HCI_SC_ENABLED) && |
| 609 | test_bit(HCI_CONN_SC_ENABLED, &conn->flags); | 611 | test_bit(HCI_CONN_SC_ENABLED, &conn->flags); |
| 610 | } | 612 | } |
| 611 | 613 | ||
| @@ -1025,10 +1027,10 @@ void hci_conn_del_sysfs(struct hci_conn *conn); | |||
| 1025 | #define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) | 1027 | #define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) |
| 1026 | #define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) | 1028 | #define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) |
| 1027 | 1029 | ||
| 1028 | #define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ | 1030 | #define hdev_is_powered(dev) (test_bit(HCI_UP, &(dev)->flags) && \ |
| 1029 | !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) | 1031 | !hci_dev_test_flag(dev, HCI_AUTO_OFF)) |
| 1030 | #define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ | 1032 | #define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ |
| 1031 | test_bit(HCI_SC_ENABLED, &(dev)->dev_flags)) | 1033 | hci_dev_test_flag(dev, HCI_SC_ENABLED)) |
| 1032 | 1034 | ||
| 1033 | /* ----- HCI protocols ----- */ | 1035 | /* ----- HCI protocols ----- */ |
| 1034 | #define HCI_PROTO_DEFER 0x01 | 1036 | #define HCI_PROTO_DEFER 0x01 |
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; |
