From 1ec96e31f50697b34e5b322161bedef17d3f491f Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 16 Jun 2020 21:14:37 +0100 Subject: [PATCH] Allow plugins to set remove delay only on the child Force the FuDevice parent to have the largest of the child removal delays. This avoids each plugin enumerating the children (which may not even be added yet) to increase the length of the allowed parent delay. --- libfwupdplugin/fu-device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libfwupdplugin/fu-device.c b/libfwupdplugin/fu-device.c index 3dfb23780..64a8723af 100644 --- a/libfwupdplugin/fu-device.c +++ b/libfwupdplugin/fu-device.c @@ -770,6 +770,17 @@ fu_device_add_child (FuDevice *self, FuDevice *child) } g_ptr_array_add (priv->children, g_object_ref (child)); + /* ensure the parent has the MAX() of the childrens removal delay */ + for (guint i = 0; i < priv->children->len; i++) { + FuDevice *child_tmp = g_ptr_array_index (priv->children, i); + guint remove_delay = fu_device_get_remove_delay (child_tmp); + if (remove_delay > priv->remove_delay) { + g_debug ("setting remove delay to %u as child is greater than %u", + remove_delay, priv->remove_delay); + priv->remove_delay = remove_delay; + } + } + /* copy from main device if unset */ if (fu_device_get_physical_id (child) == NULL && fu_device_get_physical_id (self) != NULL)