aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-07 06:24:58 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-07 06:36:39 -0400
commitbb3e0a336ae683332c1282d1e84b371b65aba1b4 (patch)
tree8779c5bd3fe1f9bf78dc7257b37cdeab43e4df60 /net
parent7e899c94939b928173d76d1e5a7c0675f44813f5 (diff)
Bluetooth: Update discovery state earlier in hci_discovery_set_state
In a subsequent patch the hci_update_background_scan() function will depend on being able to know the current discovery state. For this to be possible we need to set the new state early in the function. Since we also need to check what the old state was this patch introduces an extra variable for tracking it. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_core.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 623ffe0da4a6..6a0e39f69e03 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1903,16 +1903,20 @@ bool hci_discovery_active(struct hci_dev *hdev)
1903 1903
1904void hci_discovery_set_state(struct hci_dev *hdev, int state) 1904void hci_discovery_set_state(struct hci_dev *hdev, int state)
1905{ 1905{
1906 int old_state = hdev->discovery.state;
1907
1906 BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state); 1908 BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state);
1907 1909
1908 if (hdev->discovery.state == state) 1910 if (old_state == state)
1909 return; 1911 return;
1910 1912
1913 hdev->discovery.state = state;
1914
1911 switch (state) { 1915 switch (state) {
1912 case DISCOVERY_STOPPED: 1916 case DISCOVERY_STOPPED:
1913 hci_update_background_scan(hdev); 1917 hci_update_background_scan(hdev);
1914 1918
1915 if (hdev->discovery.state != DISCOVERY_STARTING) 1919 if (old_state != DISCOVERY_STARTING)
1916 mgmt_discovering(hdev, 0); 1920 mgmt_discovering(hdev, 0);
1917 break; 1921 break;
1918 case DISCOVERY_STARTING: 1922 case DISCOVERY_STARTING:
@@ -1925,8 +1929,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
1925 case DISCOVERY_STOPPING: 1929 case DISCOVERY_STOPPING:
1926 break; 1930 break;
1927 } 1931 }
1928
1929 hdev->discovery.state = state;
1930} 1932}
1931 1933
1932void hci_inquiry_cache_flush(struct hci_dev *hdev) 1934void hci_inquiry_cache_flush(struct hci_dev *hdev)