emulator: always create emulators in offline state
authorFrédéric Danis <frederic.danis@linux.intel.com>
Thu, 17 Feb 2011 17:23:29 +0000 (18:23 +0100)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 17 Feb 2011 17:25:27 +0000 (11:25 -0600)
this allows to fix problem when atom created in online state
are destroyed when modem goes to offline state

src/emulator.c
src/modem.c
src/ofono.h

index 5744903..101b33d 100644 (file)
@@ -115,7 +115,8 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 
        em->type = type;
 
-       em->atom = __ofono_modem_add_atom(modem, atom_t, emulator_remove, em);
+       em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
+                                                       emulator_remove, em);
 
        return em;
 }
index 8567cac..bf8b0c0 100644 (file)
@@ -189,6 +189,20 @@ struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
        return atom;
 }
 
+struct ofono_atom *__ofono_modem_add_atom_offline(struct ofono_modem *modem,
+                                       enum ofono_atom_type type,
+                                       void (*destruct)(struct ofono_atom *),
+                                       void *data)
+{
+       struct ofono_atom *atom;
+
+       atom = __ofono_modem_add_atom(modem, type, destruct, data);
+
+       atom->modem_state = MODEM_STATE_OFFLINE;
+
+       return atom;
+}
+
 void *__ofono_atom_get_data(struct ofono_atom *atom)
 {
        return atom->data;
index f52356e..9d13684 100644 (file)
@@ -148,6 +148,11 @@ struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
                                        void (*destruct)(struct ofono_atom *),
                                        void *data);
 
+struct ofono_atom *__ofono_modem_add_atom_offline(struct ofono_modem *modem,
+                                       enum ofono_atom_type type,
+                                       void (*destruct)(struct ofono_atom *),
+                                       void *data);
+
 struct ofono_atom *__ofono_modem_find_atom(struct ofono_modem *modem,
                                                enum ofono_atom_type type);