]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
backlight: filter out unnecessary backlight devices by device enumerator
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Aug 2022 14:25:34 +0000 (23:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 17 Aug 2022 05:21:36 +0000 (14:21 +0900)
src/backlight/backlight.c

index 46b1301ff6a20a8bdf7d07795b1adc466e43bd92..b01b94b2b6cd887f583be927043b1df16fac4d65 100644 (file)
@@ -188,17 +188,22 @@ static int validate_device(sd_device *device) {
         if (r < 0)
                 return log_debug_errno(r, "Failed to add subsystem match: %m");
 
+        r = sd_device_enumerator_add_nomatch_sysname(enumerate, sysname);
+        if (r < 0)
+                return log_debug_errno(r, "Failed to add sysname unmatch: %m");
+
+        r = sd_device_enumerator_add_match_sysattr(enumerate, "type", "platform", /* match = */ true);
+        if (r < 0)
+                return log_debug_errno(r, "Failed to add sysattr match: %m");
+
+        r = sd_device_enumerator_add_match_sysattr(enumerate, "type", "firmware", /* match = */ true);
+        if (r < 0)
+                return log_debug_errno(r, "Failed to add sysattr match: %m");
+
         FOREACH_DEVICE(enumerate, other) {
                 const char *other_subsystem;
                 sd_device *other_parent;
 
-                if (same_device(device, other) > 0)
-                        continue;
-
-                if (sd_device_get_sysattr_value(other, "type", &v) < 0 ||
-                    !STR_IN_SET(v, "platform", "firmware"))
-                        continue;
-
                 /* OK, so there's another backlight device, and it's a platform or firmware device.
                  * Let's see if we can verify it belongs to the same device as ours. */
                 r = find_pci_or_platform_parent(other, &other_parent);