OSDN Git Service

core: Remove unnecessary adapter->passive_scanning variable
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 30 Jan 2013 01:29:40 +0000 (19:29 -0600)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 30 Jan 2013 01:29:46 +0000 (19:29 -0600)
The adapter->discovery_list can function equally well as an indicator of
whether normal discovery or passive scanning is in progress. Normal
discovery always overrides passive scanning so if there's one or more
entries in discovery_list we must be performing normal discovery and not
passive scanning.

src/adapter.c

index 805a80a..8a1c870 100644 (file)
@@ -163,7 +163,6 @@ struct btd_adapter {
        GSList *connections;            /* Connected devices */
        GSList *devices;                /* Devices structure pointers */
        GSList *connect_list;           /* Devices to connect when found */
-       bool passive_scanning;          /* Passive (LE) scanning enabled */
        struct btd_device *connect_le;  /* LE device waiting to be connected */
        sdp_list_t *services;           /* Services associated to adapter */
 
@@ -1118,7 +1117,6 @@ static void passive_scanning_complete(uint8_t status, uint16_t length,
        if (status == MGMT_STATUS_SUCCESS) {
                adapter->discovery_type = rp->type;
                adapter->discovery_enable = 0x01;
-               adapter->passive_scanning = true;
        }
 }
 
@@ -1401,9 +1399,6 @@ static void discovering_callback(uint16_t index, uint16_t length,
        adapter->discovery_type = ev->type;
        adapter->discovery_enable = ev->discovering;
 
-       if (!adapter->discovery_enable)
-               adapter->passive_scanning = false;
-
        /*
         * Check for existing discoveries triggered by client applications
         * and ignore all others.
@@ -4118,9 +4113,11 @@ static void update_found_devices(struct btd_adapter *adapter,
        /*
         * Only if at least one client has requested discovery, maintain
         * list of found devices and name confirming for legacy devices.
+        * Otherwise, this is an event from passive discovery and we
+        * should check if the device needs connecting to.
         */
        if (!adapter->discovery_list)
-               goto done;
+               goto connect_le;
 
        if (g_slist_find(adapter->discovery_found, dev))
                return;
@@ -4132,11 +4129,9 @@ static void update_found_devices(struct btd_adapter *adapter,
        adapter->discovery_found = g_slist_prepend(adapter->discovery_found,
                                                                        dev);
 
-done:
-       /* Don't trigger LE connections through normal discovery */
-       if (!adapter->passive_scanning)
-               return;
+       return;
 
+connect_le:
        /*
         * If this is an LE device that's not connected and part of the
         * connect_list stop passive scanning so that a connection