diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-07 11:53:13 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-24 20:47:57 +0100 |
commit | 1b35d74c157417e40877535eec757e5cd725564f (patch) | |
tree | e9e26fb80e9d7f3141d017dd84b6e41a7a4783f5 /plugins/huawei/mm-plugin-huawei.c | |
parent | cc07d21410d707a3e3cf16c3fa187562dcdea58b (diff) |
kernel-device: add get_interface_number() method
We already have methods to query for interface specific attributes
like class/subclass/protocol, so add a new one for the interface
number, and make sure we use ATTRS{bInterfaceNumber} to load it
always, instead of assuming the ID_USB_INTERFACE_NUM property is set.
Diffstat (limited to 'plugins/huawei/mm-plugin-huawei.c')
-rw-r--r-- | plugins/huawei/mm-plugin-huawei.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c index 4c5c39ed..07652ec7 100644 --- a/plugins/huawei/mm-plugin-huawei.c +++ b/plugins/huawei/mm-plugin-huawei.c @@ -56,7 +56,7 @@ MM_PLUGIN_DEFINE_MINOR_VERSION typedef struct { MMPortProbe *probe; - guint first_usbif; + gint first_usbif; guint timeout_id; gboolean custom_init_run; } FirstInterfaceContext; @@ -177,23 +177,23 @@ try_next_usbif (MMPortProbe *probe, MMDevice *device) { FirstInterfaceContext *fi_ctx; - GList *l; - guint closest; + GList *l; + gint closest; fi_ctx = g_object_get_data (G_OBJECT (device), TAG_FIRST_INTERFACE_CONTEXT); g_assert (fi_ctx != NULL); /* Look for the next closest one among the list of interfaces in the device, * and enable that one as being first */ - closest = G_MAXUINT; + closest = G_MAXINT; for (l = mm_device_peek_port_probe_list (device); l; l = g_list_next (l)) { MMPortProbe *iter = MM_PORT_PROBE (l->data); /* Only expect ttys for next probing attempt */ if (g_str_equal (mm_port_probe_get_port_subsys (iter), "tty")) { - guint usbif; + gint usbif; - usbif = mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (iter), "ID_USB_INTERFACE_NUM"); + usbif = mm_kernel_device_get_interface_number (mm_port_probe_peek_port (iter)); if (usbif == fi_ctx->first_usbif) { /* This is the one we just probed, which wasn't yet removed, so just skip it */ } else if (usbif > fi_ctx->first_usbif && @@ -203,7 +203,7 @@ try_next_usbif (MMPortProbe *probe, } } - if (closest == G_MAXUINT) { + if (closest == G_MAXINT) { /* No more ttys to try! Just return something */ closest = 0; mm_obj_dbg (probe, "no more ports to run initial probing"); @@ -359,9 +359,7 @@ huawei_custom_init (MMPortProbe *probe, g_task_set_task_data (task, ctx, (GDestroyNotify)huawei_custom_init_context_free); /* Custom init only to be run in the first interface */ - if (mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (probe), - "ID_USB_INTERFACE_NUM") != fi_ctx->first_usbif) { - + if (mm_kernel_device_get_interface_number (mm_port_probe_peek_port (probe)) != fi_ctx->first_usbif) { if (fi_ctx->custom_init_run) /* If custom init was run already, we can consider this as successfully run */ g_task_return_boolean (task, TRUE); @@ -391,8 +389,8 @@ static gint probe_cmp_by_usbif (MMPortProbe *a, MMPortProbe *b) { - return ((gint) mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (a), "ID_USB_INTERFACE_NUM") - - (gint) mm_kernel_device_get_property_as_int_hex (mm_port_probe_peek_port (b), "ID_USB_INTERFACE_NUM")); + return (mm_kernel_device_get_interface_number (mm_port_probe_peek_port (a)) - + mm_kernel_device_get_interface_number (mm_port_probe_peek_port (b))); } static guint |