mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 04:23:21 +00:00
Set the context in the right place more often
This commit is contained in:
parent
945002f7a3
commit
8b62bf6b64
@ -3548,6 +3548,23 @@ fu_device_set_context(FuDevice *self, FuContext *ctx)
|
||||
{
|
||||
FuDevicePrivate *priv = GET_PRIVATE(self);
|
||||
g_return_if_fail(FU_IS_DEVICE(self));
|
||||
g_return_if_fail(FU_IS_CONTEXT(ctx) || ctx == NULL);
|
||||
|
||||
#ifndef SUPPORTED_BUILD
|
||||
if (priv->ctx != NULL && ctx == NULL) {
|
||||
g_critical("clearing device context for %s [%s]",
|
||||
fu_device_get_name(self),
|
||||
fu_device_get_id(self));
|
||||
return;
|
||||
}
|
||||
if (priv->ctx != NULL && priv->ctx == ctx) {
|
||||
g_critical("re-setting device context for %s [%s]",
|
||||
fu_device_get_name(self),
|
||||
fu_device_get_id(self));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_set_object(&priv->ctx, ctx))
|
||||
g_object_notify(G_OBJECT(self), "context");
|
||||
}
|
||||
|
@ -1038,8 +1038,9 @@ FuDellDockEc *
|
||||
fu_dell_dock_ec_new(FuDevice *proxy)
|
||||
{
|
||||
FuDellDockEc *self = NULL;
|
||||
FuContext *ctx = fu_device_get_context(proxy);
|
||||
|
||||
self = g_object_new(FU_TYPE_DELL_DOCK_EC, NULL);
|
||||
self = g_object_new(FU_TYPE_DELL_DOCK_EC, "context", ctx, NULL);
|
||||
fu_device_set_proxy(FU_DEVICE(self), proxy);
|
||||
fu_device_set_physical_id(FU_DEVICE(self), fu_device_get_physical_id(proxy));
|
||||
fu_device_set_logical_id(FU_DEVICE(self), "ec");
|
||||
|
@ -1255,9 +1255,9 @@ fu_dell_dock_mst_class_init(FuDellDockMstClass *klass)
|
||||
}
|
||||
|
||||
FuDellDockMst *
|
||||
fu_dell_dock_mst_new(void)
|
||||
fu_dell_dock_mst_new(FuContext *ctx)
|
||||
{
|
||||
FuDellDockMst *device = NULL;
|
||||
device = g_object_new(FU_TYPE_DELL_DOCK_MST, NULL);
|
||||
device = g_object_new(FU_TYPE_DELL_DOCK_MST, "context", ctx, NULL);
|
||||
return device;
|
||||
}
|
||||
|
@ -23,4 +23,4 @@
|
||||
G_DECLARE_FINAL_TYPE(FuDellDockMst, fu_dell_dock_mst, FU, DELL_DOCK_MST, FuDevice)
|
||||
|
||||
FuDellDockMst *
|
||||
fu_dell_dock_mst_new(void);
|
||||
fu_dell_dock_mst_new(FuContext *ctx);
|
||||
|
@ -294,7 +294,8 @@ fu_dell_dock_tbt_class_init(FuDellDockTbtClass *klass)
|
||||
FuDellDockTbt *
|
||||
fu_dell_dock_tbt_new(FuDevice *proxy)
|
||||
{
|
||||
FuDellDockTbt *self = g_object_new(FU_TYPE_DELL_DOCK_TBT, NULL);
|
||||
FuContext *ctx = fu_device_get_context(proxy);
|
||||
FuDellDockTbt *self = g_object_new(FU_TYPE_DELL_DOCK_TBT, "context", ctx, NULL);
|
||||
fu_device_set_proxy(FU_DEVICE(self), proxy);
|
||||
return self;
|
||||
}
|
||||
|
@ -176,9 +176,9 @@ fu_dell_dock_status_class_init(FuDellDockStatusClass *klass)
|
||||
}
|
||||
|
||||
FuDellDockStatus *
|
||||
fu_dell_dock_status_new(void)
|
||||
fu_dell_dock_status_new(FuContext *ctx)
|
||||
{
|
||||
FuDellDockStatus *self = NULL;
|
||||
self = g_object_new(FU_TYPE_DELL_DOCK_STATUS, NULL);
|
||||
self = g_object_new(FU_TYPE_DELL_DOCK_STATUS, "context", ctx, NULL);
|
||||
return self;
|
||||
}
|
||||
|
@ -23,4 +23,4 @@
|
||||
G_DECLARE_FINAL_TYPE(FuDellDockStatus, fu_dell_dock_status, FU, DELL_DOCK_STATUS, FuDevice)
|
||||
|
||||
FuDellDockStatus *
|
||||
fu_dell_dock_status_new(void);
|
||||
fu_dell_dock_status_new(FuContext *ctx);
|
||||
|
@ -47,10 +47,8 @@ fu_plugin_dell_dock_init(FuPlugin *plugin)
|
||||
static gboolean
|
||||
fu_plugin_dell_dock_create_node(FuPlugin *plugin, FuDevice *device, GError **error)
|
||||
{
|
||||
FuContext *ctx = fu_plugin_get_context(plugin);
|
||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||
|
||||
fu_device_set_context(device, ctx);
|
||||
locker = fu_device_locker_new(device, error);
|
||||
if (locker == NULL)
|
||||
return FALSE;
|
||||
@ -75,12 +73,11 @@ fu_plugin_dell_dock_probe(FuPlugin *plugin, FuDevice *proxy, GError **error)
|
||||
return FALSE;
|
||||
|
||||
/* create mst endpoint */
|
||||
mst_device = fu_dell_dock_mst_new();
|
||||
mst_device = fu_dell_dock_mst_new(ctx);
|
||||
if (fu_dell_dock_get_ec_type(FU_DEVICE(ec_device)) == ATOMIC_BASE)
|
||||
instance = DELL_DOCK_VMM6210_INSTANCE_ID;
|
||||
else
|
||||
instance = DELL_DOCK_VM5331_INSTANCE_ID;
|
||||
fu_device_set_context(FU_DEVICE(mst_device), ctx);
|
||||
fu_device_add_guid(FU_DEVICE(mst_device), fwupd_guid_hash_string(instance));
|
||||
fu_device_add_child(FU_DEVICE(ec_device), FU_DEVICE(mst_device));
|
||||
fu_device_add_instance_id(FU_DEVICE(mst_device), instance);
|
||||
@ -88,14 +85,13 @@ fu_plugin_dell_dock_probe(FuPlugin *plugin, FuDevice *proxy, GError **error)
|
||||
return FALSE;
|
||||
|
||||
/* create package version endpoint */
|
||||
status_device = fu_dell_dock_status_new();
|
||||
status_device = fu_dell_dock_status_new(ctx);
|
||||
if (fu_dell_dock_get_ec_type(FU_DEVICE(ec_device)) == ATOMIC_BASE)
|
||||
instance = DELL_DOCK_ATOMIC_STATUS_INSTANCE_ID;
|
||||
else if (fu_dell_dock_module_is_usb4(FU_DEVICE(ec_device)))
|
||||
instance = DELL_DOCK_DOCK2_INSTANCE_ID;
|
||||
else
|
||||
instance = DELL_DOCK_DOCK1_INSTANCE_ID;
|
||||
fu_device_set_context(FU_DEVICE(status_device), ctx);
|
||||
fu_device_add_guid(FU_DEVICE(status_device), fwupd_guid_hash_string(instance));
|
||||
fu_device_add_child(FU_DEVICE(ec_device), FU_DEVICE(status_device));
|
||||
fu_device_add_instance_id(FU_DEVICE(status_device), instance);
|
||||
|
@ -531,10 +531,10 @@ fu_dfu_device_remove_attribute(FuDfuDevice *self, FuDfuDeviceAttrs attribute)
|
||||
* Returns: a new #FuDfuDevice
|
||||
**/
|
||||
FuDfuDevice *
|
||||
fu_dfu_device_new(GUsbDevice *usb_device)
|
||||
fu_dfu_device_new(FuContext *ctx, GUsbDevice *usb_device)
|
||||
{
|
||||
FuDfuDevice *self;
|
||||
self = g_object_new(FU_TYPE_DFU_DEVICE, "usb-device", usb_device, NULL);
|
||||
self = g_object_new(FU_TYPE_DFU_DEVICE, "usb-device", usb_device, "context", ctx, NULL);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ struct _FuDfuDeviceClass {
|
||||
};
|
||||
|
||||
FuDfuDevice *
|
||||
fu_dfu_device_new(GUsbDevice *usb_device);
|
||||
fu_dfu_device_new(FuContext *ctx, GUsbDevice *usb_device);
|
||||
const gchar *
|
||||
fu_dfu_device_get_platform_id(FuDfuDevice *self);
|
||||
GPtrArray *
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "fu-context-private.h"
|
||||
#include "fu-dfu-device.h"
|
||||
#include "fu-dfu-sector.h"
|
||||
#include "fu-dfu-target-private.h"
|
||||
@ -64,7 +65,8 @@ fu_dfu_target_dfuse_func(void)
|
||||
{
|
||||
gboolean ret;
|
||||
gchar *tmp;
|
||||
g_autoptr(FuDfuDevice) device = fu_dfu_device_new(NULL);
|
||||
g_autoptr(FuContext) ctx = fu_context_new();
|
||||
g_autoptr(FuDfuDevice) device = fu_dfu_device_new(ctx, NULL);
|
||||
g_autoptr(FuDfuTarget) target = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
|
@ -180,7 +180,6 @@ fu_dfu_tool_get_default_device(FuDfuTool *self, GError **error)
|
||||
gchar *tmp;
|
||||
guint64 pid;
|
||||
guint64 vid;
|
||||
g_autoptr(FuDfuDevice) device = NULL;
|
||||
g_autoptr(GUsbDevice) usb_device = NULL;
|
||||
|
||||
/* parse */
|
||||
@ -220,17 +219,14 @@ fu_dfu_tool_get_default_device(FuDfuTool *self, GError **error)
|
||||
(guint)pid);
|
||||
return NULL;
|
||||
}
|
||||
device = fu_dfu_device_new(usb_device);
|
||||
fu_device_set_context(FU_DEVICE(device), self->ctx);
|
||||
return g_steal_pointer(&device);
|
||||
return fu_dfu_device_new(self->ctx, usb_device);
|
||||
}
|
||||
|
||||
/* auto-detect first device */
|
||||
devices = g_usb_context_get_devices(self->usb_context);
|
||||
for (guint i = 0; i < devices->len; i++) {
|
||||
GUsbDevice *usb_device = g_ptr_array_index(devices, i);
|
||||
g_autoptr(FuDfuDevice) device = fu_dfu_device_new(usb_device);
|
||||
fu_device_set_context(FU_DEVICE(device), self->ctx);
|
||||
g_autoptr(FuDfuDevice) device = fu_dfu_device_new(self->ctx, usb_device);
|
||||
if (fu_device_probe(FU_DEVICE(device), NULL))
|
||||
return g_steal_pointer(&device);
|
||||
}
|
||||
|
@ -149,7 +149,6 @@ fu_plugin_flashrom_coldplug(FuPlugin *plugin, GError **error)
|
||||
const gchar *dmi_vendor;
|
||||
g_autoptr(FuDevice) device = fu_flashrom_device_new(ctx);
|
||||
|
||||
fu_device_set_context(device, ctx);
|
||||
fu_device_set_name(device, fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME));
|
||||
fu_device_set_vendor(device, fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER));
|
||||
|
||||
|
@ -33,11 +33,9 @@ fu_plugin_thunderbolt_safe_kernel(FuPlugin *plugin, GError **error)
|
||||
static gboolean
|
||||
fu_plugin_thunderbolt_device_created(FuPlugin *plugin, FuDevice *dev, GError **error)
|
||||
{
|
||||
FuContext *ctx = fu_plugin_get_context(plugin);
|
||||
fu_plugin_add_rule(plugin,
|
||||
FU_PLUGIN_RULE_INHIBITS_IDLE,
|
||||
"thunderbolt requires device wakeup");
|
||||
fu_device_set_context(dev, ctx);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -706,7 +706,6 @@ fu_plugin_uefi_capsule_check_cod_support(GError **error)
|
||||
static gboolean
|
||||
fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, GError **error)
|
||||
{
|
||||
FuContext *ctx = fu_plugin_get_context(plugin);
|
||||
FuPluginData *data = fu_plugin_get_data(plugin);
|
||||
const gchar *str;
|
||||
gboolean has_fde = FALSE;
|
||||
@ -750,7 +749,6 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, GError **error)
|
||||
FuUefiDevice *dev = g_ptr_array_index(devices, i);
|
||||
g_autoptr(GError) error_device = NULL;
|
||||
|
||||
fu_device_set_context(FU_DEVICE(dev), ctx);
|
||||
if (data->esp != NULL)
|
||||
fu_uefi_device_set_esp(dev, data->esp);
|
||||
if (!fu_plugin_uefi_capsule_coldplug_device(plugin, dev, &error_device)) {
|
||||
|
Loading…
Reference in New Issue
Block a user