Skip to contentSkip to conversation

Bluetooth: Introduce hci_dev_test_and_set_flag helper macro

PATCH In review Marcel Holtmann 1 participant 1 message Mar 13, 2015

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 7/7 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.

---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_core.c         |  8 +++----
 net/bluetooth/hci_sock.c         |  2 +-
 net/bluetooth/mgmt.c             | 46 +++++++++++++++++-----------------------
 4 files changed, 26 insertions(+), 31 deletions(-)
include/net/bluetooth/hci_core.h +1 -0
index 4b7632b15051..6db1333a114f 100644
@@ -507,6 +507,7 @@ extern struct mutex hci_cb_list_lock;
 #define hci_dev_change_flag(hdev, nr) change_bit((nr), &(hdev)->dev_flags)
 #define hci_dev_test_flag(hdev, nr)   test_bit((nr), &(hdev)->dev_flags)
 
+#define hci_dev_test_and_set_flag(hdev, nr)    test_and_set_bit((nr), &(hdev)->dev_flags)
 #define hci_dev_test_and_clear_flag(hdev, nr)  test_and_clear_bit((nr), &(hdev)->dev_flags)
 #define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), &(hdev)->dev_flags)
 
net/bluetooth/hci_core.c +4 -4
index 85d5222c70ae..c6ed46c4f45a 100644
@@ -1836,15 +1836,15 @@ static void hci_update_scan_state(struct hci_dev *hdev, u8 scan)
 	BT_DBG("%s scan 0x%02x", hdev->name, scan);
 
 	if ((scan & SCAN_PAGE))
-		conn_changed = !test_and_set_bit(HCI_CONNECTABLE,
-						 &hdev->dev_flags);
+		conn_changed = !hci_dev_test_and_set_flag(hdev,
+							  HCI_CONNECTABLE);
 	else
 		conn_changed = hci_dev_test_and_clear_flag(hdev,
 							   HCI_CONNECTABLE);
 
 	if ((scan & SCAN_INQUIRY)) {
-		discov_changed = !test_and_set_bit(HCI_DISCOVERABLE,
-						   &hdev->dev_flags);
+		discov_changed = !hci_dev_test_and_set_flag(hdev,
+							    HCI_DISCOVERABLE);
 	} else {
 		hci_dev_clear_flag(hdev, HCI_LIMITED_DISCOVERABLE);
 		discov_changed = hci_dev_test_and_clear_flag(hdev,
net/bluetooth/hci_sock.c +1 -1
index ca402a0a6740..b614543b4fe3 100644
@@ -720,7 +720,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
 			goto done;
 		}
 
-		if (test_and_set_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
+		if (hci_dev_test_and_set_flag(hdev, HCI_USER_CHANNEL)) {
 			err = -EUSERS;
 			hci_dev_put(hdev);
 			goto done;
net/bluetooth/mgmt.c +20 -26

141 lines not on this page · raw message

Signature · 1 line
2.1.0