]> err.no Git - systemd/commitdiff
libudev: device - lookup subsystem and devtype together
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 3 Jan 2009 10:10:10 +0000 (11:10 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 3 Jan 2009 14:12:17 +0000 (15:12 +0100)
udev/lib/exported_symbols
udev/lib/libudev-device.c
udev/lib/libudev.h

index 6b07842a8145d7d7c4d67699381537739baf476c..88d5c48c10c646bb128ec836fcb995aecd0887bb 100644 (file)
@@ -17,7 +17,7 @@ udev_device_new_from_devnum
 udev_device_new_from_subsystem_sysname
 udev_device_get_parent
 udev_device_get_parent_with_subsystem
-udev_device_get_parent_with_devtype
+udev_device_get_parent_with_subsystem_devtype
 udev_device_ref
 udev_device_unref
 udev_device_get_udev
index a25716d95d58d323dbf2bbf182dc93261f4993cc..7c803594e4b2000760f71b5be3a7690ae71b3651 100644 (file)
@@ -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;
index b96e49429b9d71a48930fe65e841c49ac05ba2a2..bac362a360ac15c9af7ebb08bf1ee8663adef013 100644 (file)
@@ -63,7 +63,7 @@ extern struct udev_device *udev_device_new_from_devnum(struct udev *udev, char t
 extern struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);
 extern struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
 extern struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *udev_device, const char *subsystem);
-extern struct udev_device *udev_device_get_parent_with_devtype(struct udev_device *udev_device, const char *devtype);
+extern struct udev_device *udev_device_get_parent_with_subsytem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype);
 extern struct udev_device *udev_device_ref(struct udev_device *udev_device);
 extern void udev_device_unref(struct udev_device *udev_device);
 extern struct udev *udev_device_get_udev(struct udev_device *udev_device);