chiark / gitweb /
libudev: device - add get_parent_with_subsystem()
[elogind.git] / udev / lib / libudev-device.c
index a512537140b19ff76ab46d55518ab4a2d5077f0f..8e4360a7f4c50a5d96f3d83646ce1251a75a9c6d 100644 (file)
@@ -404,6 +404,22 @@ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)
        return udev_device->parent_device;
 }
 
+struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *udev_device, const char *subsystem)
+{
+       struct udev_device *parent;
+
+       parent = udev_device_get_parent(udev_device);
+       while (parent != NULL) {
+               const char *parent_subsystem;
+
+               parent_subsystem = udev_device_get_subsystem(parent);
+               if (parent_subsystem != NULL && strcmp(parent_subsystem, subsystem) == 0)
+                       break;
+               parent = udev_device_get_parent(parent);
+       }
+       return parent;
+}
+
 /**
  * udev_device_get_udev:
  * @udev_device: udev device