We have implemented a driver for the Gemalto modem we are using and today I noticed that it got stuck in initialization (during enable). The problem is that the AT+CFUN=4 (which is the last step of our init) now returned a CME error. The error handling for this is inspired from all the other drivers:


static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct verimalto_data *data = ofono_modem_get_data(modem);

if (!ok) {
g_at_chat_unref(data->app);
data->app = NULL;

g_at_chat_unref(data->mdm);
data->mdm = NULL;

ofono_modem_set_powered(modem, FALSE);
return;
}

// Get initial SIM state
data->sim_state_query = at_util_sim_state_query_new(data->app,
2, 20, sim_state_cb, modem,
NULL);
}

This will put the modem in not powered state. The problem is that as it has not completed the initialization, there is now no interfaces at all set up. So we can not try to power it again or anything else. Are all these drivers having an issue with error handling or have I missed something else? And how could I handle it better?