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>bb10
parent
385e584926
commit
fb6d83cca5
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue