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/
This commit is contained in:
Mario Limonciello 2023-02-17 13:02:53 -06:00 committed by Bastien Nocera
parent 6b7ffaaa16
commit 0b7d7cfc08

View file

@ -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,