From 5b4d7dce0a72c5c12dec77f8fe792693bed7097f Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Thu, 7 Sep 2017 10:15:35 +0100 Subject: [PATCH] steelseries: Use FuDeviceLocker --- plugins/steelseries/fu-plugin-steelseries.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/plugins/steelseries/fu-plugin-steelseries.c b/plugins/steelseries/fu-plugin-steelseries.c index 1e8d3e9ed..9b6fdf318 100644 --- a/plugins/steelseries/fu-plugin-steelseries.c +++ b/plugins/steelseries/fu-plugin-steelseries.c @@ -44,6 +44,7 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, g_autoptr(AsProfile) profile = as_profile_new (); g_autoptr(AsProfileTask) ptask = NULL; g_autoptr(FuDevice) dev = NULL; + g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(GError) error_local = NULL; /* not the right kind of device */ @@ -67,7 +68,8 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, } /* 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); return; } @@ -75,7 +77,6 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER, &error_local)) { g_warning ("failed to claim interface: %s", error_local->message); - g_usb_device_close (usb_device, NULL); return; } @@ -97,7 +98,6 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, &error_local); if (!ret) { g_debug ("failed to do control transfer: %s", error_local->message); - g_usb_device_close (usb_device, NULL); return; } if (actual_len != 32) { @@ -114,12 +114,10 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, &error_local); if (!ret) { g_debug ("failed to do EP1 transfer: %s", error_local->message); - g_usb_device_close (usb_device, NULL); return; } if (actual_len != 32) { g_warning ("only read %" G_GSIZE_FORMAT "bytes", actual_len); - g_usb_device_close (usb_device, NULL); return; } @@ -142,11 +140,8 @@ fu_plugin_steelseries_device_added_cb (GUsbContext *ctx, G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER, &error_local)) { g_warning ("failed to release interface: %s", error_local->message); - g_usb_device_close (usb_device, NULL); 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_cache_add (plugin, platform_id, dev); }