X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_sysfs.c;h=8de523dadf66abc3bbf0198c9dac01036ca7f608;hb=36af2ddcb92c51acad0f909bb5dfb090cea9c5ed;hp=983837980338e8de0a219b991063689188f08413;hpb=ea48d4d7fb856184b5caadf5436a48afe5ad113c;p=elogind.git diff --git a/udev_sysfs.c b/udev_sysfs.c index 983837980..8de523dad 100644 --- a/udev_sysfs.c +++ b/udev_sysfs.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "udev.h" @@ -274,7 +275,7 @@ struct sysfs_device *sysfs_device_get_parent(struct sysfs_device *dev) if (strncmp(parent_devpath, "/class", 6) == 0) { pos = strrchr(parent_devpath, '/'); if (pos == &parent_devpath[6] || pos == parent_devpath) { - dbg("class top level, look for device link"); + dbg("/class top level, look for device link"); goto device_link; } } @@ -306,6 +307,19 @@ device_link: return sysfs_device_get(parent_devpath); } +struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct sysfs_device *dev, const char *subsystem) +{ + struct sysfs_device *dev_parent; + + dev_parent = sysfs_device_get_parent(dev); + while (dev_parent != NULL) { + if (strcmp(dev_parent->subsystem, subsystem) == 0) + return dev_parent; + dev_parent = sysfs_device_get_parent(dev_parent); + } + return NULL; +} + char *sysfs_attr_get_value(const char *devpath, const char *attr_name) { char path_full[PATH_SIZE];