diff options
author | Johannes Zellner <johannes.zellner@nokia.com> | 2012-05-15 12:43:08 -0700 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-15 23:03:23 +0200 |
commit | fb6d83cca59930345231161c1d6bfdf79fe25807 (patch) | |
tree | 782776c8985943f9180c364705c4920ed3b5b49c | |
parent | 385e584926f2957d6e9ec4c2c4e89b37a5e0c80c (diff) |
udev: improve device discovery with udev for add/remove
As the udev device tree structure varies between distros and udev
versions, first probe the actual leaf node for device properties.
If leaf does not contain needed properties, walk up the tree to the
next node matching the queried submodule.
Change-Id: I09329d5a76a1a2a797513f4a787cb27fed5293c7
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
-rw-r--r-- | src/platformsupport/udev/qudevicehelper.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/platformsupport/udev/qudevicehelper.cpp b/src/platformsupport/udev/qudevicehelper.cpp index 688cedd304..0cf370badc 100644 --- a/src/platformsupport/udev/qudevicehelper.cpp +++ b/src/platformsupport/udev/qudevicehelper.cpp @@ -192,13 +192,18 @@ void QUDeviceHelper::handleUDevNotification() subsystem = "drm"; else goto cleanup; - // does not increase the refcount - dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0); - if (!dev) - goto cleanup; - types = checkDeviceType(dev); + // if we cannot determine a type, walk up the device tree + if (types == UDev_Unknown) { + // does not increase the refcount + dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0); + if (!dev) + goto cleanup; + + types = checkDeviceType(dev); + } + if (types && (qstrcmp(action, "add") == 0)) emit deviceDetected(devNode, types); |