chiark / gitweb /
remove remaining support for CONFIG_SYSFS_DEPRECATED
[elogind.git] / libudev / libudev-device.c
index 22d8349275d1fcaef57a3cd47becd716279993b2..dffeed0b79bc95f5fbfa190cbd46205264cc2139 100644 (file)
@@ -123,7 +123,7 @@ int udev_device_read_db(struct udev_device *udev_device)
                                next = &next[1];
                        }
                        util_strscpyl(devlink, sizeof(devlink), udev_get_dev_path(udev_device->udev), "/", lnk, NULL);
-                       udev_device_add_devlink(udev_device, devlink);
+                       udev_device_add_devlink(udev_device, devlink, 0);
                }
                info(udev_device->udev, "device %p filled with db symlink data '%s'\n", udev_device, udev_device->devnode);
                return 0;
@@ -150,7 +150,7 @@ int udev_device_read_db(struct udev_device *udev_device)
                        break;
                case 'S':
                        util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/", val, NULL);
-                       udev_device_add_devlink(udev_device, filename);
+                       udev_device_add_devlink(udev_device, filename, 0);
                        break;
                case 'L':
                        udev_device_set_devlink_priority(udev_device, atoi(val));
@@ -508,20 +508,9 @@ static struct udev_device *device_new_from_parent(struct udev_device *udev_devic
        char path[UTIL_PATH_SIZE];
        const char *subdir;
 
-       /* follow "device" link in deprecated sys layout */
-       if (strncmp(udev_device->devpath, "/class/", 7) == 0 ||
-           strncmp(udev_device->devpath, "/block/", 7) == 0) {
-               util_strscpyl(path, sizeof(path), udev_device->syspath, "/device", NULL);
-               if (util_resolve_sys_link(udev_device->udev, path, sizeof(path)) == 0) {
-                       udev_device_parent = udev_device_new_from_syspath(udev_device->udev, path);
-                       if (udev_device_parent != NULL)
-                               return udev_device_parent;
-               }
-       }
-
        util_strscpy(path, sizeof(path), udev_device->syspath);
        subdir = &path[strlen(udev_get_sys_path(udev_device->udev))+1];
-       while (1) {
+       for (;;) {
                char *pos;
 
                pos = strrchr(subdir, '/');
@@ -577,6 +566,9 @@ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)
  * value, and fill in information from the sys device and the udev
  * database entry.
  *
+ * If devtype is #NULL, only subsystem is checked, and any devtype will
+ * match.
+ *
  * The returned the device is not referenced. It is attached to the
  * child device, and will be cleaned up when the child device
  * is cleaned up.
@@ -1118,11 +1110,16 @@ int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode
        return 0;
 }
 
-int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink)
+int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink, int unique)
 {
+       struct udev_list_entry *list_entry;
+
        udev_device->devlinks_uptodate = 0;
-       if (udev_list_entry_add(udev_device->udev, &udev_device->devlinks_list, devlink, NULL, 1, 0) == NULL)
+       list_entry = udev_list_entry_add(udev_device->udev, &udev_device->devlinks_list, devlink, NULL, 1, 0);
+       if (list_entry == NULL)
                return -ENOMEM;
+       if (unique)
+               udev_list_entry_set_flag(list_entry, 1);
        return 0;
 }