if (powered == TRUE) {
if (driver->enable) {
err = driver->enable(device);
- __connman_notifier_enable(type);
+ if (err == 0)
+ __connman_notifier_enable(type);
} else
err = -EINVAL;
} else {
if (driver->disable) {
err = driver->disable(device);
- __connman_notifier_disable(type);
+ if (err == 0)
+ __connman_notifier_disable(type);
} else
err = -EINVAL;
}
static void device_enable(struct connman_device *device)
{
- enum connman_service_type type;
-
DBG("device %p", device);
if (device->powered == TRUE)
return;
- type = __connman_device_get_service_type(device);
-
if (device->driver->enable) {
- if (device->driver->enable(device) == 0)
+ if (device->driver->enable(device) == 0) {
+ enum connman_service_type type;
+
device->powered = TRUE;
- __connman_notifier_enable(type);
+
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_enable(type);
+ }
}
}
static void device_disable(struct connman_device *device)
{
- enum connman_service_type type;
-
DBG("device %p", device);
if (device->powered == FALSE)
g_hash_table_remove_all(device->networks);
- type = __connman_device_get_service_type(device);
-
if (device->driver->disable) {
- if (device->driver->disable(device) == 0)
+ if (device->driver->disable(device) == 0) {
+ enum connman_service_type type;
+
device->powered = FALSE;
- __connman_notifier_disable(type);
+
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_disable(type);
+ }
}
}
int connman_device_set_powered(struct connman_device *device,
connman_bool_t powered)
{
+ enum connman_service_type type;
+
DBG("driver %p powered %d", device, powered);
if (device->timeout > 0) {
device->powered = powered;
+ type = __connman_device_get_service_type(device);
+
+ if (device->powered == TRUE)
+ __connman_notifier_enable(type);
+ else
+ __connman_notifier_disable(type);
+
if (device->registered == FALSE)
return 0;