Toggle offline mode only if device enablement succeeds
authorYing An Deng <ying.an.deng@intel.com>
Tue, 3 Aug 2010 14:48:33 +0000 (16:48 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 3 Aug 2010 15:31:52 +0000 (17:31 +0200)
src/device.c

index fc72544..aab0c83 100644 (file)
@@ -1056,16 +1056,22 @@ int __connman_device_enable(struct connman_device *device)
 
 int __connman_device_enable_persistent(struct connman_device *device)
 {
+       int err;
+
        DBG("device %p", device);
 
        device->powered_persistent = TRUE;
 
-       if (__connman_profile_get_offlinemode() == TRUE)
-               __connman_profile_set_offlinemode(FALSE, FALSE);
-
        __connman_storage_save_device(device);
 
-       return __connman_device_enable(device);
+       err = __connman_device_enable(device);
+       if (err == 0 || err == -EINPROGRESS) {
+               if (__connman_profile_get_offlinemode() == TRUE)
+                       __connman_profile_set_offlinemode(FALSE, FALSE);
+
+       }
+
+       return err;
 }
 
 int __connman_device_disable(struct connman_device *device)