|
|
ac3a84 |
From 49d626105a5739bf7fa725f578d02b8873c282c7 Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
ac3a84 |
Date: Mon, 14 Nov 2022 02:54:50 +0900
|
|
|
ac3a84 |
Subject: [PATCH] sleep: enumerate only existing and non-device batteries
|
|
|
ac3a84 |
|
|
|
ac3a84 |
The enumerator is now mostly consistent with on_ac_power() in
|
|
|
ac3a84 |
udev-util.c.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
(cherry picked from commit fe8e0f8e7989fe5cead5ad0e225dc0888ff10140)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related: #2151612
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
src/shared/sleep-config.c | 17 ++++++++++++++---
|
|
|
ac3a84 |
1 file changed, 14 insertions(+), 3 deletions(-)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
|
|
|
ac3a84 |
index 4c08e97c8a..2d55e7c860 100644
|
|
|
ac3a84 |
--- a/src/shared/sleep-config.c
|
|
|
ac3a84 |
+++ b/src/shared/sleep-config.c
|
|
|
ac3a84 |
@@ -143,16 +143,27 @@ static int battery_enumerator_new(sd_device_enumerator **ret) {
|
|
|
ac3a84 |
if (r < 0)
|
|
|
ac3a84 |
return r;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- r = sd_device_enumerator_add_match_subsystem(e, "power_supply", /* match= */ true);
|
|
|
ac3a84 |
+ r = sd_device_enumerator_add_match_subsystem(e, "power_supply", /* match = */ true);
|
|
|
ac3a84 |
if (r < 0)
|
|
|
ac3a84 |
return r;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- r = sd_device_enumerator_add_match_property(e, "POWER_SUPPLY_TYPE", "Battery");
|
|
|
ac3a84 |
+ r = sd_device_enumerator_allow_uninitialized(e);
|
|
|
ac3a84 |
if (r < 0)
|
|
|
ac3a84 |
return r;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- *ret = TAKE_PTR(e);
|
|
|
ac3a84 |
+ r = sd_device_enumerator_add_match_sysattr(e, "type", "Battery", /* match = */ true);
|
|
|
ac3a84 |
+ if (r < 0)
|
|
|
ac3a84 |
+ return r;
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
+ r = sd_device_enumerator_add_match_sysattr(e, "present", "1", /* match = */ true);
|
|
|
ac3a84 |
+ if (r < 0)
|
|
|
ac3a84 |
+ return r;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+ r = sd_device_enumerator_add_match_sysattr(e, "scope", "Device", /* match = */ false);
|
|
|
ac3a84 |
+ if (r < 0)
|
|
|
ac3a84 |
+ return r;
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
+ *ret = TAKE_PTR(e);
|
|
|
ac3a84 |
return 0;
|
|
|
ac3a84 |
}
|
|
|
ac3a84 |
|