asix-sigma: Only download firmware when necessary

The Asix Sigma driver is aware of three firmware images, which are
required for acquisition with up to 50MHz, 100MHz, and 200MHz. The
previous implementation always downloaded the corresponding firmware
image whenever the sample rate has changed, which was redundant.

Skip the download when the new samplerate uses the same firmware as the
previously selected samplerate did. This results in faster responses in
the GUI when the samplerate selection changes.

Move assignments out of the variable declaration block for improved
readability while we are here.
This commit is contained in:
Gerhard Sittig 2017-05-25 19:47:31 +02:00 committed by Uwe Hermann
parent 85c032e485
commit a9016883f8
1 changed files with 10 additions and 2 deletions

View File

@ -442,10 +442,18 @@ static int upload_firmware(struct sr_context *ctx,
unsigned char *buf;
unsigned char pins;
size_t buf_size;
const char *firmware = sigma_firmware_files[firmware_idx];
struct ftdi_context *ftdic = &devc->ftdic;
const char *firmware;
struct ftdi_context *ftdic;
/* Avoid downloading the same firmware multiple times. */
firmware = sigma_firmware_files[firmware_idx];
if (devc->cur_firmware == firmware_idx) {
sr_info("Not uploading firmware file '%s' again.", firmware);
return SR_OK;
}
/* Make sure it's an ASIX SIGMA. */
ftdic = &devc->ftdic;
ret = ftdi_usb_open_desc(ftdic, USB_VENDOR, USB_PRODUCT,
USB_DESCRIPTION, NULL);
if (ret < 0) {