summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem/network-registration.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2012-09-11 23:21:27 -0500
committerDenis Kenzior <denkenz@gmail.com>2012-09-11 23:21:48 -0500
commitb274e74102c7a4b96c06dba895cf0cb444fa54c3 (patch)
treebb12cab6cdc5a0ebb24997092bfbb7595aa6f6cb /drivers/atmodem/network-registration.c
parentbb0f308223816e53de0a5a6a2cdb6eb1f11856c8 (diff)
downloadofono-b274e74102c7a4b96c06dba895cf0cb444fa54c3.tar.bz2
netreg: Remove netreg atom in case init fails
Diffstat (limited to 'drivers/atmodem/network-registration.c')
-rw-r--r--drivers/atmodem/network-registration.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index d4c090ac..ff73dab3 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -1431,14 +1431,36 @@ static void at_cmer_not_supported(struct ofono_netreg *netreg)
{
ofono_error("+CMER not supported by this modem. If this is an error"
" please submit patches to support this hardware");
+
+ ofono_netreg_remove(netreg);
}
static void at_cmer_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
+ struct netreg_data *nd = ofono_netreg_get_data(netreg);
- if (!ok)
+ if (!ok) {
at_cmer_not_supported(netreg);
+ return;
+ }
+
+ /*
+ * Telit uses strings instead of numbers to identify indicators
+ * in a +CIEV URC.
+ * Handle them in a separate function to keep the code clean.
+ */
+ if (nd->vendor == OFONO_VENDOR_TELIT)
+ g_at_chat_register(nd->chat, "+CIEV:",
+ telit_ciev_notify, FALSE, netreg, NULL);
+ else
+ g_at_chat_register(nd->chat, "+CIEV:",
+ ciev_notify, FALSE, netreg, NULL);
+
+ g_at_chat_register(nd->chat, "+CREG:",
+ creg_notify, FALSE, netreg, NULL);
+
+ ofono_netreg_register(netreg);
}
static inline char wanted_cmer(int supported, const char *pref)
@@ -1648,22 +1670,6 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_send(nd->chat, "AT+CMER=?", cmer_prefix,
at_cmer_query_cb, netreg, NULL);
- /*
- * Telit uses strings instead of numbers to identify indicators
- * in a +CIEV URC.
- * Handle them in a separate function to keep the code clean.
- */
- if (nd->vendor == OFONO_VENDOR_TELIT)
- g_at_chat_register(nd->chat, "+CIEV:",
- telit_ciev_notify, FALSE, netreg, NULL);
- else
- g_at_chat_register(nd->chat, "+CIEV:",
- ciev_notify, FALSE, netreg, NULL);
-
- g_at_chat_register(nd->chat, "+CREG:",
- creg_notify, FALSE, netreg, NULL);
-
- ofono_netreg_register(netreg);
return;
error: