From: Uwe Hermann Date: Sun, 12 Feb 2012 12:31:58 +0000 (+0100) Subject: sr: stop_acquisition callback: Return int. X-Git-Tag: libsigrok-0.1.0~127 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3010f21c9170e9f235d49bc7b333d17677c70e5c;p=libsigrok.git sr: stop_acquisition callback: Return int. --- diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index 4c930e4f..e5fad8f5 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -379,11 +379,13 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) return SR_OK; } -static void hw_stop_acquisition(int device_index, gpointer session_device_id) +static int hw_stop_acquisition(int device_index, gpointer session_device_id) { /* Avoid compiler warnings. */ device_index = device_index; session_device_id = session_device_id; + + return SR_OK; } SR_PRIV struct sr_device_plugin alsa_plugin_info = { diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index f05bc4dc..5ed01407 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -118,7 +118,7 @@ static const char *firmware_files[] = { "asix-sigma-phasor.fw", /* Frequency counter */ }; -static void hw_stop_acquisition(int device_index, gpointer session_data); +static int hw_stop_acquisition(int device_index, gpointer session_data); static int sigma_read(void *buf, size_t size, struct sigma *sigma) { @@ -1362,20 +1362,25 @@ static int hw_start_acquisition(int device_index, gpointer session_data) return SR_OK; } -static void hw_stop_acquisition(int device_index, gpointer session_data) +static int hw_stop_acquisition(int device_index, gpointer session_data) { struct sr_device_instance *sdi; struct sigma *sigma; uint8_t modestatus; - if (!(sdi = sr_get_device_instance(device_instances, device_index))) - return; - - sigma = sdi->priv; - /* Avoid compiler warnings. */ (void)session_data; + if (!(sdi = sr_get_device_instance(device_instances, device_index))) { + sr_err("asix: %s: sdi was NULL", __func__); + return SR_ERR_BUG; + } + + if (!(sigma = sdi->priv)) { + sr_err("asix: %s: sdi->priv was NULL", __func__); + return SR_ERR_BUG; + } + /* Stop acquisition. */ sigma_set_register(WRITE_MODE, 0x11, sigma); @@ -1387,15 +1392,16 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) /* Check if trigger has fired. */ modestatus = sigma_get_register(READ_MODE, sigma); - if (modestatus & 0x20) { + if (modestatus & 0x20) sigma->state.triggerchunk = sigma->state.triggerpos / 512; - - } else + else sigma->state.triggerchunk = -1; sigma->state.chunks_downloaded = 0; sigma->state.state = SIGMA_DOWNLOAD; + + return SR_OK; } SR_PRIV struct sr_device_plugin asix_sigma_plugin_info = { diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index b0609f7e..23ac8c79 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -136,7 +136,7 @@ static int capabilities[] = { /* Function prototypes. */ static int la8_close_usb_reset_sequencer(struct la8 *la8); -static void hw_stop_acquisition(int device_index, gpointer session_data); +static int hw_stop_acquisition(int device_index, gpointer session_data); static int la8_reset(struct la8 *la8); static void fill_supported_samplerates_if_needed(void) @@ -1103,7 +1103,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) return SR_OK; } -static void hw_stop_acquisition(int device_index, gpointer session_data) +static int hw_stop_acquisition(int device_index, gpointer session_data) { struct sr_device_instance *sdi; struct la8 *la8; @@ -1113,18 +1113,20 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) if (!(sdi = sr_get_device_instance(device_instances, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); - return; + return SR_ERR_BUG; } if (!(la8 = sdi->priv)) { sr_err("la8: %s: sdi->priv was NULL", __func__); - return; + return SR_ERR_BUG; } /* Send end packet to the session bus. */ sr_dbg("la8: %s: sending SR_DF_END", __func__); packet.type = SR_DF_END; sr_session_bus(session_data, &packet); + + return SR_OK; } SR_PRIV struct sr_device_plugin chronovu_la8_plugin_info = { diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 8cfd1c89..5e0d44cf 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -134,7 +134,7 @@ static int default_pattern = PATTERN_SIGROK; static GThread *my_thread; static int thread_running; -static void hw_stop_acquisition(int device_index, gpointer session_data); +static int hw_stop_acquisition(int device_index, gpointer session_data); static int hw_init(const char *deviceinfo) { @@ -476,7 +476,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) return SR_OK; } -static void hw_stop_acquisition(int device_index, gpointer session_data) +static int hw_stop_acquisition(int device_index, gpointer session_data) { /* Avoid compiler warnings. */ (void)device_index; @@ -484,6 +484,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) /* Stop generate thread. */ thread_running = 0; + + return SR_OK; } SR_PRIV struct sr_device_plugin demo_plugin_info = { diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index 7e8e797f..b3a5667f 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -816,7 +816,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) } /* FIXME */ -static void hw_stop_acquisition(int device_index, gpointer session_device_id) +static int hw_stop_acquisition(int device_index, gpointer session_device_id) { struct sr_datafeed_packet packet; @@ -824,6 +824,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id) packet.type = SR_DF_END; sr_session_bus(session_device_id, &packet); + + return SR_OK; } SR_PRIV struct sr_device_plugin link_mso19_plugin_info = { diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index d71c0251..930d0085 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -1010,7 +1010,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) return SR_OK; } -static void hw_stop_acquisition(int device_index, gpointer session_device_id) +static int hw_stop_acquisition(int device_index, gpointer session_device_id) { struct sr_datafeed_packet packet; @@ -1019,6 +1019,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id) packet.type = SR_DF_END; sr_session_bus(session_device_id, &packet); + + return SR_OK; } SR_PRIV struct sr_device_plugin ols_plugin_info = { diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index bde17d75..14477496 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -94,7 +94,7 @@ static libusb_context *usb_context = NULL; static int new_saleae_logic_firmware = 0; static int hw_set_configuration(int device_index, int capability, void *value); -static void hw_stop_acquisition(int device_index, gpointer session_device_id); +static int hw_stop_acquisition(int device_index, gpointer session_device_id); /** * Check the USB configuration to determine if this is a Saleae Logic. @@ -856,7 +856,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) } /* This stops acquisition on ALL devices, ignoring device_index. */ -static void hw_stop_acquisition(int device_index, gpointer session_data) +static int hw_stop_acquisition(int device_index, gpointer session_data) { struct sr_datafeed_packet packet; @@ -869,6 +869,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) receive_transfer(NULL); /* TODO: Need to cancel and free any queued up transfers. */ + + return SR_OK; } SR_PRIV struct sr_device_plugin saleae_logic_plugin_info = { diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 9892df0f..883f5b49 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -698,7 +698,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) } /* This stops acquisition on ALL devices, ignoring device_index. */ -static void hw_stop_acquisition(int device_index, gpointer session_device_id) +static int hw_stop_acquisition(int device_index, gpointer session_device_id) { struct sr_datafeed_packet packet; struct sr_device_instance *sdi; @@ -709,16 +709,18 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id) if (!(sdi = sr_get_device_instance(device_instances, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); - return; /* FIXME */ + return SR_ERR_BUG; } if (!(zp = sdi->priv)) { sr_err("zp: %s: sdi->priv was NULL", __func__); - return; /* FIXME */ + return SR_ERR_BUG; } analyzer_reset(zp->usb->devhdl); /* TODO: Need to cancel and free any queued up transfers. */ + + return SR_OK; } SR_PRIV struct sr_device_plugin zeroplus_logic_cube_plugin_info = { diff --git a/sigrok.h b/sigrok.h index e12c5bc5..bb16a63d 100644 --- a/sigrok.h +++ b/sigrok.h @@ -354,7 +354,7 @@ struct sr_device_plugin { int *(*get_capabilities) (void); int (*set_configuration) (int device_index, int capability, void *value); int (*start_acquisition) (int device_index, gpointer session_device_id); - void (*stop_acquisition) (int device_index, gpointer session_device_id); + int (*stop_acquisition) (int device_index, gpointer session_device_id); }; struct sr_session {