Bluetooth: Add helper function for clearing the discovery filter
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 5 Dec 2014 10:45:21 +0000 (11:45 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 5 Dec 2014 11:12:58 +0000 (13:12 +0200)
The discovery filter allocates memory for its UUID list. So use
a helper function to free it and reset it to default states.

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

index 83ca58b9f4c13c6290ae51dba65568f4a0aaf4a5..f07b1450b3c2018906111fb06f491b1d48f6aba0 100644 (file)
@@ -509,6 +509,14 @@ static inline void discovery_init(struct hci_dev *hdev)
        hdev->discovery.rssi = HCI_RSSI_INVALID;
 }
 
+static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
+{
+       hdev->discovery.rssi = HCI_RSSI_INVALID;
+       hdev->discovery.uuid_count = 0;
+       kfree(hdev->discovery.uuids);
+       hdev->discovery.uuids = NULL;
+}
+
 bool hci_discovery_active(struct hci_dev *hdev);
 
 void hci_discovery_set_state(struct hci_dev *hdev, int state);
index 42f86dc3fb40d1135f59ee4b7d513def02ccfca8..3c81b5cdda83d50be0d7860bdfba497d775d49ae 100644 (file)
@@ -2061,10 +2061,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
                 * count, it is important to actually free the allocated
                 * list of UUIDs here.
                 */
-               hdev->discovery.rssi = HCI_RSSI_INVALID;
-               hdev->discovery.uuid_count = 0;
-               kfree(hdev->discovery.uuids);
-               hdev->discovery.uuids = NULL;
+               hci_discovery_filter_clear(hdev);
 
                if (old_state != DISCOVERY_STARTING)
                        mgmt_discovering(hdev, 0);