]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw: Print device failed to renumerate error
authorAlexandru Gagniuc <redacted>
Thu, 6 Dec 2012 21:55:14 +0000 (15:55 -0600)
committerUwe Hermann <redacted>
Mon, 17 Dec 2012 23:48:56 +0000 (00:48 +0100)
commit 378abfeac6cc94d88dc82b8481dec9c9f691f3da tried to solve a bug where
the fx2lafw driver would print "Device came back" even if a timeout had occured.

It solved that issue, but inadvertently introduced a new bug:
"Device came back" would be printed even if no firmware upload was performed.
This is counterintuitive, as the device is only reset when a firmware upload is
performed.

There are three cases:
i)   Firmware upload was successful
ii)  Firmware upload failed
iii) Firmware upload was NOT needed

Each case warrants a separate message from the driver. Print the
following messages depending on the outcome:

i)   "Device came back"
ii)  "Device failed to renumerate"
iii) "Firmware upload was not needed."

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/fx2lafw/fx2lafw.c

index 8e5a10b20655f261259b64c6662b9d7aa649b341..22fff9275dd1c6155f5bb6e44083b3bd8da8be43 100644 (file)
@@ -542,16 +542,20 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
                        timediff_ms = timediff_us / 1000;
                        sr_spew("Waited %" PRIi64 " ms", timediff_ms);
                }
+               if (ret != SR_OK) {
+                       sr_err("Device failed to renumerate.");
+                       return SR_ERR;
+               }
+               sr_info("Device came back after %d ms.",
+                       timediff_ms);
        } else {
+               sr_info("Firmware upload was not needed.");
                ret = fx2lafw_dev_open(sdi);
        }
 
        if (ret != SR_OK) {
                sr_err("Unable to open device.");
                return SR_ERR;
-       } else {
-               sr_info("Device came back after %d ms.",
-                       timediff_ms);
        }
 
        devc = sdi->priv;