mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-26 02:42:46 +00:00
Open the device proxy in the engine where required
The benefit of using the proxy device is that we can 'use' the proxy device for device access, but 'report' the progress on the passed FuDevice instance. This means the front-end reports the device status correctly when updating composite devices that us proxies. The comment always said we should move it to the daemon if another plugin started doing this, and that is now.
This commit is contained in:
parent
a0fd32f418
commit
15b668c0c6
@ -1097,6 +1097,26 @@ fu_device_get_proxy (FuDevice *self)
|
|||||||
return priv->proxy;
|
return priv->proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_device_get_proxy_with_fallback:
|
||||||
|
* @self: a #FuDevice
|
||||||
|
*
|
||||||
|
* Gets the proxy device, falling back to the device itself.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a device
|
||||||
|
*
|
||||||
|
* Since: 1.6.2
|
||||||
|
**/
|
||||||
|
FuDevice *
|
||||||
|
fu_device_get_proxy_with_fallback (FuDevice *self)
|
||||||
|
{
|
||||||
|
FuDevicePrivate *priv = GET_PRIVATE (self);
|
||||||
|
g_return_val_if_fail (FU_IS_DEVICE (self), NULL);
|
||||||
|
if (priv->proxy != NULL)
|
||||||
|
return priv->proxy;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_device_get_children:
|
* fu_device_get_children:
|
||||||
* @self: a #FuDevice
|
* @self: a #FuDevice
|
||||||
|
@ -310,6 +310,7 @@ void fu_device_add_counterpart_guid (FuDevice *self,
|
|||||||
FuDevice *fu_device_get_proxy (FuDevice *self);
|
FuDevice *fu_device_get_proxy (FuDevice *self);
|
||||||
void fu_device_set_proxy (FuDevice *self,
|
void fu_device_set_proxy (FuDevice *self,
|
||||||
FuDevice *proxy);
|
FuDevice *proxy);
|
||||||
|
FuDevice *fu_device_get_proxy_with_fallback (FuDevice *self);
|
||||||
const gchar *fu_device_get_metadata (FuDevice *self,
|
const gchar *fu_device_get_metadata (FuDevice *self,
|
||||||
const gchar *key);
|
const gchar *key);
|
||||||
gboolean fu_device_get_metadata_boolean (FuDevice *self,
|
gboolean fu_device_get_metadata_boolean (FuDevice *self,
|
||||||
|
@ -655,8 +655,9 @@ fu_plugin_get_context (FuPlugin *self)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_device_attach (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_device_attach (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return fu_device_attach (device, error);
|
return fu_device_attach (device, error);
|
||||||
@ -665,8 +666,9 @@ fu_plugin_device_attach (FuPlugin *self, FuDevice *device, GError **error)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_device_detach (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_device_detach (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return fu_device_detach (device, error);
|
return fu_device_detach (device, error);
|
||||||
@ -675,8 +677,9 @@ fu_plugin_device_detach (FuPlugin *self, FuDevice *device, GError **error)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_device_activate (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_device_activate (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return fu_device_activate (device, error);
|
return fu_device_activate (device, error);
|
||||||
@ -687,8 +690,9 @@ fu_plugin_device_write_firmware (FuPlugin *self, FuDevice *device,
|
|||||||
GBytes *fw, FwupdInstallFlags flags,
|
GBytes *fw, FwupdInstallFlags flags,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -723,6 +727,7 @@ fu_plugin_device_write_firmware (FuPlugin *self, FuDevice *device,
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_device_read_firmware (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_device_read_firmware (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
g_autoptr(FuFirmware) firmware = NULL;
|
g_autoptr(FuFirmware) firmware = NULL;
|
||||||
g_autoptr(GBytes) fw = NULL;
|
g_autoptr(GBytes) fw = NULL;
|
||||||
@ -730,7 +735,7 @@ fu_plugin_device_read_firmware (FuPlugin *self, FuDevice *device, GError **error
|
|||||||
G_CHECKSUM_SHA1,
|
G_CHECKSUM_SHA1,
|
||||||
G_CHECKSUM_SHA256,
|
G_CHECKSUM_SHA256,
|
||||||
0 };
|
0 };
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!fu_device_detach (device, error))
|
if (!fu_device_detach (device, error))
|
||||||
@ -1219,6 +1224,7 @@ fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error
|
|||||||
gboolean
|
gboolean
|
||||||
fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
|
|
||||||
/* not enabled */
|
/* not enabled */
|
||||||
@ -1226,7 +1232,7 @@ fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* no object loaded */
|
/* no object loaded */
|
||||||
locker = fu_device_locker_new (device, error);
|
locker = fu_device_locker_new (proxy, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return fu_device_reload (device, error);
|
return fu_device_reload (device, error);
|
||||||
@ -1407,6 +1413,7 @@ fu_plugin_check_supported_device (FuPlugin *self, FuDevice *device)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_backend_device_added (FuPlugin *self, FuDevice *device, GError **error)
|
fu_plugin_backend_device_added (FuPlugin *self, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy;
|
||||||
FuPluginPrivate *priv = GET_PRIVATE (self);
|
FuPluginPrivate *priv = GET_PRIVATE (self);
|
||||||
GType device_gtype = fu_device_get_specialized_gtype (FU_DEVICE (device));
|
GType device_gtype = fu_device_get_specialized_gtype (FU_DEVICE (device));
|
||||||
g_autoptr(FuDevice) dev = NULL;
|
g_autoptr(FuDevice) dev = NULL;
|
||||||
@ -1444,6 +1451,13 @@ fu_plugin_backend_device_added (FuPlugin *self, FuDevice *device, GError **error
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* open and add */
|
/* open and add */
|
||||||
|
proxy = fu_device_get_proxy (device);
|
||||||
|
if (proxy != NULL) {
|
||||||
|
g_autoptr(FuDeviceLocker) locker_proxy = NULL;
|
||||||
|
locker_proxy = fu_device_locker_new (proxy, error);
|
||||||
|
if (locker_proxy == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
locker = fu_device_locker_new (dev, error);
|
locker = fu_device_locker_new (dev, error);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -829,6 +829,7 @@ LIBFWUPDPLUGIN_1.6.2 {
|
|||||||
fu_device_emit_request;
|
fu_device_emit_request;
|
||||||
fu_device_get_parent_physical_ids;
|
fu_device_get_parent_physical_ids;
|
||||||
fu_device_get_private_flags;
|
fu_device_get_private_flags;
|
||||||
|
fu_device_get_proxy_with_fallback;
|
||||||
fu_device_get_request_cnt;
|
fu_device_get_request_cnt;
|
||||||
fu_device_has_parent_physical_id;
|
fu_device_has_parent_physical_id;
|
||||||
fu_device_has_private_flag;
|
fu_device_has_private_flag;
|
||||||
|
@ -299,8 +299,9 @@ fu_vli_usbhub_device_spi_write_data (FuVliDevice *self,
|
|||||||
#define VL817_ADDR_GPIO_GET_INPUT_DATA 0xF6A2 /* 0=low, 1=high */
|
#define VL817_ADDR_GPIO_GET_INPUT_DATA 0xF6A2 /* 0=low, 1=high */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_vli_usbhub_device_attach_full (FuDevice *device, FuDevice *proxy, GError **error)
|
fu_vli_usbhub_device_attach (FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDevice *proxy = fu_device_get_proxy_with_fallback (device);
|
||||||
g_autoptr(GError) error_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
|
|
||||||
/* update UI */
|
/* update UI */
|
||||||
@ -362,25 +363,6 @@ fu_vli_usbhub_device_attach_full (FuDevice *device, FuDevice *proxy, GError **er
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
fu_vli_usbhub_device_attach (FuDevice *device, GError **error)
|
|
||||||
{
|
|
||||||
FuDevice *proxy = fu_device_get_proxy (device);
|
|
||||||
|
|
||||||
/* if we do this in another plugin, perhaps move to the engine? */
|
|
||||||
if (proxy != NULL) {
|
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
|
||||||
g_debug ("using proxy device %s", fu_device_get_id (proxy));
|
|
||||||
locker = fu_device_locker_new (proxy, error);
|
|
||||||
if (locker == NULL)
|
|
||||||
return FALSE;
|
|
||||||
return fu_vli_usbhub_device_attach_full (device, proxy, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* normal case */
|
|
||||||
return fu_vli_usbhub_device_attach_full (device, device, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* disable hub sleep states -- not really required by 815~ hubs */
|
/* disable hub sleep states -- not really required by 815~ hubs */
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_vli_usbhub_device_disable_u1u2 (FuVliUsbhubDevice *self, GError **error)
|
fu_vli_usbhub_device_disable_u1u2 (FuVliUsbhubDevice *self, GError **error)
|
||||||
|
Loading…
Reference in New Issue
Block a user