mirror of
https://git.proxmox.com/git/fwupd
synced 2025-06-14 16:01:08 +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_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_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_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(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_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))
|
#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);
|
FuUsbDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
FuUsbDeviceClass *klass = FU_USB_DEVICE_GET_CLASS (device);
|
FuUsbDeviceClass *klass = FU_USB_DEVICE_GET_CLASS (device);
|
||||||
guint idx;
|
|
||||||
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(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
@ -158,45 +157,55 @@ fu_usb_device_open (FuUsbDevice *device, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* get vendor */
|
/* get vendor */
|
||||||
idx = g_usb_device_get_manufacturer_index (priv->usb_device);
|
if (fu_device_get_vendor (FU_DEVICE (device)) == NULL) {
|
||||||
if (idx != 0x00) {
|
guint idx = g_usb_device_get_manufacturer_index (priv->usb_device);
|
||||||
g_autofree gchar *tmp = NULL;
|
if (idx != 0x00) {
|
||||||
tmp = g_usb_device_get_string_descriptor (priv->usb_device,
|
g_autofree gchar *tmp = NULL;
|
||||||
idx, error);
|
tmp = g_usb_device_get_string_descriptor (priv->usb_device,
|
||||||
if (tmp == NULL)
|
idx, error);
|
||||||
return FALSE;
|
if (tmp == NULL)
|
||||||
fu_device_set_vendor (FU_DEVICE (device), tmp);
|
return FALSE;
|
||||||
|
fu_device_set_vendor (FU_DEVICE (device), tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get product */
|
/* get product */
|
||||||
idx = g_usb_device_get_product_index (priv->usb_device);
|
if (fu_device_get_name (FU_DEVICE (device)) == NULL) {
|
||||||
if (idx != 0x00) {
|
guint idx = g_usb_device_get_product_index (priv->usb_device);
|
||||||
g_autofree gchar *tmp = NULL;
|
if (idx != 0x00) {
|
||||||
tmp = g_usb_device_get_string_descriptor (priv->usb_device,
|
g_autofree gchar *tmp = NULL;
|
||||||
idx, error);
|
tmp = g_usb_device_get_string_descriptor (priv->usb_device,
|
||||||
if (tmp == NULL)
|
idx, error);
|
||||||
return FALSE;
|
if (tmp == NULL)
|
||||||
fu_device_set_name (FU_DEVICE (device), tmp);
|
return FALSE;
|
||||||
|
fu_device_set_name (FU_DEVICE (device), tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get version number, falling back to the USB device release */
|
/* get version number, falling back to the USB device release */
|
||||||
idx = g_usb_device_get_custom_index (priv->usb_device,
|
if (fu_device_get_version (FU_DEVICE (device)) == NULL) {
|
||||||
G_USB_DEVICE_CLASS_VENDOR_SPECIFIC,
|
guint idx;
|
||||||
'F', 'W', NULL);
|
idx = g_usb_device_get_custom_index (priv->usb_device,
|
||||||
if (idx != 0x00) {
|
G_USB_DEVICE_CLASS_VENDOR_SPECIFIC,
|
||||||
g_autofree gchar *tmp = NULL;
|
'F', 'W', NULL);
|
||||||
tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, NULL);
|
if (idx != 0x00) {
|
||||||
fu_device_set_version (FU_DEVICE (device), tmp);
|
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 */
|
/* get GUID from the descriptor if set */
|
||||||
idx = g_usb_device_get_custom_index (priv->usb_device,
|
if (fu_device_get_guid_default (FU_DEVICE (device)) == NULL) {
|
||||||
G_USB_DEVICE_CLASS_VENDOR_SPECIFIC,
|
guint idx;
|
||||||
'G', 'U', NULL);
|
idx = g_usb_device_get_custom_index (priv->usb_device,
|
||||||
if (idx != 0x00) {
|
G_USB_DEVICE_CLASS_VENDOR_SPECIFIC,
|
||||||
g_autofree gchar *tmp = NULL;
|
'G', 'U', NULL);
|
||||||
tmp = g_usb_device_get_string_descriptor (priv->usb_device, idx, NULL);
|
if (idx != 0x00) {
|
||||||
fu_device_add_guid (FU_DEVICE (device), tmp);
|
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 */
|
/* subclassed */
|
||||||
|
Loading…
Reference in New Issue
Block a user