mirror of
https://git.proxmox.com/git/fwupd
synced 2025-06-14 01:09:36 +00:00
Never overwrite GUsbDevice properties
Getting the string indexes from the hardware is not cheap, and also triggers a warning from the fwupd daemon.
This commit is contained in:
parent
634e9228f8
commit
94e94eb976
@ -86,6 +86,7 @@ FuDevice *fu_device_new (void);
|
||||
#define fu_device_get_plugin(d) fwupd_device_get_plugin(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_update_error(d) fwupd_device_get_update_error(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_update_state(d) fwupd_device_get_update_state(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_vendor(d) fwupd_device_get_vendor(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version(d) fwupd_device_get_version(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version_lowest(d) fwupd_device_get_version_lowest(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version_bootloader(d) fwupd_device_get_version_bootloader(FWUPD_DEVICE(d))
|
||||
|
@ -133,7 +133,6 @@ fu_usb_device_open (FuUsbDevice *device, GError **error)
|
||||
{
|
||||
FuUsbDevicePrivate *priv = GET_PRIVATE (device);
|
||||
FuUsbDeviceClass *klass = FU_USB_DEVICE_GET_CLASS (device);
|
||||
guint idx;
|
||||
g_autoptr(AsProfile) profile = as_profile_new ();
|
||||
g_autoptr(AsProfileTask) ptask = NULL;
|
||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||
@ -158,45 +157,55 @@ fu_usb_device_open (FuUsbDevice *device, GError **error)
|
||||
return FALSE;
|
||||
|
||||
/* get vendor */
|
||||
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 (FU_DEVICE (device), tmp);
|
||||
if (fu_device_get_vendor (FU_DEVICE (device)) == NULL) {
|
||||
guint 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 (FU_DEVICE (device), tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/* get product */
|
||||
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 (FU_DEVICE (device), tmp);
|
||||
if (fu_device_get_name (FU_DEVICE (device)) == NULL) {
|
||||
guint 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 (FU_DEVICE (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 (FU_DEVICE (device), tmp);
|
||||
if (fu_device_get_version (FU_DEVICE (device)) == NULL) {
|
||||
guint idx;
|
||||
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 (FU_DEVICE (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 (FU_DEVICE (device), tmp);
|
||||
if (fu_device_get_guid_default (FU_DEVICE (device)) == NULL) {
|
||||
guint idx;
|
||||
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 (FU_DEVICE (device), tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/* subclassed */
|
||||
|
Loading…
Reference in New Issue
Block a user