Hi Martin,
huawei_disconnect is used to recovery the io and gprs context when
io error happends, see commit 39382730d7758b093ca6271f4e9dea875fa04b3a
However, io error not only happends at PPP disconnect, in theory it
can happends at any situation. I also observed that it happens when modem
go into offline mode at my Huawei EM770W modem. in this case, gprs should
not be reopened.
<snip>
static void huawei_set_online(struct ofono_modem *modem,
ofono_bool_t online,
@@ -595,21 +611,26 @@ static void huawei_set_online(struct ofono_modem *modem,
ofono_bool_t online,
{
struct huawei_data *data = ofono_modem_get_data(modem);
GAtChat *chat = data->pcui;
- struct cb_data *cbd = cb_data_new(cb, user_data);
+ struct huawei_cb_data *online_cbd;
char const *command = online ? "AT+CFUN=1" : "AT+CFUN=5";
DBG("modem %p %s", modem, online ? "online" :
"offline");
- if (cbd == NULL)
+ online_cbd = g_try_new0(struct huawei_cb_data, 1);
+ online_cbd->cbd = cb_data_new(cb, user_data);
+ if (online_cbd->cbd == NULL)
goto error;
you know that you are doing exactly the wrong NULL pointer checks
here ;)
Anyhow, we need to get rid of the if (cbd == NULL) check first. A while
back we changed cb_data_new() to use g_new0() instead of g_try_new0() to
simplify the code. So first that should be all cleaned up.
A quick grep showed these locations for the AT modems:
drivers/mbmmodem/location-reporting.c: if (cbd == NULL)
plugins/bluetooth.c: if (cbd == NULL) {
plugins/huawei.c: if (cbd == NULL)
The ISI modem stuff is a different story and needs to be tackled
separately anyway.
Regards
Marcel