From: Lars-Peter Clausen Date: Mon, 25 Jun 2012 21:51:38 +0000 (+0200) Subject: sr: fx2lafw: Move empty_transfer_count to device ctx X-Git-Tag: dsupstream~890 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2769eed9917aeb6e549b90be4925a4c192a92309;p=libsigrok.git sr: fx2lafw: Move empty_transfer_count to device ctx If one device is failing it should not affect the transfers of other devices. Signed-off-by: Lars-Peter Clausen --- diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index 90434796..53a2e09f 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -708,8 +708,6 @@ static void resubmit_transfer(struct libusb_transfer *transfer) static void receive_transfer(struct libusb_transfer *transfer) { - /* TODO: These statics have to move to the ctx struct. */ - static int empty_transfer_count = 0; gboolean packet_has_error = FALSE; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; @@ -747,8 +745,8 @@ static void receive_transfer(struct libusb_transfer *transfer) } if (transfer->actual_length == 0 || packet_has_error) { - empty_transfer_count++; - if (empty_transfer_count > MAX_EMPTY_TRANSFERS) { + ctx->empty_transfer_count++; + if (ctx->empty_transfer_count > MAX_EMPTY_TRANSFERS) { /* * The FX2 gave up. End the acquisition, the frontend * will work out that the samplecount is short. @@ -760,7 +758,7 @@ static void receive_transfer(struct libusb_transfer *transfer) } return; } else { - empty_transfer_count = 0; + ctx->empty_transfer_count = 0; } trigger_offset = 0; @@ -902,6 +900,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data) ctx = sdi->priv; ctx->session_dev_id = cb_data; ctx->num_samples = 0; + ctx->empty_transfer_count = 0; const unsigned int timeout = get_timeout(ctx); const unsigned int num_transfers = get_number_of_transfers(ctx); diff --git a/hardware/fx2lafw/fx2lafw.h b/hardware/fx2lafw/fx2lafw.h index c6ad3ce1..727c0fa6 100644 --- a/hardware/fx2lafw/fx2lafw.h +++ b/hardware/fx2lafw/fx2lafw.h @@ -84,6 +84,7 @@ struct context { int num_samples; int submitted_transfers; + int empty_transfer_count; void *session_dev_id;