From: "Gustavo F. Padovan" <[email protected]>

---
 plugins/telit.c |   78 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/plugins/telit.c b/plugins/telit.c
index 5d72b79..47a82d9 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -280,6 +280,43 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
        }
 }
 
+static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+       struct ofono_modem *modem = user_data;
+       struct telit_data *data = ofono_modem_get_data(modem);
+
+       if(data->sap_modem)
+               modem = data->sap_modem;
+
+       DBG("%p", modem);
+
+       g_at_chat_unref(data->chat);
+       data->chat = NULL;
+
+       if (data->sim_inserted_source > 0)
+               g_source_remove(data->sim_inserted_source);
+
+       if (ok)
+               ofono_modem_set_powered(modem, FALSE);
+
+       data->sap_modem = NULL;
+}
+
+static int telit_disable(struct ofono_modem *modem)
+{
+       struct telit_data *data = ofono_modem_get_data(modem);
+       DBG("%p", modem);
+
+       g_at_chat_cancel_all(data->chat);
+       g_at_chat_unregister_all(data->chat);
+
+       /* Power down modem */
+       g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
+                               cfun_disable_cb, modem, NULL);
+
+       return -EINPROGRESS;
+}
+
 static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
        struct ofono_modem *modem = user_data;
@@ -290,8 +327,7 @@ static void rsen_disable_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
        g_at_chat_unref(data->aux);
        data->aux = NULL;
 
-       if (ok)
-               ofono_modem_set_powered(data->sap_modem, FALSE);
+       telit_disable(modem);
 }
 
 static int telit_sap_open(struct ofono_modem *modem)
@@ -350,10 +386,10 @@ static int telit_sap_disable(struct ofono_modem *modem)
 
        DBG("%p", modem);
 
-       g_at_chat_cancel_all(data->chat);
-       g_at_chat_unregister_all(data->chat);
+       g_at_chat_cancel_all(data->aux);
+       g_at_chat_unregister_all(data->aux);
 
-       g_at_chat_send(data->chat, "AT#RSEN=0", rsen_prefix,
+       g_at_chat_send(data->aux, "AT#RSEN=0", rsen_prefix,
                                rsen_disable_cb, modem, NULL);
 
        return 0;
@@ -482,38 +518,6 @@ static void telit_remove(struct ofono_modem *modem)
        g_free(data);
 }
 
-static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
-       struct ofono_modem *modem = user_data;
-       struct telit_data *data = ofono_modem_get_data(modem);
-
-       DBG("%p", modem);
-
-       g_at_chat_unref(data->chat);
-       data->chat = NULL;
-
-       if (data->sim_inserted_source > 0)
-               g_source_remove(data->sim_inserted_source);
-
-       if (ok)
-               ofono_modem_set_powered(modem, FALSE);
-}
-
-static int telit_disable(struct ofono_modem *modem)
-{
-       struct telit_data *data = ofono_modem_get_data(modem);
-       DBG("%p", modem);
-
-       g_at_chat_cancel_all(data->chat);
-       g_at_chat_unregister_all(data->chat);
-
-       /* Power down modem */
-       g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
-                               cfun_disable_cb, modem, NULL);
-
-       return -EINPROGRESS;
-}
-
 static struct ofono_modem_driver telit_driver = {
        .name           = "telit",
        .probe          = telit_probe,
-- 
1.7.6.2

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to