aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-modem-huawei-gsm.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-06-16 17:12:41 +0200
committerGuido Günther <agx@sigxcpu.org>2014-02-05 08:38:26 +0100
commit59ed3390b9a798ff8bf9133cbc28c4539ad99f42 (patch)
tree2009d57abbd0061b4ee230516e004eb83509aac5 /plugins/mm-modem-huawei-gsm.c
parentbbf8a053e07c66f336ed46a7fb6105dc30645596 (diff)
parent3dbe8df8bfe8741e1b9a48b56e41517816f17dc1 (diff)
Imported Debian patch 0.4.997-1debian/0.4.997-1
Diffstat (limited to 'plugins/mm-modem-huawei-gsm.c')
-rw-r--r--plugins/mm-modem-huawei-gsm.c88
1 files changed, 68 insertions, 20 deletions
diff --git a/plugins/mm-modem-huawei-gsm.c b/plugins/mm-modem-huawei-gsm.c
index df58d53..e038069 100644
--- a/plugins/mm-modem-huawei-gsm.c
+++ b/plugins/mm-modem-huawei-gsm.c
@@ -171,6 +171,11 @@ set_allowed_mode_done (MMAtSerialPort *port,
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
if (error)
info->error = g_error_copy (error);
@@ -232,11 +237,18 @@ get_allowed_mode_done (MMAtSerialPort *port,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem);
+ MMModemHuaweiGsm *self;
int mode_a, mode_b, u1, u2;
guint32 band;
MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
+ self = MM_MODEM_HUAWEI_GSM (info->modem);
+
if (error)
info->error = g_error_copy (error);
else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2, &mode))
@@ -271,8 +283,16 @@ set_band_done (MMAtSerialPort *port,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem);
- MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self);
+ MMModemHuaweiGsm *self;
+ MMModemHuaweiGsmPrivate *priv;
+
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
+ self = MM_MODEM_HUAWEI_GSM (info->modem);
+ priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self);
if (error)
info->error = g_error_copy (error);
@@ -321,10 +341,17 @@ get_band_done (MMAtSerialPort *port,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem);
+ MMModemHuaweiGsm *self;
int mode_a, mode_b, u1, u2;
guint32 band;
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
+ self = MM_MODEM_HUAWEI_GSM (info->modem);
+
if (error)
info->error = g_error_copy (error);
else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2, NULL)) {
@@ -410,6 +437,11 @@ get_act_request_done (MMAtSerialPort *port,
char *str;
int srv_stat = 0;
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
if (error) {
info->error = g_error_copy (error);
goto done;
@@ -504,6 +536,11 @@ send_huawei_cpin_done (MMAtSerialPort *port,
char *str = NULL;
guint32 num = 0;
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
if (error) {
info->error = g_error_copy (error);
goto done;
@@ -710,12 +747,6 @@ do_enable_power_up_done (MMGenericGsm *gsm,
/*****************************************************************************/
-typedef struct {
- MMModem *modem;
- MMModemFn callback;
- gpointer user_data;
-} DisableInfo;
-
static void
disable_unsolicited_done (MMAtSerialPort *port,
GString *response,
@@ -723,12 +754,29 @@ disable_unsolicited_done (MMAtSerialPort *port,
gpointer user_data)
{
- MMModem *parent_modem_iface;
- DisableInfo *info = user_data;
+ MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+
+ /* If the modem has already been removed, return without
+ * scheduling callback */
+ if (mm_callback_info_check_modem_removed (info))
+ return;
+
+ /* Ignore all errors */
+ mm_callback_info_schedule (info);
+}
+
+static void
+invoke_call_parent_disable_fn (MMCallbackInfo *info)
+{
+ /* Note: we won't call the parent disable if info->modem is no longer
+ * valid. The invoke is called always once the info gets scheduled, which
+ * may happen during removed modem detection. */
+ if (info->modem) {
+ MMModem *parent_modem_iface;
- parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
- parent_modem_iface->disable (info->modem, info->callback, info->user_data);
- g_free (info);
+ parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
+ parent_modem_iface->disable (info->modem, (MMModemFn)info->callback, info->user_data);
+ }
}
static void
@@ -737,12 +785,12 @@ disable (MMModem *modem,
gpointer user_data)
{
MMAtSerialPort *primary;
- DisableInfo *info;
+ MMCallbackInfo *info;
- info = g_malloc0 (sizeof (DisableInfo));
- info->callback = callback;
- info->user_data = user_data;
- info->modem = modem;
+ info = mm_callback_info_new_full (modem,
+ invoke_call_parent_disable_fn,
+ (GCallback)callback,
+ user_data);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);