diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-06-22 17:41:04 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-06-23 18:12:27 +0200 |
commit | b520503686ced256146335d6e51bab5c150188d1 (patch) | |
tree | 2dac77b73bd7690f9d87c38e842d38c0bd25f601 | |
parent | 7c347aa3ec1d5540c23c20dcb5edd3c6ccb28c24 (diff) | |
download | ModemManager-b520503686ced256146335d6e51bab5c150188d1.tar.gz |
huawei: quicker find matching cdc-wdm AT port
Without using a new GUdevClient.
Based on a patch from Dan Williams <dcbw@redhat.com>
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 83 |
1 files changed, 15 insertions, 68 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index 3d41213f3..46d15a5f6 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -2129,84 +2129,31 @@ static MMPortSerialAt * peek_port_at_for_data (MMBroadbandModemHuawei *self, MMPort *port) { - GUdevClient *client; - GUdevDevice *data_device; - GUdevDevice *data_device_parent = NULL; - GList *cdc_wdm_at_ports = NULL; - GList *l; - MMPortSerialAt *found = NULL; + GList *cdc_wdm_at_ports, *l; + const gchar *net_port_parent_path; - client = g_udev_client_new (NULL); - data_device = (g_udev_client_query_by_subsystem_and_name ( - client, - "net", - mm_port_get_device (port))); + g_warn_if_fail (mm_port_get_subsys (port) == MM_PORT_SUBSYS_NET); + net_port_parent_path = mm_port_get_parent_path (port); + if (!net_port_parent_path) { + g_warning ("(%s) no parent path for net port", mm_port_get_device (port)); + return NULL; + } + /* Find the CDC-WDM port on the same USB interface as the given net port */ cdc_wdm_at_ports = mm_base_modem_find_ports (MM_BASE_MODEM (self), MM_PORT_SUBSYS_USB, MM_PORT_TYPE_AT, NULL); - - /* Get parent of the data device */ - data_device_parent = g_udev_device_get_parent (data_device); - if (!data_device_parent) { - mm_dbg ("Cannot get parent device (%s)", mm_port_get_device (port)); - goto out; - } - - /* Now walk the list of cdc-wdm AT ports looking for a match */ - for (l = cdc_wdm_at_ports; l && !found; l = g_list_next (l)) { - GUdevDevice *cdc_wdm_device; - GUdevDevice *cdc_wdm_device_parent; + for (l = cdc_wdm_at_ports; l; l = g_list_next (l)) { + const gchar *wdm_port_parent_path; g_assert (MM_IS_PORT_SERIAL_AT (l->data)); - - /* Get udev device for the cdc-wdm port */ - cdc_wdm_device = (g_udev_client_query_by_subsystem_and_name ( - client, - "usb", - mm_port_get_device (MM_PORT (l->data)))); - if (!cdc_wdm_device) { - cdc_wdm_device = (g_udev_client_query_by_subsystem_and_name ( - client, - "usbmisc", - mm_port_get_device (MM_PORT (l->data)))); - if (!cdc_wdm_device) { - mm_warn ("Couldn't get udev device for cdc-wdm port '%s'", - mm_port_get_device (MM_PORT (l->data))); - continue; - } - } - - /* Get parent of the cdc-wdm device */ - cdc_wdm_device_parent = g_udev_device_get_parent (cdc_wdm_device); - g_object_unref (cdc_wdm_device); - - if (!cdc_wdm_device_parent) { - mm_warn ("Couldn't get udev device parent for cdc-wdm port '%s'", - mm_port_get_device (MM_PORT (l->data))); - continue; - } - - if (g_str_equal (g_udev_device_get_sysfs_path (data_device_parent), - g_udev_device_get_sysfs_path (cdc_wdm_device_parent))) - found = MM_PORT_SERIAL_AT (l->data); - - g_object_unref (cdc_wdm_device_parent); + wdm_port_parent_path = mm_port_get_parent_path (MM_PORT (l->data)); + if (wdm_port_parent_path && g_str_equal (wdm_port_parent_path, net_port_parent_path)) + return MM_PORT_SERIAL_AT (l->data); } -out: - - if (data_device_parent) - g_object_unref (data_device_parent); - if (data_device) - g_object_unref (data_device); - if (client) - g_object_unref (client); - if (cdc_wdm_at_ports) - g_list_free_full (cdc_wdm_at_ports, (GDestroyNotify)g_object_unref); - - return found; + return NULL; } |