diff options
author | Dan Williams <dcbw@redhat.com> | 2009-07-02 13:48:30 -0400 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-07-02 13:48:30 -0400 |
commit | 52da9990eef279bbc349685a7558d26cf4b7893b (patch) | |
tree | f84433872729aafef296eebae46ace57eb9c8d82 /src/mm-generic-cdma.c | |
parent | 4e7548e496d580f26a763bcdaeca7e7af75d5141 (diff) |
plugins: allow plugins to more easily suggest port types
ZTE modems need to use udev rules to assign port type hints,
so generalize that and port all the plugins over to suggested
port types in the MMModem interface's grab_port() function.
Diffstat (limited to 'src/mm-generic-cdma.c')
-rw-r--r-- | src/mm-generic-cdma.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/mm-generic-cdma.c b/src/mm-generic-cdma.c index 7d731384..5d58a81f 100644 --- a/src/mm-generic-cdma.c +++ b/src/mm-generic-cdma.c @@ -85,6 +85,7 @@ static gboolean grab_port (MMModem *modem, const char *subsys, const char *name, + MMPortType suggested_type, gpointer user_data, GError **error) { @@ -94,24 +95,28 @@ grab_port (MMModem *modem, MMPort *port; g_return_val_if_fail (!strcmp (subsys, "net") || !strcmp (subsys, "tty"), FALSE); + if (priv->primary) + g_return_val_if_fail (suggested_type != MM_PORT_TYPE_PRIMARY, FALSE); if (!strcmp (subsys, "tty")) { - if (!priv->primary) - ptype = MM_PORT_TYPE_PRIMARY; - else if (!priv->secondary) - ptype = MM_PORT_TYPE_SECONDARY; + if (suggested_type != MM_PORT_TYPE_UNKNOWN) + ptype = suggested_type; + else { + if (!priv->primary) + ptype = MM_PORT_TYPE_PRIMARY; + else if (!priv->secondary) + ptype = MM_PORT_TYPE_SECONDARY; + } } port = mm_modem_base_add_port (MM_MODEM_BASE (self), subsys, name, ptype); - if (MM_IS_SERIAL_PORT (port)) { + if (port && MM_IS_SERIAL_PORT (port)) { g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL); mm_serial_port_set_response_parser (MM_SERIAL_PORT (port), mm_serial_parser_v1_parse, mm_serial_parser_v1_new (), mm_serial_parser_v1_destroy); - } - if (MM_IS_SERIAL_PORT (port)) { if (ptype == MM_PORT_TYPE_PRIMARY) { priv->primary = MM_SERIAL_PORT (port); if (!priv->data) { |