From d7f1bf55de06b5ca788513112861044afb8f92ac Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 11 Nov 2017 20:02:19 +0000 Subject: [PATCH] ebitdo: Use the new delayed removal functionality to remove complexity The engine keeps track of the runtime GUID, so we don't have to anymore. --- plugins/ebitdo/fu-ebitdo-device.c | 3 +++ plugins/ebitdo/fu-plugin-ebitdo.c | 21 +-------------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/plugins/ebitdo/fu-ebitdo-device.c b/plugins/ebitdo/fu-ebitdo-device.c index b8dbe471e..eb315a8f0 100644 --- a/plugins/ebitdo/fu-ebitdo-device.c +++ b/plugins/ebitdo/fu-ebitdo-device.c @@ -609,6 +609,7 @@ fu_ebitdo_device_init_real (FuEbitdoDevice *device) /* allowed, but requires manual bootloader step */ fu_device_add_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_UPDATABLE); + fu_device_set_remove_delay (FU_DEVICE (device), FU_DEVICE_REMOVE_DELAY_USER_REPLUG); /* set name and vendor */ name = g_strdup_printf ("%s Gamepad", @@ -623,6 +624,8 @@ fu_ebitdo_device_init_real (FuEbitdoDevice *device) /* only the bootloader can do the update */ if (priv->kind != FU_EBITDO_DEVICE_KIND_BOOTLOADER) { + fu_device_add_guid (FU_DEVICE (device), "USB\\VID_0483&PID_5750"); + fu_device_add_guid (FU_DEVICE (device), "USB\\VID_2DC8&PID_5750"); fu_device_add_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER); } diff --git a/plugins/ebitdo/fu-plugin-ebitdo.c b/plugins/ebitdo/fu-plugin-ebitdo.c index 24f3e984f..aa526c9b3 100644 --- a/plugins/ebitdo/fu-plugin-ebitdo.c +++ b/plugins/ebitdo/fu-plugin-ebitdo.c @@ -32,8 +32,6 @@ fu_plugin_ebitdo_device_added (FuPlugin *plugin, GError **error) { FuEbitdoDeviceKind ebitdo_kind; - const gchar *platform_id = NULL; - g_autofree gchar *runtime_id = NULL; g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuEbitdoDevice) dev = NULL; @@ -48,26 +46,9 @@ fu_plugin_ebitdo_device_added (FuPlugin *plugin, if (locker == NULL) return FALSE; - /* only the bootloader can do the update */ - platform_id = g_usb_device_get_platform_id (usb_device); - runtime_id = g_strdup_printf ("%s-runtime", platform_id); - if (ebitdo_kind == FU_EBITDO_DEVICE_KIND_BOOTLOADER) { - FuEbitdoDevice *dev_runtime; - - /* add the last seen runtime GUID too */ - dev_runtime = fu_plugin_cache_lookup (plugin, runtime_id); - if (dev_runtime != NULL) { - const gchar *guid = fu_device_get_guid_default (FU_DEVICE (dev_runtime)); - g_debug ("adding runtime GUID of %s", guid); - fu_device_add_guid (FU_DEVICE (dev), guid); - } - } else { - fu_plugin_cache_add (plugin, runtime_id, dev); - } - /* insert to hash */ fu_plugin_device_add (plugin, FU_DEVICE (dev)); - fu_plugin_cache_add (plugin, platform_id, dev); + fu_plugin_cache_add (plugin, g_usb_device_get_platform_id (usb_device), dev); return TRUE; }