From 1251cb3376f2f5383b06a47607358e6119d6f601 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 20 Jul 2022 16:12:26 +0100 Subject: [PATCH] amt: Connect to the interface during ->open() --- plugins/amt/fu-amt-device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/amt/fu-amt-device.c b/plugins/amt/fu-amt-device.c index a68926215..1b2df815e 100644 --- a/plugins/amt/fu-amt-device.c +++ b/plugins/amt/fu-amt-device.c @@ -269,6 +269,15 @@ fu_amt_device_get_provisioning_state(FuAmtDevice *self, guint8 *state, GError ** return TRUE; } +static gboolean +fu_amt_device_open(FuDevice *device, GError **error) +{ + /* open then create context */ + if (!FU_DEVICE_CLASS(fu_amt_device_parent_class)->open(device, error)) + return FALSE; + return fu_mei_device_connect(FU_MEI_DEVICE(device), FU_AMT_DEVICE_MEI_IAMTHIF, 0, error); +} + static gboolean fu_amt_device_setup(FuDevice *device, GError **error) { @@ -279,10 +288,6 @@ fu_amt_device_setup(FuDevice *device, GError **error) g_autoptr(GString) version_bl = g_string_new(NULL); g_autoptr(GString) version_fw = g_string_new(NULL); - /* create context */ - if (!fu_mei_device_connect(FU_MEI_DEVICE(self), FU_AMT_DEVICE_MEI_IAMTHIF, 0, error)) - return FALSE; - /* check version */ if (!fu_amt_device_host_if_call(self, (const guchar *)&CODE_VERSION_REQ, @@ -365,5 +370,6 @@ static void fu_amt_device_class_init(FuAmtDeviceClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS(klass); + klass_device->open = fu_amt_device_open; klass_device->setup = fu_amt_device_setup; }