From e2c32e1967608ad0befdfcf7393b68cb4f9be5c3 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 12 Jul 2009 20:24:04 -0700 Subject: [PATCH] Fix MBM detection code to find first control interface --- src/udev.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/udev.c b/src/udev.c index 0900f39..4decd7d 100644 --- a/src/udev.c +++ b/src/udev.c @@ -309,6 +309,7 @@ char *__connman_udev_get_mbm_devnode(const char *ifname) struct udev_device *device, *parent, *control; const char *driver, *devpath1, *devpath2; char *devnode = NULL; + unsigned int i; device = udev_device_new_from_subsystem_sysname(udev_ctx, "net", ifname); @@ -330,20 +331,28 @@ char *__connman_udev_get_mbm_devnode(const char *ifname) devpath1 = udev_device_get_devpath(parent); - control = udev_device_new_from_subsystem_sysname(udev_ctx, - "usb", "cdc-wdm0"); - if (control == NULL) - goto done; + for (i = 0; i < 64; i++) { + char sysname[16]; + + snprintf(sysname, sizeof(sysname) - 1, "ttyACM%d", i); + + control = udev_device_new_from_subsystem_sysname(udev_ctx, + "tty", sysname); + if (control == NULL) + continue; - parent = udev_device_get_parent_with_subsystem_devtype(control, + parent = udev_device_get_parent_with_subsystem_devtype(control, "usb", "usb_device"); - if (parent == NULL) - goto done; + if (parent == NULL) + continue; - devpath2 = udev_device_get_devpath(parent); + devpath2 = udev_device_get_devpath(parent); - if (g_strcmp0(devpath1, devpath2) == 0) - devnode = g_strdup(udev_device_get_devnode(control)); + if (g_strcmp0(devpath1, devpath2) == 0) { + devnode = g_strdup(udev_device_get_devnode(control)); + break; + } + } done: udev_device_unref(device); -- 2.7.4