]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: drop /sys/subsystem support
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Mar 2022 19:04:54 +0000 (04:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 30 Mar 2022 22:25:24 +0000 (07:25 +0900)
Follow-ups for 37cf83d9bfdd9f6859b6f2654d8ec3bbb17873b2.

src/libsystemd/sd-device/sd-device.c

index f22088db57d6055e8188b9c691c4358e5890b308..e7d398dbb0acb7c11bf2f04eda54f36d7c028085 100644 (file)
@@ -340,7 +340,7 @@ _public_ int sd_device_new_from_subsystem_sysname(
         assert_return(path_is_normalized(sysname), -EINVAL);
 
         if (streq(subsystem, "subsystem")) {
-                FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/", "/sys/class/") {
+                FOREACH_STRING(s, "/sys/bus/", "/sys/class/") {
                         r = device_strjoin_new(s, sysname, NULL, NULL, ret);
                         if (r < 0)
                                 return r;
@@ -364,13 +364,11 @@ _public_ int sd_device_new_from_subsystem_sysname(
                         const char *subsys = memdupa_suffix0(sysname, sep - sysname);
                         sep++;
 
-                        FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/") {
-                                r = device_strjoin_new(s, subsys, "/drivers/", sep, ret);
-                                if (r < 0)
-                                        return r;
-                                if (r > 0)
-                                        return 0;
-                        }
+                        r = device_strjoin_new("/sys/bus/", subsys, "/drivers/", sep, ret);
+                        if (r < 0)
+                                return r;
+                        if (r > 0)
+                                return 0;
                 }
         }
 
@@ -380,13 +378,11 @@ _public_ int sd_device_new_from_subsystem_sysname(
                 if (name[i] == '/')
                         name[i] = '!';
 
-        FOREACH_STRING(s, "/sys/subsystem/", "/sys/bus/") {
-                r = device_strjoin_new(s, subsystem, "/devices/", name, ret);
-                if (r < 0)
-                        return r;
-                if (r > 0)
-                        return 0;
-        }
+        r = device_strjoin_new("/sys/bus/", subsystem, "/devices/", name, ret);
+        if (r < 0)
+                return r;
+        if (r > 0)
+                return 0;
 
         r = device_strjoin_new("/sys/class/", subsystem, "/", name, ret);
         if (r < 0)
@@ -869,9 +865,7 @@ _public_ int sd_device_get_subsystem(sd_device *device, const char **ret) {
                         r = device_set_subsystem(device, "module");
                 else if (strstr(syspath, "/drivers/"))
                         r = device_set_drivers_subsystem(device);
-                else if (PATH_STARTSWITH_SET(device->devpath, "/subsystem/",
-                                                              "/class/",
-                                                              "/bus/"))
+                else if (PATH_STARTSWITH_SET(device->devpath, "/class/", "/bus/"))
                         r = device_set_subsystem(device, "subsystem");
                 else {
                         device->subsystem_set = true;