aboutsummaryrefslogtreecommitdiff
path: root/plugins/mm-plugin-option.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-option.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-option.c')
-rw-r--r--plugins/mm-plugin-option.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/plugins/mm-plugin-option.c b/plugins/mm-plugin-option.c
index 8c16879a..0f90a4e7 100644
--- a/plugins/mm-plugin-option.c
+++ b/plugins/mm-plugin-option.c
@@ -110,7 +110,8 @@ grab_port (MMPluginBase *base,
const char *name, *subsys, *devfile, *sysfs_path;
guint32 caps;
int usbif;
- MMPortType ptype = MM_PORT_TYPE_SECONDARY;
+ MMPortType ptype;
+ MMAtPortFlags pflags = MM_AT_PORT_FLAG_NONE;
guint16 vendor = 0, product = 0;
port = mm_plugin_base_supports_task_get_port (task);
@@ -122,9 +123,6 @@ grab_port (MMPluginBase *base,
return NULL;
}
- subsys = g_udev_device_get_subsystem (port);
- name = g_udev_device_get_name (port);
-
/* This is the MM equivalent of NM commit 9d7f5b3d084eee2ccfff721c4beca3e3f34bdc50;
* Genuine Option NV devices are always supposed to use USB interface 0 as
* the modem/data port, per mail with Option engineers. Only this port
@@ -132,8 +130,10 @@ grab_port (MMPluginBase *base,
*/
usbif = g_udev_device_get_property_as_int (port, "ID_USB_INTERFACE_NUM");
if (usbif == 0)
- ptype = MM_PORT_TYPE_PRIMARY;
+ pflags = MM_AT_PORT_FLAG_PRIMARY | MM_AT_PORT_FLAG_PPP;
+ subsys = g_udev_device_get_subsystem (port);
+ name = g_udev_device_get_name (port);
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
g_set_error (error, 0, 0, "Could not get modem product ID.");
return NULL;
@@ -141,6 +141,7 @@ grab_port (MMPluginBase *base,
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
+ ptype = mm_plugin_base_probed_capabilities_to_port_type (caps);
if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
modem = mm_modem_option_new (sysfs_path,
@@ -151,17 +152,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;
}