* no compiled in support or the driver is not yet loaded.
*/
static GSList *techless_device_list = NULL;
+static GHashTable *rfkill_list;
static connman_bool_t global_offlinemode;
int refcount;
enum connman_service_type type;
char *path;
- GHashTable *rfkill_list;
GSList *device_list;
int enabled;
char *regdom;
return driver2->priority - driver1->priority;
}
+static void rfkill_check(gpointer key, gpointer value, gpointer user_data)
+{
+ struct connman_rfkill *rfkill = value;
+ enum connman_service_type type = GPOINTER_TO_INT(user_data);
+
+ /* Calling _technology_rfkill_add will update the tech. */
+ if (rfkill->type == type)
+ __connman_technology_add_rfkill(rfkill->index, type,
+ rfkill->softblock, rfkill->hardblock);
+}
+
/**
* connman_technology_driver_register:
* @driver: Technology driver definition
compare_priority);
if (techless_device_list == NULL)
- return 0;
+ goto check_rfkill;
/*
* Check for technology less devices if this driver
__connman_technology_add_device(device);
}
+check_rfkill:
+ /* Check for orphaned rfkill switches. */
+ g_hash_table_foreach(rfkill_list, rfkill_check,
+ GINT_TO_POINTER(driver->type));
+
return 0;
}
technology->path = g_strdup_printf("%s/technology/%s",
CONNMAN_PATH, str);
- technology->rfkill_list = g_hash_table_new_full(g_int_hash, g_int_equal,
- NULL, free_rfkill);
technology->device_list = NULL;
technology->pending_reply = NULL;
CONNMAN_TECHNOLOGY_INTERFACE);
g_slist_free(technology->device_list);
- g_hash_table_destroy(technology->rfkill_list);
g_free(technology->path);
g_free(technology->regdom);
DBG("index %u type %d soft %u hard %u", index, type,
softblock, hardblock);
- technology = technology_get(type);
- if (technology == NULL)
- return -ENXIO;
+ rfkill = g_hash_table_lookup(rfkill_list, &index);
+ if (rfkill != NULL)
+ goto done;
rfkill = g_try_new0(struct connman_rfkill, 1);
if (rfkill == NULL)
rfkill->softblock = softblock;
rfkill->hardblock = hardblock;
- g_hash_table_replace(technology->rfkill_list, &rfkill->index, rfkill);
+ g_hash_table_insert(rfkill_list, &rfkill->index, rfkill);
+
+done:
+ technology = technology_get(type);
+ /* If there is no driver for this type, ignore it. */
+ if (technology == NULL)
+ return -ENXIO;
if (hardblock) {
DBG("%s is switched off.", get_name(type));
DBG("index %u soft %u hard %u", index, softblock, hardblock);
- technology = technology_find(type);
- if (technology == NULL)
- return -ENXIO;
-
- rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
+ rfkill = g_hash_table_lookup(rfkill_list, &index);
if (rfkill == NULL)
return -ENXIO;
return 0;
}
+ technology = technology_get(type);
+ /* If there is no driver for this type, ignore it. */
+ if (technology == NULL)
+ return -ENXIO;
+
if (!global_offlinemode) {
if (technology->enable_persistent && softblock)
return __connman_rfkill_block(type, FALSE);
DBG("index %u", index);
- technology = technology_find(type);
- if (technology == NULL)
- return -ENXIO;
-
- rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
+ rfkill = g_hash_table_lookup(rfkill_list, &index);
if (rfkill == NULL)
return -ENXIO;
- g_hash_table_remove(technology->rfkill_list, &index);
+ g_hash_table_remove(rfkill_list, &index);
+
+ technology = technology_find(type);
+ if (technology == NULL)
+ return -ENXIO;
technology_put(technology);
connection = connman_dbus_get_connection();
+ rfkill_list = g_hash_table_new_full(g_int_hash, g_int_equal,
+ NULL, free_rfkill);
+
global_offlinemode = connman_technology_load_offlinemode();
return 0;
{
DBG("");
+ g_hash_table_destroy(rfkill_list);
+
dbus_connection_unref(connection);
}