mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 21:30:48 +00:00
unifying: Wait for device to re-appear in runtime after attaching
This ensures we can flash multiple versions of firmware without an artificial delay. Also raise the timeout to cope with chains of slow hubs.
This commit is contained in:
parent
22c88de8e4
commit
a42dae927c
@ -155,7 +155,7 @@ fu_plugin_update_online (FuPlugin *plugin,
|
||||
g_timeout_add (50, fu_plugin_unifying_detach_cb, device);
|
||||
if (!lu_context_wait_for_replug (data->ctx,
|
||||
device,
|
||||
2000,
|
||||
FU_DEVICE_TIMEOUT_REPLUG,
|
||||
error))
|
||||
return FALSE;
|
||||
g_object_unref (device);
|
||||
@ -169,8 +169,8 @@ fu_plugin_update_online (FuPlugin *plugin,
|
||||
/* write the firmware */
|
||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE);
|
||||
if (!lu_device_write_firmware (device, blob_fw,
|
||||
lu_write_progress_cb, plugin,
|
||||
error))
|
||||
lu_write_progress_cb, plugin,
|
||||
error))
|
||||
return FALSE;
|
||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
||||
if (!lu_device_attach (device, error))
|
||||
@ -178,6 +178,24 @@ fu_plugin_update_online (FuPlugin *plugin,
|
||||
if (!lu_device_close (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* wait for it to appear back in runtime mode */
|
||||
if (!lu_context_wait_for_replug (data->ctx,
|
||||
device,
|
||||
FU_DEVICE_TIMEOUT_REPLUG,
|
||||
error))
|
||||
return FALSE;
|
||||
g_object_unref (device);
|
||||
|
||||
/* get the new device version */
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
fu_device_set_version (dev, lu_device_get_version_fw (device));
|
||||
if (!lu_device_close (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* success */
|
||||
data->ignore_replug = FALSE;
|
||||
return TRUE;
|
||||
|
@ -64,6 +64,9 @@ struct _LuDeviceClass
|
||||
#define LU_DEVICE_EP3 0x83
|
||||
#define LU_DEVICE_TIMEOUT_MS 2500
|
||||
|
||||
/* some USB hubs take a looong time to re-connect the device */
|
||||
#define FU_DEVICE_TIMEOUT_REPLUG 10000 /* ms */
|
||||
|
||||
typedef enum {
|
||||
LU_DEVICE_KIND_UNKNOWN,
|
||||
LU_DEVICE_KIND_RUNTIME,
|
||||
|
@ -407,7 +407,7 @@ lu_tool_write (FuLuToolPrivate *priv, gchar **values, GError **error)
|
||||
if (lu_device_has_flag (device, LU_DEVICE_FLAG_DETACH_WILL_REPLUG)) {
|
||||
if (!lu_context_wait_for_replug (priv->ctx,
|
||||
device,
|
||||
5000,
|
||||
FU_DEVICE_TIMEOUT_REPLUG,
|
||||
error))
|
||||
return FALSE;
|
||||
g_usleep (G_USEC_PER_SEC);
|
||||
|
Loading…
Reference in New Issue
Block a user