summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-08 23:25:34 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-17 14:21:36 +0900
commitf8ff4b60763cb3afc619119b2ed280d3b1fa0aba (patch)
treeb5eaa79c2d6aa35d7da59dfbe93ee2b471fdcb15 /src
parentb2f77b5e21a8e62b5c76b511fd5ba529f369e211 (diff)
downloadsystemd-f8ff4b60763cb3afc619119b2ed280d3b1fa0aba.tar.gz
backlight: filter out unnecessary backlight devices by device enumerator
Diffstat (limited to 'src')
-rw-r--r--src/backlight/backlight.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 46b1301ff6..b01b94b2b6 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -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);