From b07b1c6f400741df02d92fd2a8a3021f5799d587 Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Wed, 24 Feb 2021 23:44:15 +0000
Subject: [PATCH] Detect USB Type C port controller and other chargers

Based on squashing these two Purism patches:

https://source.puri.sm/Librem5/upower/-/commit/95186bfcb306d04b4383412421942f374217f459.patch
https://source.puri.sm/Librem5/upower/-/commit/29b711f4c1db8b380605696b6e37b843a7571084.patch
---
 src/linux/up-device-supply.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index d7e4423..3326c96 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -1066,6 +1066,10 @@ up_device_supply_guess_type (GUdevDevice *native,
 		/* use a heuristic to find the device type */
 		if (g_strstr_len (native_path, -1, "wacom_") != NULL) {
 			type = UP_DEVICE_KIND_TABLET;
+		} else if (g_strstr_len (native_path, -1, "-source-psy-") != NULL) {
+			type = UP_DEVICE_KIND_LINE_POWER;
+		} else if (g_strstr_len (native_path, -1, "-charger") != NULL) {
+			type = UP_DEVICE_KIND_BATTERY;
 		} else {
 			g_warning ("did not recognise USB path %s, please report",
 				   native_path);
-- 
2.30.1

