unifying: Only detach the device if required

This commit is contained in:
Richard Hughes 2017-06-22 21:09:51 +01:00
parent 43775d03f9
commit 765c679498

View File

@ -150,20 +150,25 @@ fu_plugin_update_online (FuPlugin *plugin,
/* switch to bootloader */ /* switch to bootloader */
data->ignore_replug = TRUE; data->ignore_replug = TRUE;
if (lu_device_get_kind (device) == LU_DEVICE_KIND_RUNTIME) { if (lu_device_has_flag (device, LU_DEVICE_FLAG_REQUIRES_DETACH)) {
/* wait for device to come back */ /* wait for device to come back */
g_timeout_add (50, fu_plugin_unifying_detach_cb, device); if (lu_device_has_flag (device, LU_DEVICE_FLAG_DETACH_WILL_REPLUG)) {
if (!lu_context_wait_for_replug (data->ctx, g_timeout_add (50, fu_plugin_unifying_detach_cb, device);
device, if (!lu_context_wait_for_replug (data->ctx,
FU_DEVICE_TIMEOUT_REPLUG, device,
error)) FU_DEVICE_TIMEOUT_REPLUG,
return FALSE; error))
g_object_unref (device); return FALSE;
device = fu_plugin_unifying_get_device (plugin, dev, error); g_object_unref (device);
if (device == NULL) device = fu_plugin_unifying_get_device (plugin, dev, error);
return FALSE; if (device == NULL)
if (!lu_device_open (device, error)) return FALSE;
return FALSE; if (!lu_device_open (device, error))
return FALSE;
} else {
if (!lu_device_detach (device, error))
return FALSE;
}
} }
/* write the firmware */ /* write the firmware */