diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2012-10-15 15:35:19 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-10-16 15:05:36 +0300 |
commit | 402f621c827bce947fe1ae89529fa3860e904f62 (patch) | |
tree | 645101aa8ff98aaaf99faf3eebc31b10fd751129 /src/technology.c | |
parent | 02ca316c6fa5dd6d46d500442799696551271cee (diff) | |
download | connman-402f621c827bce947fe1ae89529fa3860e904f62.tar.gz connman-402f621c827bce947fe1ae89529fa3860e904f62.tar.bz2 connman-402f621c827bce947fe1ae89529fa3860e904f62.zip |
technology: Use the right method to enable or disable
If rfkill driven, use rfkill soft block/unblock. If not, request the
device to be enabled or disabled.
Diffstat (limited to 'src/technology.c')
-rw-r--r-- | src/technology.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/technology.c b/src/technology.c index d2c074ec..4ae5b865 100644 --- a/src/technology.c +++ b/src/technology.c @@ -596,8 +596,7 @@ static int technology_affect_devices(struct connman_technology *technology, return err; } -static int technology_enable(struct connman_technology *technology, - connman_bool_t hardblock) +static int technology_enable(struct connman_technology *technology) { DBG("technology %p enable", technology); @@ -608,16 +607,13 @@ static int technology_enable(struct connman_technology *technology, if (technology->pending_reply != NULL) return -EBUSY; - if (hardblock == TRUE && technology->enable_persistent == FALSE) - return 0; - - __connman_rfkill_block(technology->type, FALSE); + if (technology->rfkill_driven == TRUE) + return __connman_rfkill_block(technology->type, FALSE); return technology_affect_devices(technology, TRUE); } -static int technology_disable(struct connman_technology *technology, - connman_bool_t hardblock) +static int technology_disable(struct connman_technology *technology) { DBG("technology %p disable", technology); @@ -631,8 +627,8 @@ static int technology_disable(struct connman_technology *technology, if (technology->tethering == TRUE) set_tethering(technology, FALSE); - if (hardblock == FALSE) - __connman_rfkill_block(technology->type, TRUE); + if (technology->rfkill_driven == TRUE) + return __connman_rfkill_block(technology->type, TRUE); return technology_affect_devices(technology, FALSE); } @@ -649,9 +645,9 @@ static DBusMessage *set_powered(struct connman_technology *technology, } if (powered == TRUE) - err = technology_enable(technology, FALSE); + err = technology_enable(technology); else - err = technology_disable(technology, FALSE); + err = technology_disable(technology); if (err != -EBUSY) { technology->enable_persistent = powered; @@ -1144,9 +1140,18 @@ int __connman_technology_add_device(struct connman_device *device) return -ENXIO; } - if (technology->enable_persistent && - global_offlinemode == FALSE && - technology->hardblocked == FALSE) { + __sync_synchronize(); + if (technology->rfkill_driven == TRUE) { + if (technology->enabled == TRUE) + __connman_device_enable(device); + else + __connman_device_disable(device); + + goto done; + } + + if (technology->enable_persistent == TRUE && + global_offlinemode == FALSE) { int err = __connman_device_enable(device); /* * connman_technology_add_device() calls __connman_device_enable() @@ -1157,11 +1162,11 @@ int __connman_technology_add_device(struct connman_device *device) if (err == -EALREADY) __connman_technology_enabled(type); } - /* if technology persistent state is offline or hardblocked */ - if (technology->enable_persistent == FALSE || - technology->hardblocked == TRUE) + /* if technology persistent state is offline */ + if (technology->enable_persistent == FALSE) __connman_device_disable(device); +done: technology->device_list = g_slist_prepend(technology->device_list, device); @@ -1283,10 +1288,10 @@ int __connman_technology_set_offlinemode(connman_bool_t offlinemode) struct connman_technology *technology = list->data; if (offlinemode) - err = technology_disable(technology, FALSE); + err = technology_disable(technology); if (!offlinemode && technology->enable_persistent) - err = technology_enable(technology, FALSE); + err = technology_enable(technology); } if (err == 0 || err == -EINPROGRESS || err == -EALREADY) { @@ -1346,10 +1351,10 @@ static connman_bool_t technology_apply_rfkill_change(struct connman_technology * if (hardblock == TRUE) { DBG("%s is switched off.", get_name(technology->type)); - technology_disable(technology, TRUE); + technology_disable(technology); technology_dbus_unregister(technology); } else { - technology_enable(technology, TRUE); + technology_enable(technology); technology_dbus_register(technology); } |