aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-03-28 09:12:17 -0700
committerDan Williams <dcbw@redhat.com>2010-03-28 09:12:17 -0700
commitfe69ab4210bfacda97257b6a08e85f6ce433f7d0 (patch)
treedc02ca8e4d195a9d79390ee0b87bb52285b28646
parentb876182fe60401eae86267f8cf1c6726a7a0eddc (diff)
huawei: ensure modem ports get claimed even if probe fails
Previously there was an issue where if the probe failed, because we can't really probe huawei secondary ports for various reasons, the Generic plugin would eventually come around and try actively probing the secondary port after the Huawei plugin said "I don't support this port". Which resulted (potentially) in two MMModem objects for the same device (one driven by Huawei, the other by Generic).
-rw-r--r--plugins/mm-plugin-huawei.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/mm-plugin-huawei.c b/plugins/mm-plugin-huawei.c
index 857ae6af..ab17139b 100644
--- a/plugins/mm-plugin-huawei.c
+++ b/plugins/mm-plugin-huawei.c
@@ -74,7 +74,12 @@ probe_result (MMPluginBase *base,
typedef struct {
MMAtSerialPort *serial;
guint id;
- gboolean secondary;
+ MMPortType ptype;
+ /* Whether or not there's already a detected modem that "owns" this port,
+ * in which case we'll claim it, but if no capabilities are detected it'll
+ * just be ignored.
+ */
+ gboolean parent_modem;
} HuaweiSupportsInfo;
static void
@@ -103,7 +108,7 @@ probe_secondary_supported (gpointer user_data)
info->serial = NULL;
/* Yay, supported, we got an unsolicited message */
- info->secondary = TRUE;
+ info->ptype = MM_PORT_TYPE_SECONDARY;
mm_plugin_base_supports_task_complete (task, 10);
return FALSE;
}
@@ -126,14 +131,20 @@ probe_secondary_timeout (gpointer user_data)
{
MMPluginBaseSupportsTask *task = user_data;
HuaweiSupportsInfo *info;
+ guint level = 0;
info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO);
info->id = 0;
g_object_unref (info->serial);
info->serial = NULL;
- /* Not supported by this plugin */
- mm_plugin_base_supports_task_complete (task, 0);
+ /* Supported, but ignored if this port's parent device is already a modem */
+ if (info->parent_modem) {
+ info->ptype = MM_PORT_TYPE_IGNORED;
+ level = 10;
+ }
+
+ mm_plugin_base_supports_task_complete (task, level);
return FALSE;
}
@@ -210,6 +221,7 @@ supports_port (MMPluginBase *base,
/* Listen for Huawei-specific unsolicited messages */
info = g_malloc0 (sizeof (HuaweiSupportsInfo));
+ info->parent_modem = !!existing;
info->serial = mm_at_serial_port_new (name, MM_PORT_TYPE_PRIMARY);
g_object_set (G_OBJECT (info->serial), MM_PORT_CARRIER_DETECT, FALSE, NULL);
@@ -308,8 +320,8 @@ grab_port (MMPluginBase *base,
MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO);
- if (info && info->secondary)
- ptype = MM_PORT_TYPE_SECONDARY;
+ if (info)
+ ptype = info->ptype;
else if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
ptype = MM_PORT_TYPE_QCDM;