gboolean fu_plugin_update (FuPlugin *plugin, FuDevice *device, GBytes *blob_fw, FwupdInstallFlags flags, GError **error) { FuDevice *parent = fu_device_get_parent (device); g_autoptr(FuDeviceLocker) locker = NULL; locker = fu_device_locker_new (parent != NULL ? parent : device, error); if (locker == NULL) return FALSE; return fu_device_write_firmware (device, blob_fw, error); }
gboolean fu_plugin_usb_device_added (FuPlugin *plugin, FuUsbDevice *device, GError **error) { g_autoptr(FuWacDevice) dev = NULL; g_autoptr(FuDeviceLocker) locker = NULL; dev = fu_wac_device_new (device); locker = fu_device_locker_new (dev, error); if (locker == NULL) return FALSE; fu_plugin_device_add (plugin, FU_DEVICE (dev)); return TRUE; }
gboolean fu_plugin_update_reload (FuPlugin *plugin, FuDevice *device, GError **error) { FuColorhugDevice *self = FU_COLORHUG_DEVICE (device); g_autoptr(FuDeviceLocker) locker = NULL; /* also set flash success */ locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; if (!fu_colorhug_device_set_flash_success (self, TRUE, error)) return FALSE; return TRUE; }
gboolean fu_plugin_update (FuPlugin *plugin, FuDevice *device, GBytes *blob_fw, FwupdInstallFlags flags, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; /* write firmware */ locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; return fu_device_write_firmware (device, blob_fw, error); }
gboolean fu_plugin_usb_device_added (FuPlugin *plugin, FuUsbDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuRts54HubDevice) dev = NULL; /* open the device */ dev = fu_rts54hub_device_new (device); locker = fu_device_locker_new (dev, error); if (locker == NULL) return FALSE; /* success */ fu_plugin_device_add (plugin, FU_DEVICE (dev)); return TRUE; }
gboolean fu_plugin_usb_device_added (FuPlugin *plugin, GUsbDevice *usb_device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuNitrokeyDevice) device = NULL; /* open the device */ device = fu_nitrokey_device_new (usb_device); locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; /* success */ fu_plugin_device_add (plugin, FU_DEVICE (device)); return TRUE; }
static gboolean fu_plugin_dell_dock_create_node (FuPlugin *plugin, FuDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; fu_device_set_quirks (device, fu_plugin_get_quirks (plugin)); locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; fu_plugin_device_add (plugin, device); return TRUE; }
gboolean fu_plugin_activate (FuPlugin *plugin, FuDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; if (!FU_IS_DELL_DOCK_EC (device)) { g_set_error_literal (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE, "Invalid device to activate"); return FALSE; } locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; return fu_device_activate (device, error); }
gboolean fu_plugin_usb_device_added (FuPlugin *plugin, FuUsbDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuColorhugDevice) dev = NULL; /* open the device */ dev = fu_colorhug_device_new (device); locker = fu_device_locker_new (dev, error); if (locker == NULL) return FALSE; /* insert to hash */ fu_plugin_device_add (plugin, FU_DEVICE (dev)); return TRUE; }
gboolean fu_plugin_composite_cleanup (FuPlugin *plugin, GPtrArray *devices, GError **error) { FuDevice *parent = fu_plugin_dell_dock_get_ec (devices); g_autoptr(FuDeviceLocker) locker = NULL; if (parent == NULL) return TRUE; locker = fu_device_locker_new (parent, error); if (locker == NULL) return FALSE; return fu_dell_dock_ec_reboot_dock (parent, error); }
static gboolean fu_altos_device_probe (FuDevice *device, GError **error) { FuAltosDevice *self = FU_ALTOS_DEVICE (device); GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (self)); /* bootloader uses tty */ if (self->kind == FU_ALTOS_DEVICE_KIND_BOOTLOADER) return fu_altos_device_probe_bootloader (self, error); /* get version */ if (self->kind == FU_ALTOS_DEVICE_KIND_CHAOSKEY) { const gchar *version_prefix = "ChaosKey-hw-1.0-sw-"; guint8 version_idx; g_autofree gchar *version = NULL; g_autoptr(FuDeviceLocker) locker = NULL; /* open */ locker = fu_device_locker_new (usb_device, error); if (locker == NULL) return FALSE; /* get string */ version_idx = g_usb_device_get_product_index (usb_device); version = g_usb_device_get_string_descriptor (usb_device, version_idx, error); if (version == NULL) return FALSE; if (!g_str_has_prefix (version, version_prefix)) { g_set_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "not a ChaosKey v1.0 device: %s", version); return FALSE; } fu_device_set_version (FU_DEVICE (self), version + 19); } /* success */ return TRUE; }
gboolean fu_plugin_composite_cleanup (FuPlugin *plugin, GPtrArray *devices, GError **error) { FuDevice *device = fu_plugin_wacom_usb_get_device (devices); g_autoptr(FuDeviceLocker) locker = NULL; /* not us */ if (device == NULL) return TRUE; /* reboot, which switches the boot index of the firmware */ locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; fu_device_set_status (device, FWUPD_STATUS_DEVICE_RESTART); return fu_wac_device_update_reset (FU_WAC_DEVICE (device), error); }
gboolean fu_plugin_usb_device_added (FuPlugin *plugin, FuUsbDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuDellDockHub) hub = fu_dell_dock_hub_new (device); FuDevice *fu_device = FU_DEVICE (hub); const gchar *key = NULL; locker = fu_device_locker_new (fu_device, error); if (locker == NULL) return FALSE; fu_plugin_device_add (plugin, fu_device); if (fu_device_has_custom_flag (fu_device, "has-bridge")) { g_autoptr(GError) error_local = NULL; /* only add the device with parent to cache */ key = fu_device_get_id (fu_device); if (fu_plugin_cache_lookup (plugin, key) != NULL) { g_debug ("Ignoring already added device %s", key); return TRUE; } fu_plugin_cache_add (plugin, key, fu_device); /* probe for extended devices */ if (!fu_plugin_dell_dock_probe (plugin, fu_device, &error_local)) { g_warning ("Failed to probe bridged devices for %s: %s", key, error_local->message); } } /* clear updatable flag if parent doesn't have it */ fu_dell_dock_clone_updatable (fu_device); return TRUE; }
gboolean fu_plugin_update (FuPlugin *plugin, FuDevice *dev, GBytes *blob_fw, FwupdInstallFlags flags, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; locker = fu_device_locker_new (dev, error); if (locker == NULL) return FALSE; fu_device_set_status (dev, FWUPD_STATUS_DEVICE_WRITE); if (!fu_device_write_firmware (dev, blob_fw, error)) { g_prefix_error (error, "failed to update %s: ", fu_device_get_name (dev)); return FALSE; } fu_device_set_status (dev, FWUPD_STATUS_DEVICE_RESTART); return TRUE; }
gboolean fu_plugin_update_attach (FuPlugin *plugin, FuDevice *device, GError **error) { g_autoptr(FuDeviceLocker) locker = NULL; /* open device */ locker = fu_device_locker_new (device, error); if (locker == NULL) return FALSE; /* switch to runtime mode is not required */ if (!fu_device_has_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) { g_debug ("already in runtime mode, skipping"); return TRUE; } /* reset */ if (!fu_device_attach (device, error)) return FALSE; /* wait for replug */ fu_device_add_flag (device, FWUPD_DEVICE_FLAG_WAIT_FOR_REPLUG); return TRUE; }
static gboolean fu_usb_device_open (FuDevice *device, GError **error) { FuUsbDevice *self = FU_USB_DEVICE (device); FuUsbDevicePrivate *priv = GET_PRIVATE (self); FuUsbDeviceClass *klass = FU_USB_DEVICE_GET_CLASS (device); guint idx; g_autoptr(FuDeviceLocker) locker = NULL; g_return_val_if_fail (FU_IS_USB_DEVICE (self), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); /* already open */ if (priv->usb_device_locker != NULL) return TRUE; /* open */ locker = fu_device_locker_new (priv->usb_device, error); if (locker == NULL) return FALSE; /* get vendor */ if (fu_device_get_vendor (device) == NULL) { idx = g_usb_device_get_manufacturer_index (priv->usb_device); if (idx != 0x00) { g_autofree gchar *tmp = NULL; tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, error); if (tmp == NULL) return FALSE; fu_device_set_vendor (device, tmp); } } /* get product */ if (fu_device_get_name (device) == NULL) { idx = g_usb_device_get_product_index (priv->usb_device); if (idx != 0x00) { g_autofree gchar *tmp = NULL; tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, error); if (tmp == NULL) return FALSE; fu_device_set_name (device, tmp); } } /* get serial number */ if (fu_device_get_serial (device) == NULL) { idx = g_usb_device_get_serial_number_index (priv->usb_device); if (idx != 0x00) { g_autofree gchar *tmp = NULL; tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, error); if (tmp == NULL) return FALSE; fu_device_set_serial (device, tmp); } } /* get version number, falling back to the USB device release */ idx = g_usb_device_get_custom_index (priv->usb_device, G_USB_DEVICE_CLASS_VENDOR_SPECIFIC, 'F', 'W', NULL); if (idx != 0x00) { g_autofree gchar *tmp = NULL; tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, NULL); fu_device_set_version (device, tmp); } /* get GUID from the descriptor if set */ idx = g_usb_device_get_custom_index (priv->usb_device, G_USB_DEVICE_CLASS_VENDOR_SPECIFIC, 'G', 'U', NULL); if (idx != 0x00) { g_autofree gchar *tmp = NULL; tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, NULL); fu_device_add_guid (device, tmp); } /* subclassed */ if (klass->open != NULL) { if (!klass->open (self, error)) return FALSE; } /* success */ priv->usb_device_locker = g_steal_pointer (&locker); return TRUE; }