]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Bluetooth: Use DECLARE_BITMAP for hdev->dev_flags field
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 13 Mar 2015 16:04:17 +0000 (09:04 -0700)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 13 Mar 2015 16:35:45 +0000 (18:35 +0200)
The hdev->dev_flags field has outgrown itself on 32-bit systems. So
instead of hacking around it, switch to using DECLARE_BITMAP.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

index 0f3413b285a5c487e7aa0407a65eff09ec325a76..7a0272a6f0baf3a32e2302511f34e707fd2c12d1 100644 (file)
@@ -226,14 +226,9 @@ enum {
        HCI_FAST_CONNECTABLE,
        HCI_BREDR_ENABLED,
        HCI_LE_SCAN_INTERRUPTED,
+       __HCI_NUM_FLAGS,
 };
 
-/* A mask for the flags that are supposed to remain when a reset happens
- * or the HCI device is closed.
- */
-#define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \
-                            BIT(HCI_LE_ADV))
-
 /* HCI timeouts */
 #define HCI_DISCONN_TIMEOUT    msecs_to_jiffies(2000)  /* 2 seconds */
 #define HCI_PAIRING_TIMEOUT    msecs_to_jiffies(60000) /* 60 seconds */
index 6db1333a114faedad1510ae49b24126f9b8f23d1..889a489d913fdfa26c4ce36c30a6659007f4d547 100644 (file)
@@ -354,7 +354,7 @@ struct hci_dev {
        struct rfkill           *rfkill;
 
        unsigned long           dbg_flags;
-       unsigned long           dev_flags;
+       DECLARE_BITMAP(dev_flags, __HCI_NUM_FLAGS);
 
        struct delayed_work     le_scan_disable;
        struct delayed_work     le_scan_restart;
@@ -502,14 +502,20 @@ extern struct list_head hci_cb_list;
 extern rwlock_t hci_dev_list_lock;
 extern struct mutex hci_cb_list_lock;
 
-#define hci_dev_set_flag(hdev, nr)    set_bit((nr), &(hdev)->dev_flags)
-#define hci_dev_clear_flag(hdev, nr)  clear_bit((nr), &(hdev)->dev_flags)
-#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)
+#define hci_dev_set_flag(hdev, nr)             set_bit((nr), (hdev)->dev_flags)
+#define hci_dev_clear_flag(hdev, nr)           clear_bit((nr), (hdev)->dev_flags)
+#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)
+
+#define hci_dev_clear_volatile_flags(hdev)                     \
+       do {                                                    \
+               hci_dev_clear_flag(hdev, HCI_LE_SCAN);          \
+               hci_dev_clear_flag(hdev, HCI_LE_ADV);           \
+               hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ);     \
+       } while (0)
 
 /* ----- HCI interface to upper protocols ----- */
 int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
index c6ed46c4f45a29aa1c01fa7d1f968ee1c30aeb1e..23a43ca987850417d444b07f7e46f44c3f435467 100644 (file)
@@ -1699,7 +1699,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 
        /* Clear flags */
        hdev->flags &= BIT(HCI_RAW);
-       hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
+       hci_dev_clear_volatile_flags(hdev);
 
        /* Controller radio is available but is currently powered down */
        hdev->amp_status = AMP_STATUS_POWERED_DOWN;
index 4958b24ae5c7d797b2d83ddebc068cc69c71c50b..c7376cd42b1cacd9e0225f5bb4a2b05bc01590ba 100644 (file)
@@ -198,7 +198,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
                return;
 
        /* Reset all non-persistent flags */
-       hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
+       hci_dev_clear_volatile_flags(hdev);
 
        hci_discovery_set_state(hdev, DISCOVERY_STOPPED);