diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2015-03-13 05:11:06 -0400 |
|---|---|---|
| committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-03-13 06:09:33 -0400 |
| commit | 238be788fcb75870661ec165dc90f2a2674e7fcb (patch) | |
| tree | bdeac71cdc22c7594e29df3daf678a486d048c4f | |
| parent | a69d89272698d1c31ccb78348562af6461cf1eb7 (diff) | |
Bluetooth: Introduce hci_dev_test_and_set_flag helper macro
Instead of manually coding test_and_set_bit on hdev->dev_flags all the
time, use hci_dev_test_and_set_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 | 1 | ||||
| -rw-r--r-- | net/bluetooth/hci_core.c | 8 | ||||
| -rw-r--r-- | net/bluetooth/hci_sock.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/mgmt.c | 46 |
4 files changed, 26 insertions, 31 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4b7632b15051..6db1333a114f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
| @@ -507,6 +507,7 @@ extern struct mutex hci_cb_list_lock; | |||
| 507 | #define hci_dev_change_flag(hdev, nr) change_bit((nr), &(hdev)->dev_flags) | 507 | #define hci_dev_change_flag(hdev, nr) change_bit((nr), &(hdev)->dev_flags) |
| 508 | #define hci_dev_test_flag(hdev, nr) test_bit((nr), &(hdev)->dev_flags) | 508 | #define hci_dev_test_flag(hdev, nr) test_bit((nr), &(hdev)->dev_flags) |
| 509 | 509 | ||
| 510 | #define hci_dev_test_and_set_flag(hdev, nr) test_and_set_bit((nr), &(hdev)->dev_flags) | ||
| 510 | #define hci_dev_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), &(hdev)->dev_flags) | 511 | #define hci_dev_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), &(hdev)->dev_flags) |
| 511 | #define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), &(hdev)->dev_flags) | 512 | #define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), &(hdev)->dev_flags) |
| 512 | 513 | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 85d5222c70ae..c6ed46c4f45a 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
| @@ -1836,15 +1836,15 @@ static void hci_update_scan_state(struct hci_dev *hdev, u8 scan) | |||
| 1836 | BT_DBG("%s scan 0x%02x", hdev->name, scan); | 1836 | BT_DBG("%s scan 0x%02x", hdev->name, scan); |
| 1837 | 1837 | ||
| 1838 | if ((scan & SCAN_PAGE)) | 1838 | if ((scan & SCAN_PAGE)) |
| 1839 | conn_changed = !test_and_set_bit(HCI_CONNECTABLE, | 1839 | conn_changed = !hci_dev_test_and_set_flag(hdev, |
| 1840 | &hdev->dev_flags); | 1840 | HCI_CONNECTABLE); |
| 1841 | else | 1841 | else |
| 1842 | conn_changed = hci_dev_test_and_clear_flag(hdev, | 1842 | conn_changed = hci_dev_test_and_clear_flag(hdev, |
| 1843 | HCI_CONNECTABLE); | 1843 | HCI_CONNECTABLE); |
| 1844 | 1844 | ||
| 1845 | if ((scan & SCAN_INQUIRY)) { | 1845 | if ((scan & SCAN_INQUIRY)) { |
| 1846 | discov_changed = !test_and_set_bit(HCI_DISCOVERABLE, | 1846 | discov_changed = !hci_dev_test_and_set_flag(hdev, |
| 1847 | &hdev->dev_flags); | 1847 | HCI_DISCOVERABLE); |
| 1848 | } else { | 1848 | } else { |
| 1849 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); | 1849 | hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE); |
| 1850 | discov_changed = hci_dev_test_and_clear_flag(hdev, | 1850 | discov_changed = hci_dev_test_and_clear_flag(hdev, |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index ca402a0a6740..b614543b4fe3 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
| @@ -720,7 +720,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
| 720 | goto done; | 720 | goto done; |
| 721 | } | 721 | } |
| 722 | 722 | ||
| 723 | if (test_and_set_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 723 | if (hci_dev_test_and_set_flag(hdev, HCI_USER_CHANNEL)) { |
| 724 | err = -EUSERS; | 724 | err = -EUSERS; |
| 725 | hci_dev_put(hdev); | 725 | hci_dev_put(hdev); |
| 726 | goto done; | 726 | goto done; |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cc5c04728848..d97719d04be0 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
| @@ -1178,7 +1178,7 @@ static void rpa_expired(struct work_struct *work) | |||
| 1178 | 1178 | ||
| 1179 | static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) | 1179 | static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev) |
| 1180 | { | 1180 | { |
| 1181 | if (test_and_set_bit(HCI_MGMT, &hdev->dev_flags)) | 1181 | if (hci_dev_test_and_set_flag(hdev, HCI_MGMT)) |
| 1182 | return; | 1182 | return; |
| 1183 | 1183 | ||
| 1184 | INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); | 1184 | INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off); |
| @@ -1579,8 +1579,7 @@ static void set_discoverable_complete(struct hci_dev *hdev, u8 status, | |||
| 1579 | 1579 | ||
| 1580 | cp = cmd->param; | 1580 | cp = cmd->param; |
| 1581 | if (cp->val) { | 1581 | if (cp->val) { |
| 1582 | changed = !test_and_set_bit(HCI_DISCOVERABLE, | 1582 | changed = !hci_dev_test_and_set_flag(hdev, HCI_DISCOVERABLE); |
| 1583 | &hdev->dev_flags); | ||
| 1584 | 1583 | ||
| 1585 | if (hdev->discov_timeout > 0) { | 1584 | if (hdev->discov_timeout > 0) { |
| 1586 | int to = msecs_to_jiffies(hdev->discov_timeout * 1000); | 1585 | int to = msecs_to_jiffies(hdev->discov_timeout * 1000); |
| @@ -1836,8 +1835,8 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status, | |||
| 1836 | 1835 | ||
| 1837 | cp = cmd->param; | 1836 | cp = cmd->param; |
| 1838 | if (cp->val) { | 1837 | if (cp->val) { |
| 1839 | conn_changed = !test_and_set_bit(HCI_CONNECTABLE, | 1838 | conn_changed = !hci_dev_test_and_set_flag(hdev, |
| 1840 | &hdev->dev_flags); | 1839 | HCI_CONNECTABLE); |
| 1841 | discov_changed = false; | 1840 | discov_changed = false; |
| 1842 | } else { | 1841 | } else { |
| 1843 | conn_changed = hci_dev_test_and_clear_flag(hdev, | 1842 | conn_changed = hci_dev_test_and_clear_flag(hdev, |
| @@ -2004,7 +2003,7 @@ static int set_bondable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
| 2004 | hci_dev_lock(hdev); | 2003 | hci_dev_lock(hdev); |
| 2005 | 2004 | ||
| 2006 | if (cp->val) | 2005 | if (cp->val) |
| 2007 | changed = !test_and_set_bit(HCI_BONDABLE, &hdev->dev_flags); | 2006 | changed = !hci_dev_test_and_set_flag(hdev, HCI_BONDABLE); |
| 2008 | else | 2007 | else |
| 2009 | changed = hci_dev_test_and_clear_flag(hdev, HCI_BONDABLE); | 2008 | changed = hci_dev_test_and_clear_flag(hdev, HCI_BONDABLE); |
| 2010 | 2009 | ||
| @@ -2116,8 +2115,8 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
| 2116 | bool changed; | 2115 | bool changed; |
| 2117 | 2116 | ||
| 2118 | if (cp->val) { | 2117 | if (cp->val) { |
| 2119 | changed = !test_and_set_bit(HCI_SSP_ENABLED, | 2118 | changed = !hci_dev_test_and_set_flag(hdev, |
| 2120 | &hdev->dev_flags); | 2119 | HCI_SSP_ENABLED); |
| 2121 | } else { | 2120 | } else { |
| 2122 | changed = hci_dev_test_and_clear_flag(hdev, | 2121 | changed = hci_dev_test_and_clear_flag(hdev, |
| 2123 | HCI_SSP_ENABLED); | 2122 | HCI_SSP_ENABLED); |
| @@ -2204,7 +2203,7 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
| 2204 | } | 2203 | } |
| 2205 | 2204 | ||
| 2206 | if (cp->val) { | 2205 | if (cp->val) { |
| 2207 | changed = !test_and_set_bit(HCI_HS_ENABLED, &hdev->dev_flags); | 2206 | changed = !hci_dev_test_and_set_flag(hdev, HCI_HS_ENABLED); |
| 2208 | } else { | 2207 | } else { |
| 2209 | if (hdev_is_powered(hdev)) { | 2208 | if (hdev_is_powered(hdev)) { |
| 2210 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, | 2209 | err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, |
| @@ -2487,7 +2486,7 @@ static bool enable_service_cache(struct hci_dev *hdev) | |||
| 2487 | if (!hdev_is_powered(hdev)) | 2486 | if (!hdev_is_powered(hdev)) |
| 2488 | return false; | 2487 | return false; |
| 2489 | 2488 | ||
| 2490 | if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) { | 2489 | if (!hci_dev_test_and_set_flag(hdev, HCI_SERVICE_CACHE)) { |
| 2491 | queue_delayed_work(hdev->workqueue, &hdev->service_cache, | 2490 | queue_delayed_work(hdev->workqueue, &hdev->service_cache, |
| 2492 | CACHE_TIMEOUT); | 2491 | CACHE_TIMEOUT); |
| 2493 | return true; | 2492 | return true; |
| @@ -2714,8 +2713,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, | |||
| 2714 | hci_link_keys_clear(hdev); | 2713 | hci_link_keys_clear(hdev); |
| 2715 | 2714 | ||
| 2716 | if (cp->debug_keys) | 2715 | if (cp->debug_keys) |
| 2717 | changed = !test_and_set_bit(HCI_KEEP_DEBUG_KEYS, | 2716 | changed = !hci_dev_test_and_set_flag(hdev, HCI_KEEP_DEBUG_KEYS); |
| 2718 | &hdev->dev_flags); | ||
| 2719 | else | 2717 | else |
| 2720 | changed = hci_dev_test_and_clear_flag(hdev, | 2718 | changed = hci_dev_test_and_clear_flag(hdev, |
| 2721 | HCI_KEEP_DEBUG_KEYS); | 2719 | HCI_KEEP_DEBUG_KEYS); |
| @@ -4463,8 +4461,7 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, | |||
| 4463 | bool changed; | 4461 | bool changed; |
| 4464 | 4462 | ||
| 4465 | if (cp->val) { | 4463 | if (cp->val) { |
| 4466 | changed = !test_and_set_bit(HCI_ADVERTISING, | 4464 | changed = !hci_dev_test_and_set_flag(hdev, HCI_ADVERTISING); |
| 4467 | &hdev->dev_flags); | ||
| 4468 | if (cp->val == 0x02) | 4465 | if (cp->val == 0x02) |
| 4469 | hci_dev_set_flag(hdev, HCI_ADVERTISING_CONNECTABLE); | 4466 | hci_dev_set_flag(hdev, HCI_ADVERTISING_CONNECTABLE); |
| 4470 | else | 4467 | else |
| @@ -4940,8 +4937,8 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev, | |||
| 4940 | bool changed; | 4937 | bool changed; |
| 4941 | 4938 | ||
| 4942 | if (cp->val) { | 4939 | if (cp->val) { |
| 4943 | changed = !test_and_set_bit(HCI_SC_ENABLED, | 4940 | changed = !hci_dev_test_and_set_flag(hdev, |
| 4944 | &hdev->dev_flags); | 4941 | HCI_SC_ENABLED); |
| 4945 | if (cp->val == 0x02) | 4942 | if (cp->val == 0x02) |
| 4946 | hci_dev_set_flag(hdev, HCI_SC_ONLY); | 4943 | hci_dev_set_flag(hdev, HCI_SC_ONLY); |
| 4947 | else | 4944 | else |
| @@ -5011,15 +5008,14 @@ static int set_debug_keys(struct sock *sk, struct hci_dev *hdev, | |||
| 5011 | hci_dev_lock(hdev); | 5008 | hci_dev_lock(hdev); |
| 5012 | 5009 | ||
| 50 | |||
