diff --git a/plugins/ata/fu-ata-device.c b/plugins/ata/fu-ata-device.c index 0cddc2267..91ba9ded2 100644 --- a/plugins/ata/fu-ata-device.c +++ b/plugins/ata/fu-ata-device.c @@ -813,6 +813,7 @@ fu_ata_device_write_firmware(FuDevice *device, /* write each block */ fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_WRITE); chunks = fu_chunk_array_new_from_bytes(fw, 0x00, 0x00, chunksz); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); if (!fu_ata_device_fw_download(self, @@ -824,7 +825,7 @@ fu_ata_device_write_firmware(FuDevice *device, g_prefix_error(error, "failed to write chunk %u: ", i); return FALSE; } - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } /* success! */ diff --git a/plugins/bcm57xx/fu-bcm57xx-recovery-device.c b/plugins/bcm57xx/fu-bcm57xx-recovery-device.c index 9b035460e..f2f408a95 100644 --- a/plugins/bcm57xx/fu-bcm57xx-recovery-device.c +++ b/plugins/bcm57xx/fu-bcm57xx-recovery-device.c @@ -344,6 +344,7 @@ fu_bcm57xx_recovery_device_nvram_read(FuBcm57xxRecoveryDevice *self, FuProgress *progress, GError **error) { + fu_progress_set_steps(progress, bufsz); for (guint i = 0; i < bufsz; i++) { BcmRegNVMCommand tmp = {0}; guint32 val32 = 0; @@ -377,7 +378,7 @@ fu_bcm57xx_recovery_device_nvram_read(FuBcm57xxRecoveryDevice *self, return FALSE; buf[i] = GUINT32_FROM_BE(val32); address += sizeof(guint32); - fu_progress_set_percentage_full(progress, i + 1, bufsz); + fu_progress_step_done(progress); } /* success */ @@ -405,6 +406,7 @@ fu_bcm57xx_recovery_device_nvram_write(FuBcm57xxRecoveryDevice *self, return FALSE; } + fu_progress_set_steps(progress, bufsz_dwrds); for (guint i = 0; i < bufsz_dwrds; i++) { BcmRegNVMCommand tmp = {0}; if (!fu_bcm57xx_recovery_device_nvram_clear_done(self, error)) @@ -436,7 +438,7 @@ fu_bcm57xx_recovery_device_nvram_write(FuBcm57xxRecoveryDevice *self, return FALSE; } address += sizeof(guint32); - fu_progress_set_percentage_full(progress, i + 1, bufsz_dwrds); + fu_progress_step_done(progress); } /* success */ diff --git a/plugins/dfu-csr/fu-dfu-csr-device.c b/plugins/dfu-csr/fu-dfu-csr-device.c index 41c3d447c..06fda7c95 100644 --- a/plugins/dfu-csr/fu-dfu-csr-device.c +++ b/plugins/dfu-csr/fu-dfu-csr-device.c @@ -371,6 +371,7 @@ fu_dfu_csr_device_download(FuDevice *device, FU_DFU_CSR_COMMAND_HEADER_SIZE); /* send to hardware */ + fu_progress_set_steps(progress, chunks->len); for (idx = 0; idx < chunks->len; idx++) { FuChunk *chk = g_ptr_array_index(chunks, idx); g_autoptr(GBytes) blob_tmp = fu_chunk_get_bytes(chk); @@ -380,7 +381,7 @@ fu_dfu_csr_device_download(FuDevice *device, return FALSE; /* update progress */ - fu_progress_set_percentage_full(progress, (gsize)idx + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } /* all done */ diff --git a/plugins/fastboot/fu-fastboot-device.c b/plugins/fastboot/fu-fastboot-device.c index 71cedcc58..69f203964 100644 --- a/plugins/fastboot/fu-fastboot-device.c +++ b/plugins/fastboot/fu-fastboot-device.c @@ -289,6 +289,7 @@ fu_fastboot_device_download(FuDevice *device, GBytes *fw, FuProgress *progress, 0x00, /* start addr */ 0x00, /* page_sz */ self->blocksz); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); if (!fu_fastboot_device_write(device, @@ -296,7 +297,7 @@ fu_fastboot_device_download(FuDevice *device, GBytes *fw, FuProgress *progress, fu_chunk_get_data_sz(chk), error)) return FALSE; - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } if (!fu_fastboot_device_read(device, NULL, diff --git a/plugins/hailuck/fu-hailuck-bl-device.c b/plugins/hailuck/fu-hailuck-bl-device.c index 9d8fb5b3a..87eec9369 100644 --- a/plugins/hailuck/fu-hailuck-bl-device.c +++ b/plugins/hailuck/fu-hailuck-bl-device.c @@ -118,6 +118,7 @@ fu_hailuck_bl_device_dump_firmware(FuDevice *device, FuProgress *progress, GErro /* receive data back */ fu_byte_array_set_size(fwbuf, fwsz); chunks = fu_chunk_array_mutable_new(fwbuf->data, fwbuf->len, 0x0, 0x0, 2048); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); if (!fu_hailuck_bl_device_read_block(self, @@ -125,7 +126,7 @@ fu_hailuck_bl_device_dump_firmware(FuDevice *device, FuProgress *progress, GErro fu_chunk_get_data_sz(chk), error)) return NULL; - fu_progress_set_percentage_full(progress, i + 1, chunks->len); + fu_progress_step_done(progress); } /* success */ diff --git a/plugins/superio/fu-superio-it55-device.c b/plugins/superio/fu-superio-it55-device.c index 135aa8ded..58f03ff63 100644 --- a/plugins/superio/fu-superio-it55-device.c +++ b/plugins/superio/fu-superio-it55-device.c @@ -236,6 +236,7 @@ fu_superio_it55_device_get_firmware(FuDevice *device, FuProgress *progress, GErr g_autofree guint8 *buf = NULL; buf = g_malloc0(fwsize); + fu_progress_set_steps(progress, block_count); for (guint i = 0; i < block_count; ++i) { if (!fu_superio_device_ec_write_cmd(self, SIO_CMD_EC_READ_BLOCK, error) || !fu_superio_device_ec_write_cmd(self, i, error)) @@ -244,9 +245,8 @@ fu_superio_it55_device_get_firmware(FuDevice *device, FuProgress *progress, GErr for (guint j = 0; j < BLOCK_SIZE; ++j, ++offset) { if (!fu_superio_device_ec_read_data(self, &buf[offset], error)) return NULL; - - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)block_count); } + fu_progress_step_done(progress); } return g_bytes_new_take(g_steal_pointer(&buf), fwsize); diff --git a/plugins/superio/fu-superio-it89-device.c b/plugins/superio/fu-superio-it89-device.c index 4793676f2..62651ddbb 100644 --- a/plugins/superio/fu-superio-it89-device.c +++ b/plugins/superio/fu-superio-it89-device.c @@ -254,6 +254,7 @@ fu_superio_it89_device_read_addr(FuSuperioDevice *self, /* read out data */ buf = g_malloc0(size); + fu_progress_set_steps(progress, size); for (guint i = 0; i < size; i++) { if (!fu_superio_device_ec_write_cmd(self, SIO_EC_PMC_PM1DI, error)) return NULL; @@ -261,7 +262,7 @@ fu_superio_it89_device_read_addr(FuSuperioDevice *self, return NULL; /* update progress */ - fu_progress_set_percentage_full(progress, (goffset)i, (goffset)size); + fu_progress_step_done(progress); } /* check again... */ diff --git a/plugins/synaptics-mst/fu-synaptics-mst-device.c b/plugins/synaptics-mst/fu-synaptics-mst-device.c index 232e6dad5..7f64b6765 100644 --- a/plugins/synaptics-mst/fu-synaptics-mst-device.c +++ b/plugins/synaptics-mst/fu-synaptics-mst-device.c @@ -348,6 +348,7 @@ fu_synaptics_mst_device_update_esm(FuSynapticsMstDevice *self, g_usleep(FLASH_SETTLE_TIME); /* write firmware */ + fu_progress_set_steps(progress, write_loops); for (guint32 i = 0; i < write_loops; i++) { g_autoptr(GError) error_local = NULL; if (!fu_synaptics_mst_connection_rc_set_command(connection, @@ -361,9 +362,7 @@ fu_synaptics_mst_device_update_esm(FuSynapticsMstDevice *self, } write_offset += unit_sz; write_idx += unit_sz; - fu_progress_set_percentage_full(progress, - (goffset)i + 1, - (goffset)write_loops); + fu_progress_step_done(progress); } /* check ESM checksum */ @@ -428,6 +427,7 @@ fu_synaptics_mst_device_update_tesla_leaf_firmware(FuSynapticsMstDevice *self, g_debug("Waiting for flash clear to settle"); g_usleep(FLASH_SETTLE_TIME); + fu_progress_set_steps(progress, write_loops); for (guint32 i = 0; i < write_loops; i++) { g_autoptr(GError) error_local = NULL; guint8 length = BLOCK_UNIT; @@ -459,9 +459,7 @@ fu_synaptics_mst_device_update_tesla_leaf_firmware(FuSynapticsMstDevice *self, } offset += length; data_to_write -= length; - fu_progress_set_percentage_full(progress, - (goffset)i + 1, - (goffset)write_loops); + fu_progress_step_done(progress); } /* check data just written */ @@ -587,6 +585,7 @@ fu_synaptics_mst_device_update_panamera_firmware(FuSynapticsMstDevice *self, fu_synaptics_mst_connection_new(fu_udev_device_get_fd(FU_UDEV_DEVICE(self)), self->layer, self->rad); + fu_progress_set_steps(progress, write_loops); for (guint32 i = 0; i < write_loops; i++) { g_autoptr(GError) error_local = NULL; if (!fu_synaptics_mst_connection_rc_set_command(connection, @@ -611,9 +610,7 @@ fu_synaptics_mst_device_update_panamera_firmware(FuSynapticsMstDevice *self, write_offset += unit_sz; write_idx += unit_sz; - fu_progress_set_percentage_full(progress, - (goffset)i + 1, - (goffset)write_loops); + fu_progress_step_done(progress); } /* verify CRC */ @@ -878,6 +875,7 @@ fu_synaptics_mst_device_update_cayenne_firmware(FuSynapticsMstDevice *self, g_debug("Waiting for flash clear to settle"); g_usleep(FLASH_SETTLE_TIME); + fu_progress_set_steps(progress, write_loops); for (guint32 i = 0; i < write_loops; i++) { g_autoptr(GError) error_local = NULL; guint8 length = BLOCK_UNIT; @@ -909,9 +907,7 @@ fu_synaptics_mst_device_update_cayenne_firmware(FuSynapticsMstDevice *self, } offset += length; data_to_write -= length; - fu_progress_set_percentage_full(progress, - (goffset)i * 100, - (goffset)(write_loops - 1) * 100); + fu_progress_step_done(progress); } /* verify CRC */ diff --git a/plugins/synaptics-rmi/fu-synaptics-rmi-v5-device.c b/plugins/synaptics-rmi/fu-synaptics-rmi-v5-device.c index 1e67be8e3..3a6d6e240 100644 --- a/plugins/synaptics-rmi/fu-synaptics-rmi-v5-device.c +++ b/plugins/synaptics-rmi/fu-synaptics-rmi-v5-device.c @@ -408,6 +408,7 @@ fu_synaptics_rmi_v5_device_write_firmware(FuDevice *device, g_prefix_error(error, "failed to write 1st address zero: "); return FALSE; } + fu_progress_set_steps(progress, chunks_sig->len); for (guint i = 0; i < chunks_sig->len; i++) { FuChunk *chk = g_ptr_array_index(chunks_sig, i); if (!fu_synaptics_rmi_v5_device_write_block(self, @@ -421,9 +422,7 @@ fu_synaptics_rmi_v5_device_write_firmware(FuDevice *device, fu_chunk_get_idx(chk)); return FALSE; } - fu_progress_set_percentage_full(progress, - (gsize)i + 1, - (gsize)chunks_sig->len); + fu_progress_step_done(progress); } g_usleep(1000 * 1000); } diff --git a/plugins/synaptics-rmi/fu-synaptics-rmi-v7-device.c b/plugins/synaptics-rmi/fu-synaptics-rmi-v7-device.c index 0f6ecd34d..fa312debb 100644 --- a/plugins/synaptics-rmi/fu-synaptics-rmi-v7-device.c +++ b/plugins/synaptics-rmi/fu-synaptics-rmi-v7-device.c @@ -294,6 +294,7 @@ fu_synaptics_rmi_v7_device_write_partition(FuSynapticsRmiDevice *self, 0x00, /* start addr */ 0x00, /* page_sz */ (gsize)flash->payload_length * (gsize)flash->block_size); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); g_autoptr(GByteArray) req_trans_sz = g_byte_array_new(); @@ -324,7 +325,7 @@ fu_synaptics_rmi_v7_device_write_partition(FuSynapticsRmiDevice *self, fu_chunk_get_data_sz(chk), error)) return FALSE; - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } return TRUE; } diff --git a/plugins/vli/fu-vli-device.c b/plugins/vli/fu-vli-device.c index fb1887920..6cd2efbb9 100644 --- a/plugins/vli/fu-vli-device.c +++ b/plugins/vli/fu-vli-device.c @@ -217,6 +217,7 @@ fu_vli_device_spi_read(FuVliDevice *self, /* get data from hardware */ chunks = fu_chunk_array_mutable_new(buf, bufsz, address, 0x0, FU_VLI_DEVICE_TXSIZE); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); if (!fu_vli_device_spi_read_block(self, @@ -229,7 +230,7 @@ fu_vli_device_spi_read(FuVliDevice *self, fu_chunk_get_address(chk)); return NULL; } - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } return g_bytes_new_take(g_steal_pointer(&buf), bufsz); } @@ -384,6 +385,7 @@ fu_vli_device_spi_erase(FuVliDevice *self, { g_autoptr(GPtrArray) chunks = fu_chunk_array_new(NULL, sz, addr, 0x0, 0x1000); g_debug("erasing 0x%x bytes @0x%x", (guint)sz, addr); + fu_progress_set_steps(progress, chunks->len); for (guint i = 0; i < chunks->len; i++) { FuChunk *chk = g_ptr_array_index(chunks, i); if (g_getenv("FWUPD_VLI_USBHUB_VERBOSE") != NULL) @@ -396,7 +398,7 @@ fu_vli_device_spi_erase(FuVliDevice *self, fu_chunk_get_address(chk)); return FALSE; } - fu_progress_set_percentage_full(progress, (gsize)i + 1, (gsize)chunks->len); + fu_progress_step_done(progress); } return TRUE; } diff --git a/plugins/vli/fu-vli-pd-parade-device.c b/plugins/vli/fu-vli-pd-parade-device.c index f2bbc7ce8..9cd9d27f1 100644 --- a/plugins/vli/fu-vli-pd-parade-device.c +++ b/plugins/vli/fu-vli-pd-parade-device.c @@ -649,6 +649,7 @@ fu_vli_pd_parade_device_dump_firmware(FuDevice *device, FuProgress *progress, GE fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_VERIFY); fu_byte_array_set_size(fw, fu_device_get_firmware_size_max(device)); blocks = fu_chunk_array_mutable_new(fw->data, fw->len, 0x0, 0x0, 0x10000); + fu_progress_set_steps(progress, blocks->len); for (guint i = 0; i < blocks->len; i++) { FuChunk *chk = g_ptr_array_index(blocks, i); if (!fu_vli_pd_parade_device_block_read(self, @@ -657,7 +658,7 @@ fu_vli_pd_parade_device_dump_firmware(FuDevice *device, FuProgress *progress, GE fu_chunk_get_data_sz(chk), error)) return NULL; - fu_progress_set_percentage_full(progress, i + 1, blocks->len); + fu_progress_step_done(progress); } return g_byte_array_free_to_bytes(g_steal_pointer(&fw)); } diff --git a/plugins/vli/fu-vli-usbhub-msp430-device.c b/plugins/vli/fu-vli-usbhub-msp430-device.c index 0e9cd2ca4..2826b160d 100644 --- a/plugins/vli/fu-vli-usbhub-msp430-device.c +++ b/plugins/vli/fu-vli-usbhub-msp430-device.c @@ -227,6 +227,7 @@ fu_vli_usbhub_msp430_device_write_firmware(FuDevice *device, /* transfer by I²C write, and check status by I²C read */ fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_WRITE); + fu_progress_set_steps(progress, records->len); for (guint j = 0; j < records->len; j++) { FuIhexFirmwareRecord *rcd = g_ptr_array_index(records, j); FuVliUsbhubDeviceRequest req = {0x0}; @@ -277,7 +278,7 @@ fu_vli_usbhub_msp430_device_write_firmware(FuDevice *device, &req, error)) return FALSE; - fu_progress_set_percentage_full(progress, (gsize)j + 1, (gsize)records->len); + fu_progress_step_done(progress); } /* the device automatically reboots */