technology: Handle harblock if all of them have identical type
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 2 Oct 2012 09:27:11 +0000 (12:27 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 3 Oct 2012 10:18:26 +0000 (13:18 +0300)
On some hardware, there exist two rfkill entities for the same type
with a cascading issue: if one is soft blocked, the other one is
hardblocked. But if the hardblock switch is set, all are hardblocked.
This patch figures out that a technology is hardblocked only if all
related rkill events get the same hardblock value.

src/technology.c

index 1486122288f1f1dc1778f576d0fb7be47b1b20b2..e9598aa5d08f81f84479f7492e12bf6741d96a1b 100644 (file)
@@ -1290,9 +1290,28 @@ void __connman_technology_set_connected(enum connman_service_type type,
 static void technology_apply_hardblock_change(struct connman_technology *technology,
                                                connman_bool_t hardblock)
 {
+       gboolean apply = TRUE;
+       GList *start, *list;
+
        if (technology->hardblocked == hardblock)
                return;
 
+       start = g_hash_table_get_values(rfkill_list);
+       for (list = start; list != NULL; list = list->next) {
+               struct connman_rfkill *rfkill = list->data;
+
+               if (rfkill->type != technology->type)
+                       continue;
+
+               if (rfkill->hardblock != hardblock)
+                       apply = FALSE;
+       }
+
+       g_list_free(start);
+
+       if (apply == FALSE)
+               return;
+
        technology->hardblocked = hardblock;
 
        if (hardblock == TRUE)