vli-usbhub: Open the parent device before attempting to read or write from the child

This commit is contained in:
Richard Hughes 2019-11-22 12:24:30 +00:00
parent 6496f12b37
commit 233868124e
2 changed files with 20 additions and 0 deletions

View File

@ -110,6 +110,12 @@ fu_vli_usbhub_i2c_device_write_firmware (FuDevice *device,
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE (fu_device_get_parent (device));
GPtrArray *records = fu_ihex_firmware_get_records (FU_IHEX_FIRMWARE (firmware));
guint16 usbver = fu_usb_device_get_spec (FU_USB_DEVICE (device));
g_autoptr(FuDeviceLocker) locker = NULL;
/* open device */
locker = fu_device_locker_new (parent, error);
if (locker == NULL)
return FALSE;
/* transfer by I²C write, and check status by I²C read */
fu_device_set_status (device, FWUPD_STATUS_DEVICE_WRITE);

View File

@ -125,7 +125,15 @@ fu_vli_usbhub_pd_device_read_firmware (FuDevice *device, GError **error)
{
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE (fu_device_get_parent (device));
FuVliUsbhubPdDevice *self = FU_VLI_USBHUB_PD_DEVICE (device);
g_autoptr(FuDeviceLocker) locker = NULL;
g_autoptr(GBytes) fw = NULL;
/* open device */
locker = fu_device_locker_new (parent, error);
if (locker == NULL)
return FALSE;
/* read */
fu_device_set_status (FU_DEVICE (device), FWUPD_STATUS_DEVICE_VERIFY);
fw = fu_vli_usbhub_device_spi_read (parent,
fu_vli_usbhub_pd_chip_get_offset (self->chip),
@ -146,6 +154,7 @@ fu_vli_usbhub_pd_device_write_firmware (FuDevice *device,
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE (fu_device_get_parent (device));
gsize bufsz = 0;
const guint8 *buf;
g_autoptr(FuDeviceLocker) locker = NULL;
g_autoptr(GBytes) fw = NULL;
/* simple image */
@ -153,6 +162,11 @@ fu_vli_usbhub_pd_device_write_firmware (FuDevice *device,
if (fw == NULL)
return FALSE;
/* open device */
locker = fu_device_locker_new (parent, error);
if (locker == NULL)
return FALSE;
/* erase */
fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE);
buf = g_bytes_get_data (fw, &bufsz);