plugin-base: fix finding the physical device again
Don't mis-use udev's ID_BUS key.
This commit is contained in:
@@ -680,48 +680,37 @@ get_driver_name (GUdevDevice *device)
|
|||||||
static GUdevDevice *
|
static GUdevDevice *
|
||||||
real_find_physical_device (MMPluginBase *plugin, GUdevDevice *child)
|
real_find_physical_device (MMPluginBase *plugin, GUdevDevice *child)
|
||||||
{
|
{
|
||||||
GUdevDevice *parent = NULL, *physdev = NULL;
|
GUdevDevice *iter, *old = NULL;
|
||||||
|
GUdevDevice *physdev = NULL;
|
||||||
const char *subsys, *type;
|
const char *subsys, *type;
|
||||||
|
guint32 i = 0;
|
||||||
|
gboolean is_usb = FALSE, is_pci = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (child != NULL, NULL);
|
g_return_val_if_fail (child != NULL, NULL);
|
||||||
|
|
||||||
subsys = g_udev_device_get_subsystem (child);
|
iter = g_object_ref (child);
|
||||||
g_assert (subsys);
|
while (iter && i++ < 5) {
|
||||||
if (strcmp (subsys, "usb") && strcmp (subsys, "pci")) {
|
subsys = g_udev_device_get_subsystem (iter);
|
||||||
/* Try the parent */
|
if (subsys) {
|
||||||
parent = g_udev_device_get_parent (child);
|
if (is_usb || !strcmp (subsys, "usb")) {
|
||||||
if (!parent)
|
is_usb = TRUE;
|
||||||
goto out;
|
type = g_udev_device_get_devtype (iter);
|
||||||
|
if (type && !strcmp (type, "usb_device")) {
|
||||||
subsys = g_udev_device_get_subsystem (parent);
|
physdev = iter;
|
||||||
if (strcmp (subsys, "usb") && strcmp (subsys, "pci"))
|
break;
|
||||||
goto out;
|
}
|
||||||
}
|
} else if (is_pci || !strcmp (subsys, "pci")) {
|
||||||
|
is_pci = TRUE;
|
||||||
if (!strcmp (subsys, "usb")) {
|
|
||||||
GUdevDevice *iter, *old = NULL;
|
|
||||||
|
|
||||||
/* Walk the parents to find the 'usb_device' for this device. */
|
|
||||||
iter = g_object_ref (child);
|
|
||||||
while (iter) {
|
|
||||||
type = g_udev_device_get_devtype (iter);
|
|
||||||
if (type && !strcmp (type, "usb_device")) {
|
|
||||||
physdev = iter;
|
physdev = iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
old = iter;
|
|
||||||
iter = g_udev_device_get_parent (old);
|
|
||||||
g_object_unref (old);
|
|
||||||
}
|
}
|
||||||
} else if (!strcmp (subsys, "pci"))
|
|
||||||
physdev = g_udev_device_get_parent (child);
|
|
||||||
|
|
||||||
// FIXME: pcmcia (like Sierra 850/860)
|
old = iter;
|
||||||
|
iter = g_udev_device_get_parent (old);
|
||||||
|
g_object_unref (old);
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
if (parent)
|
|
||||||
g_object_unref (parent);
|
|
||||||
return physdev;
|
return physdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -102,6 +102,10 @@ struct _MMPluginBaseClass {
|
|||||||
void (*cancel_task) (MMPluginBase *plugin,
|
void (*cancel_task) (MMPluginBase *plugin,
|
||||||
MMPluginBaseSupportsTask *task);
|
MMPluginBaseSupportsTask *task);
|
||||||
|
|
||||||
|
/* Find a the physical device of a port, ie the USB or PCI or whatever
|
||||||
|
* "master" device that owns the port. The GUdevDevice object returned
|
||||||
|
* will be unref-ed by the caller.
|
||||||
|
*/
|
||||||
GUdevDevice * (*find_physical_device) (MMPluginBase *plugin,
|
GUdevDevice * (*find_physical_device) (MMPluginBase *plugin,
|
||||||
GUdevDevice *port);
|
GUdevDevice *port);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user