summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-05-19 23:33:17 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-05-19 23:33:17 -0500
commit96480e44b2be962899bfbbf6f56d33dc88d43563 (patch)
tree267aa51a2ea6c23809c397402de705d4ecc9b53c
parent36e9803cdc0507994c2c5837deff32cf96f36a03 (diff)
downloadofono-96480e44b2be962899bfbbf6f56d33dc88d43563.tar.bz2
netreg: Fix crash when CREG is reported too early
If we register for CREG notifications before the netreg atom is registered (e.g. in MBM due to CIND queries) we crash if the CREG notification arrives before the CIND is queried.
-rw-r--r--drivers/atmodem/network-registration.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index d3d8d71c..f946b310 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -810,6 +810,8 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
NULL, NULL, NULL);
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;
@@ -834,25 +836,16 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
return;
}
- g_at_chat_register(nd->chat, "+CREG:",
- creg_notify, FALSE, netreg, NULL);
-
switch (nd->vendor) {
case OFONO_VENDOR_PHONESIM:
g_at_chat_register(nd->chat, "+CSQ:",
csq_notify, FALSE, netreg, NULL);
-
- ofono_netreg_register(netreg);
-
break;
case OFONO_VENDOR_CALYPSO:
g_at_chat_send(nd->chat, "AT%CSQ=1", none_prefix,
NULL, NULL, NULL);
g_at_chat_register(nd->chat, "%CSQ:", calypso_csq_notify,
FALSE, netreg, NULL);
-
- ofono_netreg_register(netreg);
-
break;
case OFONO_VENDOR_OPTION_HSO:
g_at_chat_send(nd->chat, "AT_OSSYS=1", none_prefix,
@@ -892,9 +885,6 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
NULL, NULL, NULL);
g_at_chat_send(nd->chat, "AT_ODO=0", none_prefix,
NULL, NULL, NULL);
-
- ofono_netreg_register(netreg);
-
break;
case OFONO_VENDOR_MBM:
@@ -904,17 +894,22 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
FALSE, netreg, NULL);
g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
cind_support_cb, netreg, NULL);
-
- break;
+ return;
case OFONO_VENDOR_HUAWEI:
- /* huawei doesn't support CIND */
- ofono_netreg_register(netreg);
+ /*
+ * Huawei doesn't support CIND, signal strength reported
+ * in the modem driver
+ */
break;
default:
g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
cind_support_cb, netreg, NULL);
- break;
+ return;
}
+
+ g_at_chat_register(nd->chat, "+CREG:",
+ creg_notify, FALSE, netreg, NULL);
+ ofono_netreg_register(netreg);
}
static void at_creg_test_cb(gboolean ok, GAtResult *result, gpointer user_data)