mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 02:54:47 +00:00
usb: Use FuDeviceLocker
This commit is contained in:
parent
7c52580f9c
commit
92faae9a41
@ -41,6 +41,7 @@ fu_plugin_usb_device_added_cb (GUsbContext *ctx,
|
|||||||
g_autoptr(AsProfile) profile = as_profile_new ();
|
g_autoptr(AsProfile) profile = as_profile_new ();
|
||||||
g_autoptr(AsProfileTask) ptask = NULL;
|
g_autoptr(AsProfileTask) ptask = NULL;
|
||||||
g_autoptr(FuDevice) dev = NULL;
|
g_autoptr(FuDevice) dev = NULL;
|
||||||
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
/* ignore hubs */
|
/* ignore hubs */
|
||||||
@ -60,7 +61,8 @@ fu_plugin_usb_device_added_cb (GUsbContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* try to get the version without claiming interface */
|
/* try to get the version without claiming interface */
|
||||||
if (!g_usb_device_open (device, &error)) {
|
locker = fu_device_locker_new (device, &error);
|
||||||
|
if (locker == NULL) {
|
||||||
g_debug ("Failed to open: %s", error->message);
|
g_debug ("Failed to open: %s", error->message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +81,6 @@ fu_plugin_usb_device_added_cb (GUsbContext *ctx,
|
|||||||
}
|
}
|
||||||
if (product == NULL) {
|
if (product == NULL) {
|
||||||
g_debug ("no product string descriptor");
|
g_debug ("no product string descriptor");
|
||||||
g_usb_device_close (device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fu_device_set_name (dev, product);
|
fu_device_set_name (dev, product);
|
||||||
@ -123,10 +124,6 @@ fu_plugin_usb_device_added_cb (GUsbContext *ctx,
|
|||||||
g_usb_device_get_release (device));
|
g_usb_device_get_release (device));
|
||||||
fu_device_add_guid (dev, devid2);
|
fu_device_add_guid (dev, devid2);
|
||||||
|
|
||||||
/* we're done here */
|
|
||||||
if (!g_usb_device_close (device, &error))
|
|
||||||
g_debug ("Failed to close: %s", error->message);
|
|
||||||
|
|
||||||
/* use a small delay for hotplugging so that other, better, plugins
|
/* use a small delay for hotplugging so that other, better, plugins
|
||||||
* can claim this interface and add the FuDevice */
|
* can claim this interface and add the FuDevice */
|
||||||
fu_plugin_device_add_delay (plugin, dev);
|
fu_plugin_device_add_delay (plugin, dev);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "fu-common.h"
|
#include "fu-common.h"
|
||||||
#include "fu-device.h"
|
#include "fu-device.h"
|
||||||
|
#include "fu-device-locker.h"
|
||||||
#include "fu-hwids.h"
|
#include "fu-hwids.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user