From 8052220fb3e6aa5c70b7712a379b7f6bbb08ee1c Mon Sep 17 00:00:00 2001 From: stuarthayhurst Date: Fri, 14 Apr 2023 02:41:55 +0100 Subject: linux: Don't overwrite guesses from previous siblings If a power supply has multiple siblings, any guesses to device type from previous siblings will be overwritten by a sibling with no guess, as it defaults to keyboard, the highest priority. Instead, while guessing, use UNKNOWN, and only default to keyboard at the end. Could also be fixed by changing the keyboard's priority, but that might have side effects for otherwise working devices. Closes: #221 --- src/linux/up-device-supply.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index c5222b5..91386cf 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -406,8 +406,7 @@ up_device_supply_sibling_discovered (UpDevice *device, g_free (serial_number); } - /* Fall back to "keyboard" if we don't find anything. */ - new_type = UP_DEVICE_KIND_KEYBOARD; + new_type = UP_DEVICE_KIND_UNKNOWN; for (i = 0; i < G_N_ELEMENTS (types); i++) { if (g_udev_device_get_property_as_boolean (input, types[i].prop)) { @@ -438,6 +437,10 @@ up_device_supply_sibling_discovered (UpDevice *device, * the model name. */ + /* Fall back to "keyboard" if we didn't find anything. */ + if (new_type == UP_DEVICE_KIND_UNKNOWN) + new_type = UP_DEVICE_KIND_KEYBOARD; + if (cur_type != new_type) g_object_set (device, "type", new_type, NULL); } -- cgit v1.2.1