Use udev_device_get_parent_with_subsystem_devtype() function
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 3 Jan 2009 10:32:00 +0000 (11:32 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 3 Jan 2009 10:32:00 +0000 (11:32 +0100)
configure.ac
src/udev.c

index adee2fe..2a4900c 100644 (file)
@@ -148,14 +148,15 @@ if (test "${enable_udev}" = "yes"); then
        AC_DEFINE(HAVE_UDEV, 1, [Define if udev support is available])
        PKG_CHECK_MODULES(UDEV, libudev >= 129, enable_udev=yes,
                                AC_MSG_ERROR(udev >= 129 is required))
-       AC_CHECK_LIB(udev, udev_device_get_parent_with_devtype, dummy=yes,
-               AC_DEFINE(NEED_UDEV_DEVICE_GET_PARENT_WITH_DEVTYPE, 1,
-                       [Define to 1 if you need the
-                               udev_device_get_parent_with_devtype() function.]))
        AC_CHECK_LIB(udev, udev_enumerate_add_match_property, dummy=yes,
                AC_DEFINE(NEED_UDEV_ENUMERATE_ADD_MATCH_PROPERTY, 1,
                        [Define to 1 if you need the
                                udev_enumerate_add_match_property() function.]))
+       AC_CHECK_LIB(udev, udev_device_get_parent_with_subsystem_devtype, dummy=yes,
+               AC_DEFINE(NEED_UDEV_DEVICE_GET_PARENT_WITH_SUBSYSTEM_DEVTYPE, 1,
+                       [Define to 1 if you need the
+                               udev_device_get_parent_with_subsystem_devtype()
+                                                                       function.]))
 fi
 AC_SUBST(UDEV_CFLAGS)
 AC_SUBST(UDEV_LIBS)
index f5c2f30..4ce3f4e 100644 (file)
 
 #include "connman.h"
 
-#ifdef NEED_UDEV_DEVICE_GET_PARENT_WITH_DEVTYPE
-static struct udev_device *udev_device_get_parent_with_devtype(struct udev_device *device,
-                                                               const char *devtype)
+#ifdef NEED_UDEV_ENUMERATE_ADD_MATCH_PROPERTY
+static int udev_enumerate_add_match_property(struct udev_enumerate *enumerate,
+                                       const char *property, const char *value)
 {
-       return NULL;
+       return -EINVAL;
 }
 #endif
 
-#ifdef NEED_UDEV_ENUMERATE_ADD_MATCH_PROPERTY
-static int udev_enumerate_add_match_property(struct udev_enumerate *enumerate,
-                                       const char *property, const char *value)
+#ifdef NEED_UDEV_DEVICE_GET_PARENT_WITH_SUBSYSTEM_DEVTYPE
+static struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *device,
+                                               const char *subsystem, const char *devtype)
 {
-       return 0;
+       return NULL;
 }
 #endif
 
@@ -179,12 +179,18 @@ static void print_properties(struct udev_device *device, const char *prefix)
 
 static void print_device(struct udev_device *device, const char *action)
 {
+       const char *subsystem = udev_device_get_subsystem(device);
+       const char *devtype = NULL;
        struct udev_device *parent;
 
        connman_debug("=== %s ===", action);
        print_properties(device, "");
 
-       parent = udev_device_get_parent_with_devtype(device, "usb_device");
+       if (subsystem != NULL && g_str_equal(subsystem, "usb") == TRUE)
+               devtype = "usb_device";
+
+       parent = udev_device_get_parent_with_subsystem_devtype(device,
+                                                       subsystem, devtype);
        print_properties(parent, "    ");
 }