From 0b7d7cfc08bfb6ee4e783c8956fd7e0bd330d7a3 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 17 Feb 2023 13:02:53 -0600 Subject: linux: Fix is-present for devices at startup As will be documented in the kernel through this patch: https://patchwork.kernel.org/project/linux-pm/patch/20230220131018.1708991-1-hadess@hadess.net/ --- src/linux/up-device-supply.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 604ff54..795018b 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -262,6 +262,10 @@ up_device_supply_refresh_device (UpDeviceSupply *supply, if (!supply->priv->has_coldplug_values) { gchar *model_name; gchar *serial_number; + gboolean is_present = TRUE; + + if (g_udev_device_has_sysfs_attr_uncached (native, "present")) + is_present = g_udev_device_get_sysfs_attr_as_boolean_uncached (native, "present"); /* get values which may be blank */ model_name = up_device_supply_get_string (native, "model_name"); @@ -272,7 +276,7 @@ up_device_supply_refresh_device (UpDeviceSupply *supply, up_make_safe_string (serial_number); g_object_set (device, - "is-present", TRUE, + "is-present", is_present, "model", model_name, "serial", serial_number, "is-rechargeable", TRUE, -- cgit v1.2.1