mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 05:17:31 +00:00
steelseries: Use FuDeviceLocker
This commit is contained in:
parent
92faae9a41
commit
5b4d7dce0a
@ -44,6 +44,7 @@ fu_plugin_steelseries_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_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
|
|
||||||
/* not the right kind of device */
|
/* not the right kind of device */
|
||||||
@ -67,7 +68,8 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get exclusive access */
|
/* get exclusive access */
|
||||||
if (!g_usb_device_open (usb_device, &error_local)) {
|
locker = fu_device_locker_new (usb_device, &error_local);
|
||||||
|
if (locker == NULL) {
|
||||||
g_warning ("failed to open device: %s", error_local->message);
|
g_warning ("failed to open device: %s", error_local->message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,7 +77,6 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx,
|
|||||||
G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER,
|
G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER,
|
||||||
&error_local)) {
|
&error_local)) {
|
||||||
g_warning ("failed to claim interface: %s", error_local->message);
|
g_warning ("failed to claim interface: %s", error_local->message);
|
||||||
g_usb_device_close (usb_device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +98,6 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx,
|
|||||||
&error_local);
|
&error_local);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
g_debug ("failed to do control transfer: %s", error_local->message);
|
g_debug ("failed to do control transfer: %s", error_local->message);
|
||||||
g_usb_device_close (usb_device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (actual_len != 32) {
|
if (actual_len != 32) {
|
||||||
@ -114,12 +114,10 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx,
|
|||||||
&error_local);
|
&error_local);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
g_debug ("failed to do EP1 transfer: %s", error_local->message);
|
g_debug ("failed to do EP1 transfer: %s", error_local->message);
|
||||||
g_usb_device_close (usb_device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (actual_len != 32) {
|
if (actual_len != 32) {
|
||||||
g_warning ("only read %" G_GSIZE_FORMAT "bytes", actual_len);
|
g_warning ("only read %" G_GSIZE_FORMAT "bytes", actual_len);
|
||||||
g_usb_device_close (usb_device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,11 +140,8 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx,
|
|||||||
G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER,
|
G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER,
|
||||||
&error_local)) {
|
&error_local)) {
|
||||||
g_warning ("failed to release interface: %s", error_local->message);
|
g_warning ("failed to release interface: %s", error_local->message);
|
||||||
g_usb_device_close (usb_device, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!g_usb_device_close (usb_device, &error_local))
|
|
||||||
g_debug ("Failed to close: %s", error_local->message);
|
|
||||||
fu_plugin_device_add (plugin, dev);
|
fu_plugin_device_add (plugin, dev);
|
||||||
fu_plugin_cache_add (plugin, platform_id, dev);
|
fu_plugin_cache_add (plugin, platform_id, dev);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user