summaryrefslogtreecommitdiffstats
path: root/plugins/ifx.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-10-24 20:15:45 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-10-24 20:15:45 +0200
commit2c863506d3fb6e6421fbb4c1940359d1ec1c9ded (patch)
tree8e5fc70c5cb5d0f503d0645724285338998ecee8 /plugins/ifx.c
parent4a5f37dafdecf567e372b90adb38d41281d6e213 (diff)
downloadofono-2c863506d3fb6e6421fbb4c1940359d1ec1c9ded.tar.bz2
ifx: Detect when DLC shutdown happens
In case one of the DLCs shuts down, the system has an undefined state and thus just shutdown the whole device.
Diffstat (limited to 'plugins/ifx.c')
-rw-r--r--plugins/ifx.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/plugins/ifx.c b/plugins/ifx.c
index 430db22a..9c3c3e3d 100644
--- a/plugins/ifx.c
+++ b/plugins/ifx.c
@@ -183,28 +183,6 @@ static void xsim_notify(GAtResult *result, gpointer user_data)
}
}
-static GAtChat *create_chat(GIOChannel *channel, char *debug)
-{
- GAtSyntax *syntax;
- GAtChat *chat;
-
- if (!channel)
- return NULL;
-
- syntax = g_at_syntax_new_gsmv1();
- chat = g_at_chat_new(channel, syntax);
- g_at_syntax_unref(syntax);
- g_io_channel_unref(channel);
-
- if (!chat)
- return NULL;
-
- if (getenv("OFONO_AT_DEBUG"))
- g_at_chat_set_debug(chat, ifx_debug, debug);
-
- return chat;
-}
-
static void shutdown_device(struct ifx_data *data)
{
int i, fd;
@@ -241,6 +219,43 @@ done:
data->device = NULL;
}
+static void dlc_disconnect(gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ifx_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ ofono_warn("Disconnect of modem channel");
+
+ shutdown_device(data);
+}
+
+static GAtChat *create_chat(GIOChannel *channel, struct ofono_modem *modem,
+ char *debug)
+{
+ GAtSyntax *syntax;
+ GAtChat *chat;
+
+ if (!channel)
+ return NULL;
+
+ syntax = g_at_syntax_new_gsmv1();
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(channel);
+
+ if (!chat)
+ return NULL;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, ifx_debug, debug);
+
+ g_at_chat_set_disconnect_function(chat, dlc_disconnect, modem);
+
+ return chat;
+}
+
static void xgendata_query(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -389,7 +404,7 @@ static gboolean dlc_ready_check(gpointer user_data)
for (i = 0; i < NUM_DLC; i++) {
GIOChannel *channel = g_at_tty_open(dlc_nodes[i], NULL);
- data->dlcs[i] = create_chat(channel, dlc_prefixes[i]);
+ data->dlcs[i] = create_chat(channel, modem, dlc_prefixes[i]);
if (!data->dlcs[i]) {
ofono_error("Failed to open %s", dlc_nodes[i]);
goto error;
@@ -438,7 +453,7 @@ static void setup_internal_mux(struct ofono_modem *modem)
for (i = 0; i < NUM_DLC; i++) {
GIOChannel *channel = g_at_mux_create_channel(data->mux);
- data->dlcs[i] = create_chat(channel, dlc_prefixes[i]);
+ data->dlcs[i] = create_chat(channel, modem, dlc_prefixes[i]);
if (!data->dlcs[i]) {
ofono_error("Failed to create channel");
goto error;