From b8cd5ae838b1a17ce1bb6f01e6491c7b887e8474 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 1 Oct 2014 12:02:36 +0200 Subject: [PATCH] device: Keep track of devices as they are move across sysfs For certain devices the name changes with their status. Notably, RFCOMM devices move from /devices/virtual/ to underneath the HCI that is used for the connection as the session is estabilished, and return back when it's torn down. --- src/mm-device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mm-device.c b/src/mm-device.c index 3e2e46f6..9c2a6e25 100644 --- a/src/mm-device.c +++ b/src/mm-device.c @@ -96,6 +96,11 @@ device_find_probe_with_device (MMDevice *self, for (l = self->priv->port_probes; l; l = g_list_next (l)) { MMPortProbe *probe = MM_PORT_PROBE (l->data); + if ( g_udev_device_has_property (udev_port, "DEVPATH_OLD") + && g_str_has_suffix (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)), + g_udev_device_get_property (udev_port, "DEVPATH_OLD"))) + return probe; + if (g_str_equal (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)), g_udev_device_get_sysfs_path (udev_port))) return probe; @@ -107,6 +112,11 @@ device_find_probe_with_device (MMDevice *self, for (l = self->priv->ignored_port_probes; l; l = g_list_next (l)) { MMPortProbe *probe = MM_PORT_PROBE (l->data); + if ( g_udev_device_has_property (udev_port, "DEVPATH_OLD") + && g_str_has_suffix (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)), + g_udev_device_get_property (udev_port, "DEVPATH_OLD"))) + return probe; + if (g_str_equal (g_udev_device_get_sysfs_path (mm_port_probe_peek_port (probe)), g_udev_device_get_sysfs_path (udev_port))) return probe;