diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-01-03 11:10:10 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-01-03 15:12:17 +0100 |
commit | 883012d49b0635ab20898a649fcce6db21288571 (patch) | |
tree | 46546f0e29b8340583ba1f446717cc645084abe4 /udev/lib/libudev-device.c | |
parent | b92511747af31bcfc880b33505c61ef6c96c6dac (diff) |
libudev: device - lookup subsystem and devtype together
Diffstat (limited to 'udev/lib/libudev-device.c')
-rw-r--r-- | udev/lib/libudev-device.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index a25716d95d..7c803594e4 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -557,17 +557,26 @@ struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *ud return parent; } -struct udev_device *udev_device_get_parent_with_devtype(struct udev_device *udev_device, const char *devtype) +struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype) { struct udev_device *parent; + if (subsystem == NULL) + return NULL; + parent = udev_device_get_parent(udev_device); while (parent != NULL) { + const char *parent_subsystem; const char *parent_devtype; - parent_devtype = udev_device_get_devtype(parent); - if (parent_devtype != NULL && strcmp(parent_devtype, devtype) == 0) - break; + parent_subsystem = udev_device_get_subsystem(parent); + if (parent_subsystem != NULL && strcmp(parent_subsystem, subsystem) == 0) { + if (devtype == NULL) + break; + parent_devtype = udev_device_get_devtype(parent); + if (parent_devtype != NULL && strcmp(parent_devtype, devtype) == 0) + break; + } parent = udev_device_get_parent(parent); } return parent; |