aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-plugin-simtech.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-02-01 01:43:54 -0600
committerDan Williams <dcbw@redhat.com>2012-02-28 10:06:04 -0600
commit4dad94d5004f325e25dc3b09d87585eab38d4c3f (patch)
tree38a5bb148952c333e18bfbd959e27573ab3364d9 /plugins/mm-plugin-simtech.c
parent36ee1b9c76a681b44516852372944b82c7616892 (diff)
core: rework port grabbing and organization
Make port roles more flexible. We have modems that do PPP on interfaces other than the primary interface, and that wasn't possible with the old code. So clean up all that logic and move the port organization code into the core so we can reduce code in the plugins. In the new world order, the plugins say whether the port is a QCDM port, an AT port, or ignored. If it's an AT port the plugins get to tag it as primary, secondary, or PPP, or any combination of the 3. This allows for modems where PPP should really be done on the secondary port (Huawei E220, Sierra devices) so that the primary port stays open for command and status. Modem subclasses no longer get asked to handle port grabbing themselves. Instead, that's now done by the generic classes (MMGenericCdma and MMGenericGsm) and the plugins are notified when a port is grabbed so they can add unsolicited response handlers for it. After all ports are grabbed by the generic classes, they get "organized", which assigns various ports to the roles of PRIMARY, SECONDARY, DATA, and QCDM based on specific rules and hints that the plugin provided (which are expressed as MMAtPortFlags). The plugins then have a chance to perform fixups on the primary port if they choose. The plugin code is responsible for determining the port hints (ie MMAtPortFlags) at probe time, instead of having a combination of the plugin and the modem class do the job. This simplifies things greatly for the plugins at the expense of more complicated logic in the core.
Diffstat (limited to 'plugins/mm-plugin-simtech.c')
-rw-r--r--plugins/mm-plugin-simtech.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/plugins/mm-plugin-simtech.c b/plugins/mm-plugin-simtech.c
index 76ab33d2..1eb28229 100644
--- a/plugins/mm-plugin-simtech.c
+++ b/plugins/mm-plugin-simtech.c
@@ -116,8 +116,9 @@ grab_port (MMPluginBase *base,
MMModem *modem = NULL;
const char *name, *subsys, *sysfs_path;
guint32 caps;
- MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
+ MMPortType ptype;
guint16 vendor = 0, product = 0;
+ MMAtPortFlags pflags = MM_AT_PORT_FLAG_NONE;
port = mm_plugin_base_supports_task_get_port (task);
g_assert (port);
@@ -127,15 +128,18 @@ grab_port (MMPluginBase *base,
* what the Windows .INF files say the port layout should be.
*/
if (g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_MODEM"))
- ptype = MM_PORT_TYPE_PRIMARY;
+ pflags = MM_AT_PORT_FLAG_PRIMARY;
else if (g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_PORT_TYPE_AUX"))
- ptype = MM_PORT_TYPE_SECONDARY;
+ pflags = MM_AT_PORT_FLAG_SECONDARY;
- /* If the device was tagged by the udev rules, then ignore any other ports
- * to guard against race conditions if a device just happens to show up
- * with more than two AT-capable ports.
+ caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
+ ptype = mm_plugin_base_probed_capabilities_to_port_type (caps);
+
+ /* If the port was tagged by the udev rules but isn't a primary or secondary,
+ * then ignore it to guard against race conditions if a device just happens
+ * to show up with more than two AT-capable ports.
*/
- if ( (ptype == MM_PORT_TYPE_UNKNOWN)
+ if ( (pflags == MM_AT_PORT_FLAG_NONE)
&& g_udev_device_get_property_as_boolean (port, "ID_MM_SIMTECH_TAGGED"))
ptype = MM_PORT_TYPE_IGNORED;
@@ -147,7 +151,6 @@ grab_port (MMPluginBase *base,
return NULL;
}
- caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
@@ -167,17 +170,14 @@ grab_port (MMPluginBase *base,
}
if (modem) {
- if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error)) {
+ if (!mm_modem_grab_port (modem, subsys, name, ptype, pflags, NULL, error)) {
g_object_unref (modem);
return NULL;
}
}
} else if (get_level_for_capabilities (caps)) {
- if (caps & MM_PLUGIN_BASE_PORT_CAP_QCDM)
- ptype = MM_PORT_TYPE_QCDM;
-
modem = existing;
- if (!mm_modem_grab_port (modem, subsys, name, ptype, NULL, error))
+ if (!mm_modem_grab_port (modem, subsys, name, ptype, pflags, NULL, error))
return NULL;
}