aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-12-27 07:23:01 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-12-27 08:48:11 +0100
commitf923e95861eb65a29ba9ced2040abaed8add6703 (patch)
tree19a78e8ede4845470e96d532b5e3e4e4412b5bda /src/mm-base-modem.c
parent4ffa871228fa9b267f1647bf73238811e20e51b7 (diff)
base-modem: don't set the modem valid if we didn't export the Modem interface
If an error occurs early during the initialization (e.g. during port setup), we would be aborting without even having exported the modem interface. So detect that case and skip setting the modem as valid.
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r--src/mm-base-modem.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index db277097..c66ec53c 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -781,21 +781,28 @@ initialize_ready (MMBaseModem *self,
{
GError *error = NULL;
- if (!mm_base_modem_initialize_finish (self, res, &error)) {
- /* Wrong state is returned when modem is found locked */
- if (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE))
- mm_dbg ("Couldn't finish initialization in the current state: '%s'",
- error->message);
- else
- mm_warn ("couldn't initialize the modem: '%s'", error->message);
- g_error_free (error);
- } else
+ if (mm_base_modem_initialize_finish (self, res, &error)) {
mm_dbg ("modem properly initialized");
+ mm_base_modem_set_valid (self, TRUE);
+ return;
+ }
- /* Even with initialization errors, we do set the state to valid, so
- * that the modem gets exported and the failure notified to the user.
- */
- mm_base_modem_set_valid (self, TRUE);
+ /* Wrong state is returned when modem is found locked */
+ if (g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE)) {
+ /* Even with initialization errors, we do set the state to valid, so
+ * that the modem gets exported and the failure notified to the user.
+ */
+ mm_dbg ("Couldn't finish initialization in the current state: '%s'",
+ error->message);
+ g_error_free (error);
+ mm_base_modem_set_valid (self, TRUE);
+ return;
+ }
+
+ /* Really fatal, we cannot even export the failed modem (e.g. error before
+ * even trying to enable the Modem interface */
+ mm_warn ("couldn't initialize the modem: '%s'", error->message);
+ g_error_free (error);
}
static inline void