adapter: Remove timer for removing temporary devices
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 15 Jul 2020 20:29:24 +0000 (13:29 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
Now that each temporary device object can cleanup after it has detected
that it has disappeared it is no longer necessary to keep this logic as
well in the adapter.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c

index 0757237..bc39e6f 100644 (file)
@@ -329,7 +329,6 @@ struct btd_adapter {
        guint le_discovery_idle_timeout;        /* timeout between le discovery runs */
 #endif
        guint passive_scan_timeout;     /* timeout between passive scans */
-       guint temp_devices_timeout;     /* timeout for temporary devices */
 
        guint pairable_timeout_id;      /* pairable timeout id */
        guint auth_idle_id;             /* Pending authorization dequeue */
@@ -2029,27 +2028,6 @@ static void invalidate_rssi_and_tx_power(gpointer a)
        device_set_tx_power(dev, 127);
 }
 
-static gboolean remove_temp_devices(gpointer user_data)
-{
-       struct btd_adapter *adapter = user_data;
-       GSList *l, *next;
-
-       DBG("%s", adapter->path);
-
-       adapter->temp_devices_timeout = 0;
-
-       for (l = adapter->devices; l != NULL; l = next) {
-               struct btd_device *dev = l->data;
-
-               next = g_slist_next(l);
-
-               if (device_is_temporary(dev) && !btd_device_is_connected(dev))
-                       btd_adapter_remove_device(adapter, dev);
-       }
-
-       return FALSE;
-}
-
 static void discovery_cleanup(struct btd_adapter *adapter, int timeout)
 {
        GSList *l, *next;
@@ -2061,11 +2039,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout)
                adapter->discovery_idle_timeout = 0;
        }
 
-       if (adapter->temp_devices_timeout > 0) {
-               g_source_remove(adapter->temp_devices_timeout);
-               adapter->temp_devices_timeout = 0;
-       }
-
        g_slist_free_full(adapter->discovery_found,
                                                invalidate_rssi_and_tx_power);
        adapter->discovery_found = NULL;
@@ -2087,9 +2060,6 @@ static void discovery_cleanup(struct btd_adapter *adapter, int timeout)
                btd_adapter_remove_device(adapter, dev);
 
        }
-
-       adapter->temp_devices_timeout = g_timeout_add_seconds(timeout,
-                                               remove_temp_devices, adapter);
 }
 
 static void discovery_free(void *user_data)
@@ -3181,20 +3151,8 @@ static void discovery_destroy(void *user_data)
        adapter->discovery_type = 0x00;
 #endif
 
-       if (adapter->discovery_idle_timeout > 0) {
-               g_source_remove(adapter->discovery_idle_timeout);
-               adapter->discovery_idle_timeout = 0;
-       }
-
-       if (adapter->temp_devices_timeout > 0) {
-               g_source_remove(adapter->temp_devices_timeout);
-               adapter->temp_devices_timeout = 0;
-       }
-
        discovery_cleanup(adapter, 0);
 
-       adapter->temp_devices_timeout = g_timeout_add_seconds(TEMP_DEV_TIMEOUT,
-                                               remove_temp_devices, adapter);
 }
 
 static void discovery_disconnect(DBusConnection *conn, void *user_data)
@@ -3269,11 +3227,6 @@ static void le_discovery_destroy(void *user_data)
                adapter->discovery_idle_timeout = 0;
        }
 
-       if (adapter->temp_devices_timeout > 0) {
-               g_source_remove(adapter->temp_devices_timeout);
-               adapter->temp_devices_timeout = 0;
-       }
-
        discovery_cleanup(adapter, 0);
 }
 
@@ -11422,11 +11375,6 @@ static void adapter_remove(struct btd_adapter *adapter)
                adapter->discovery_idle_timeout = 0;
        }
 
-       if (adapter->temp_devices_timeout > 0) {
-               g_source_remove(adapter->temp_devices_timeout);
-               adapter->temp_devices_timeout = 0;
-       }
-
        discovery_cleanup(adapter, 0);
 
        g_slist_free(adapter->connect_list);