summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuarthayhurst <stuart.a.hayhurst@gmail.com>2023-04-14 02:41:55 +0100
committerBastien Nocera <hadess@hadess.net>2023-04-17 15:01:29 +0200
commit8052220fb3e6aa5c70b7712a379b7f6bbb08ee1c (patch)
tree03bb28b349fc0edb2358aa7d7a370c245b2fa640
parentc4bfc27042541f6c7014843239788f5d1d265eda (diff)
downloadupower-8052220fb3e6aa5c70b7712a379b7f6bbb08ee1c.tar.gz
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
-rw-r--r--src/linux/up-device-supply.c7
1 files 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);
}