mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-29 23:26:55 +00:00
unifying: Use the new update_detach() and update_attach() vfuncs
This commit is contained in:
parent
0d7fdb3110
commit
37e124f3da
@ -159,26 +159,25 @@ fu_plugin_unifying_attach_cb (gpointer user_data)
|
||||
}
|
||||
|
||||
gboolean
|
||||
fu_plugin_update (FuPlugin *plugin,
|
||||
FuDevice *dev,
|
||||
GBytes *blob_fw,
|
||||
FwupdInstallFlags flags,
|
||||
GError **error)
|
||||
fu_plugin_update_detach (FuPlugin *plugin, FuDevice *dev, GError **error)
|
||||
{
|
||||
FuPluginData *data = fu_plugin_get_data (plugin);
|
||||
g_autoptr(LuDevice) device = NULL;
|
||||
|
||||
/* get version */
|
||||
/* get device */
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* switch to bootloader */
|
||||
/* switch to bootloader if required */
|
||||
data->ignore_replug = TRUE;
|
||||
if (lu_device_has_flag (device, LU_DEVICE_FLAG_REQUIRES_DETACH)) {
|
||||
if (!lu_device_has_flag (device, LU_DEVICE_FLAG_REQUIRES_DETACH))
|
||||
return TRUE;
|
||||
|
||||
/* wait for device to come back */
|
||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
||||
if (lu_device_has_flag (device, LU_DEVICE_FLAG_DETACH_WILL_REPLUG)) {
|
||||
g_debug ("doing detach in idle");
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
|
||||
@ -190,29 +189,33 @@ fu_plugin_update (FuPlugin *plugin,
|
||||
FU_DEVICE_TIMEOUT_REPLUG,
|
||||
error))
|
||||
return FALSE;
|
||||
g_object_unref (device);
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
} else {
|
||||
g_debug ("doing detach in main thread");
|
||||
if (!lu_device_detach (device, error))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* 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))
|
||||
return FALSE;
|
||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
||||
gboolean
|
||||
fu_plugin_update_attach (FuPlugin *plugin, FuDevice *dev, GError **error)
|
||||
{
|
||||
FuPluginData *data = fu_plugin_get_data (plugin);
|
||||
g_autoptr(LuDevice) device = NULL;
|
||||
|
||||
/* wait for it to appear back in runtime mode */
|
||||
if (lu_device_has_flag (device, LU_DEVICE_FLAG_REQUIRES_ATTACH)) {
|
||||
/* get device */
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* wait for it to appear back in runtime mode if required */
|
||||
if (!lu_device_has_flag (device, LU_DEVICE_FLAG_REQUIRES_ATTACH))
|
||||
return TRUE;
|
||||
|
||||
/* wait for device to come back */
|
||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
||||
if (lu_device_has_flag (device, LU_DEVICE_FLAG_ATTACH_WILL_REPLUG)) {
|
||||
g_debug ("doing attach in idle");
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
|
||||
@ -224,24 +227,56 @@ fu_plugin_update (FuPlugin *plugin,
|
||||
FU_DEVICE_TIMEOUT_REPLUG,
|
||||
error))
|
||||
return FALSE;
|
||||
g_object_unref (device);
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
} else {
|
||||
g_debug ("doing attach in main thread");
|
||||
if (!lu_device_attach (device, error))
|
||||
return FALSE;
|
||||
}
|
||||
data->ignore_replug = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
fu_plugin_update_reload (FuPlugin *plugin, FuDevice *dev, GError **error)
|
||||
{
|
||||
g_autoptr(LuDevice) device = NULL;
|
||||
|
||||
/* get device */
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* set new version */
|
||||
fu_device_set_version (dev, lu_device_get_version_fw (device));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
fu_plugin_update (FuPlugin *plugin,
|
||||
FuDevice *dev,
|
||||
GBytes *blob_fw,
|
||||
FwupdInstallFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(LuDevice) device = NULL;
|
||||
|
||||
/* get version */
|
||||
device = fu_plugin_unifying_get_device (plugin, dev, error);
|
||||
if (device == NULL)
|
||||
return FALSE;
|
||||
if (!lu_device_open (device, error))
|
||||
return FALSE;
|
||||
|
||||
/* 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))
|
||||
return FALSE;
|
||||
|
||||
/* success */
|
||||
data->ignore_replug = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user