mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 13:59:15 +00:00
corsair: improve subdevice handling
* add IN endpoint flushing for a subdevice * don't check for a subdevice if in bootloader mode * add delay for a first subdevice check to prevent unneeded polling
This commit is contained in:
parent
e5d489f680
commit
4b242efe91
@ -19,6 +19,7 @@
|
|||||||
#define CORSAIR_SUBDEVICE_REBOOT_DELAY (4 * G_USEC_PER_SEC)
|
#define CORSAIR_SUBDEVICE_REBOOT_DELAY (4 * G_USEC_PER_SEC)
|
||||||
#define CORSAIR_SUBDEVICE_RECONNECT_RETRIES 30
|
#define CORSAIR_SUBDEVICE_RECONNECT_RETRIES 30
|
||||||
#define CORSAIR_SUBDEVICE_RECONNECT_PERIOD 1000
|
#define CORSAIR_SUBDEVICE_RECONNECT_PERIOD 1000
|
||||||
|
#define CORSAIR_SUBDEVICE_FIRST_POLL_DELAY (2 * G_USEC_PER_SEC)
|
||||||
|
|
||||||
struct _FuCorsairDevice {
|
struct _FuCorsairDevice {
|
||||||
FuUsbDevice parent_instance;
|
FuUsbDevice parent_instance;
|
||||||
@ -198,7 +199,6 @@ fu_corsair_device_setup(FuDevice *device, GError **error)
|
|||||||
g_autofree gchar *version = NULL;
|
g_autofree gchar *version = NULL;
|
||||||
FuCorsairDevice *self = FU_CORSAIR_DEVICE(device);
|
FuCorsairDevice *self = FU_CORSAIR_DEVICE(device);
|
||||||
|
|
||||||
if (!fu_device_has_private_flag(device, FU_CORSAIR_DEVICE_FLAG_IS_SUBDEVICE))
|
|
||||||
fu_corsair_bp_flush_input_reports(self->bp);
|
fu_corsair_bp_flush_input_reports(self->bp);
|
||||||
|
|
||||||
if (!fu_corsair_bp_get_property(self->bp, FU_CORSAIR_BP_PROPERTY_MODE, &mode, error))
|
if (!fu_corsair_bp_get_property(self->bp, FU_CORSAIR_BP_PROPERTY_MODE, &mode, error))
|
||||||
@ -238,12 +238,19 @@ fu_corsair_device_setup(FuDevice *device, GError **error)
|
|||||||
fu_device_add_flag(device, FWUPD_DEVICE_FLAG_UPDATABLE);
|
fu_device_add_flag(device, FWUPD_DEVICE_FLAG_UPDATABLE);
|
||||||
|
|
||||||
/* check for a subdevice */
|
/* check for a subdevice */
|
||||||
if (self->subdevice_id != NULL) {
|
if (self->subdevice_id != NULL &&
|
||||||
|
!fu_device_has_flag(device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) {
|
||||||
gboolean subdevice_added = FALSE;
|
gboolean subdevice_added = FALSE;
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
|
|
||||||
|
/* Give some time to a subdevice to get connected to the receiver.
|
||||||
|
* Without this delay a subdevice may be not present even if it is
|
||||||
|
* turned on. */
|
||||||
|
g_usleep(CORSAIR_SUBDEVICE_FIRST_POLL_DELAY);
|
||||||
if (!fu_corsair_poll_subdevice(device, &subdevice_added, &local_error)) {
|
if (!fu_corsair_poll_subdevice(device, &subdevice_added, &local_error)) {
|
||||||
g_warning("error polling subdevice: %s", local_error->message);
|
g_warning("error polling subdevice: %s", local_error->message);
|
||||||
} else {
|
} else {
|
||||||
|
/* start polling if a subdevice was not added */
|
||||||
if (!subdevice_added)
|
if (!subdevice_added)
|
||||||
fu_device_set_poll_interval(device, CORSAIR_SUBDEVICE_POLL_PERIOD);
|
fu_device_set_poll_interval(device, CORSAIR_SUBDEVICE_POLL_PERIOD);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user