From 7bcf21683e6b8f77d55eaab7da5ea0bbe2949a6b Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 25 Jun 2017 12:01:43 +0200 Subject: [PATCH] asix-sigma: Propagate errors from firmware upload The firmware upload code paths in the asix-sigma driver used to return either the SR_OK code, or the magic number 0 for error conditions. Which happens to be identical and cannot be told apart by callers. Provide proper SR_ERR return codes for error conditions, such that callers can tell whether the firmware upload succeeded. This fixes part of bug #471. Suggested-By: Marian Cingel --- src/hardware/asix-sigma/protocol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 48de1b95..a81ec2f6 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -462,14 +462,14 @@ static int upload_firmware(struct sr_context *ctx, if (ret < 0) { sr_err("ftdi_usb_open failed: %s", ftdi_get_error_string(ftdic)); - return 0; + return SR_ERR; } ret = ftdi_set_bitmode(ftdic, 0xdf, BITMODE_BITBANG); if (ret < 0) { sr_err("ftdi_set_bitmode failed: %s", ftdi_get_error_string(ftdic)); - return 0; + return SR_ERR; } /* Four times the speed of sigmalogan - Works well. */ @@ -477,7 +477,7 @@ static int upload_firmware(struct sr_context *ctx, if (ret < 0) { sr_err("ftdi_set_baudrate failed: %s", ftdi_get_error_string(ftdic)); - return 0; + return SR_ERR; } /* Initialize the FPGA for firmware upload. */