From fb6d83cca59930345231161c1d6bfdf79fe25807 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 15 May 2012 12:43:08 -0700 Subject: 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 --- src/platformsupport/udev/qudevicehelper.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') 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); -- cgit v1.2.3