summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlok Barsode <alok.barsode@linux.intel.com>2011-08-24 16:44:11 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-08-25 11:14:21 +0200
commit1780bb28cfc7198483f0bd36aa0a90020698e2ba (patch)
treec86b9296ed1bd7f0c0ed8ea4c86e8c96e1d284aa
parent902f7b27814640781c07158b25bf9c7738338cf2 (diff)
downloadconnman-1780bb28cfc7198483f0bd36aa0a90020698e2ba.tar.gz
connman-1780bb28cfc7198483f0bd36aa0a90020698e2ba.tar.bz2
connman-1780bb28cfc7198483f0bd36aa0a90020698e2ba.zip
technology: Remove global rfkill table
Remove the global rfkill_table and maintain a per technology rfkill table.
-rw-r--r--src/connman.h4
-rw-r--r--src/rfkill.c9
-rw-r--r--src/technology.c16
3 files changed, 13 insertions, 16 deletions
diff --git a/src/connman.h b/src/connman.h
index 0a448051..08e1fed4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -324,9 +324,11 @@ int __connman_technology_add_rfkill(unsigned int index,
connman_bool_t softblock,
connman_bool_t hardblock);
int __connman_technology_update_rfkill(unsigned int index,
+ enum connman_service_type type,
connman_bool_t softblock,
connman_bool_t hardblock);
-int __connman_technology_remove_rfkill(unsigned int index);
+int __connman_technology_remove_rfkill(unsigned int index,
+ enum connman_service_type type);
void __connman_technology_add_interface(enum connman_service_type type,
int index, const char *name, const char *ident);
diff --git a/src/rfkill.c b/src/rfkill.c
index 2a4458b8..3d214ef3 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -99,18 +99,19 @@ static GIOStatus rfkill_process(GIOChannel *chan)
event->type, event->op,
event->soft, event->hard);
+ type = convert_type(event->type);
+
switch (event->op) {
case RFKILL_OP_ADD:
- type = convert_type(event->type);
__connman_technology_add_rfkill(event->idx, type,
event->soft, event->hard);
break;
case RFKILL_OP_DEL:
- __connman_technology_remove_rfkill(event->idx);
+ __connman_technology_remove_rfkill(event->idx, type);
break;
case RFKILL_OP_CHANGE:
- __connman_technology_update_rfkill(event->idx, event->soft,
- event->hard);
+ __connman_technology_update_rfkill(event->idx, type,
+ event->soft, event->hard);
break;
default:
break;
diff --git a/src/technology.c b/src/technology.c
index cc446580..849d72a5 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -32,7 +32,6 @@
static DBusConnection *connection;
-static GHashTable *rfkill_table;
static GHashTable *device_table;
static GSList *technology_list = NULL;
@@ -908,8 +907,6 @@ int __connman_technology_add_rfkill(unsigned int index,
rfkill->softblock = softblock;
rfkill->hardblock = hardblock;
- g_hash_table_replace(rfkill_table, &rfkill->index, technology);
-
g_hash_table_replace(technology->rfkill_list, &rfkill->index, rfkill);
blocked = (softblock || hardblock) ? TRUE : FALSE;
@@ -927,6 +924,7 @@ int __connman_technology_add_rfkill(unsigned int index,
}
int __connman_technology_update_rfkill(unsigned int index,
+ enum connman_service_type type,
connman_bool_t softblock,
connman_bool_t hardblock)
{
@@ -936,7 +934,7 @@ int __connman_technology_update_rfkill(unsigned int index,
DBG("index %u soft %u hard %u", index, softblock, hardblock);
- technology = g_hash_table_lookup(rfkill_table, &index);
+ technology = technology_find(type);
if (technology == NULL)
return -ENXIO;
@@ -976,7 +974,8 @@ int __connman_technology_update_rfkill(unsigned int index,
return 0;
}
-int __connman_technology_remove_rfkill(unsigned int index)
+int __connman_technology_remove_rfkill(unsigned int index,
+ enum connman_service_type type)
{
struct connman_technology *technology;
struct connman_rfkill *rfkill;
@@ -984,7 +983,7 @@ int __connman_technology_remove_rfkill(unsigned int index)
DBG("index %u", index);
- technology = g_hash_table_lookup(rfkill_table, &index);
+ technology = technology_find(type);
if (technology == NULL)
return -ENXIO;
@@ -996,8 +995,6 @@ int __connman_technology_remove_rfkill(unsigned int index)
g_hash_table_remove(technology->rfkill_list, &index);
- g_hash_table_remove(rfkill_table, &index);
-
if (blocked &&
g_atomic_int_dec_and_test(&technology->blocked) == TRUE) {
technology_blocked(technology, FALSE);
@@ -1028,8 +1025,6 @@ int __connman_technology_init(void)
connection = connman_dbus_get_connection();
- rfkill_table = g_hash_table_new_full(g_int_hash, g_int_equal,
- NULL, unregister_technology);
device_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, unregister_technology);
@@ -1041,7 +1036,6 @@ void __connman_technology_cleanup(void)
DBG("");
g_hash_table_destroy(device_table);
- g_hash_table_destroy(rfkill_table);
dbus_connection_unref(connection);
}