From: Tomasz Gregorek <tomasz.gregorek@gmail.com>
To: ofono@ofono.org
Subject: [PATCH] plugins-mbm: Combining mbm_disable and reopen_callback
Date: Wed, 12 Jan 2011 14:45:42 +0100 [thread overview]
Message-ID: <1294839942-9071-1-git-send-email-tomasz.gregorek@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2587 bytes --]
From: Tomasz Gregorek <tomasz.gregorek@stericsson.com>
Combining mbm_disable and reopen_callback into one and removing 1 second
delay between them to avoid call to reopen_callback after modem being
disconnected.
---
plugins/mbm.c | 41 +++++++++++------------------------------
1 files changed, 11 insertions(+), 30 deletions(-)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index dca9bd8..d1529ac 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -66,7 +66,6 @@ struct mbm_data {
gboolean have_sim;
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
- guint reopen_source;
enum mbm_variant variant;
};
@@ -297,21 +296,26 @@ static GAtChat *create_port(const char *device)
return chat;
}
-static void mbm_disconnect(gpointer user_data);
-
-static gboolean reopen_callback(gpointer user_data)
+static void mbm_disconnect(gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct mbm_data *data = ofono_modem_get_data(modem);
const char *data_dev;
- data->reopen_source = 0;
+ DBG("");
+
+ if (data->gc)
+ ofono_gprs_context_remove(data->gc);
+
+ g_at_chat_unref(data->data_port);
+ data->data_port = NULL;
data_dev = ofono_modem_get_string(modem, "DataDevice");
data->data_port = create_port(data_dev);
+
if (data->data_port == NULL)
- return FALSE;
+ return;
if (getenv("OFONO_AT_DEBUG"))
g_at_chat_set_debug(data->data_port, mbm_debug, "Data: ");
@@ -323,30 +327,12 @@ static gboolean reopen_callback(gpointer user_data)
data->gc = ofono_gprs_context_create(modem, 0,
"atmodem", data->data_port);
+
if (data->gprs && data->gc) {
ofono_gprs_context_set_type(data->gc,
OFONO_GPRS_CONTEXT_TYPE_MMS);
ofono_gprs_add_context(data->gprs, data->gc);
}
-
- return FALSE;
-}
-
-static void mbm_disconnect(gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct mbm_data *data = ofono_modem_get_data(modem);
-
- DBG("");
-
- if (data->gc)
- ofono_gprs_context_remove(data->gc);
-
- g_at_chat_unref(data->data_port);
- data->data_port = NULL;
-
- /* Waiting for the +CGEV: ME DEACT might also work */
- data->reopen_source = g_timeout_add_seconds(1, reopen_callback, modem);
}
static int mbm_enable(struct ofono_modem *modem)
@@ -425,11 +411,6 @@ static int mbm_disable(struct ofono_modem *modem)
DBG("%p", modem);
- if (data->reopen_source > 0) {
- g_source_remove(data->reopen_source);
- data->reopen_source = 0;
- }
-
if (data->modem_port == NULL)
return 0;
--
1.7.1
next reply other threads:[~2011-01-12 13:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 13:45 Tomasz Gregorek [this message]
2011-01-12 16:13 ` [PATCH] plugins-mbm: Combining mbm_disable and reopen_callback Marcel Holtmann
2011-01-12 17:26 ` Tomasz Gregorek
2011-01-12 17:31 ` Marcel Holtmann
2011-01-12 17:42 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2011-01-12 17:50 ` Tomasz Gregorek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1294839942-9071-1-git-send-email-tomasz.gregorek@gmail.com \
--to=tomasz.gregorek@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.