]> sigrok.org Git - libsigrok.git/commitdiff
sr: stop_acquisition callback: Return int.
authorUwe Hermann <redacted>
Sun, 12 Feb 2012 12:31:58 +0000 (13:31 +0100)
committerUwe Hermann <redacted>
Mon, 13 Feb 2012 18:49:00 +0000 (19:49 +0100)
hardware/alsa/alsa.c
hardware/asix-sigma/asix-sigma.c
hardware/chronovu-la8/chronovu-la8.c
hardware/demo/demo.c
hardware/link-mso19/link-mso19.c
hardware/openbench-logic-sniffer/ols.c
hardware/saleae-logic/saleae-logic.c
hardware/zeroplus-logic-cube/zeroplus.c
sigrok.h

index 4c930e4f18676076df63ff72ca68dfb1990e586e..e5fad8f56940a440b87f4d87fbd5a2591c6ec399 100644 (file)
@@ -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 = {
index f05bc4dce6fdd4da51e633ce4d8300ba82ed6cd9..5ed014079887d2f301d5d593443814a90bf416fe 100644 (file)
@@ -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 = {
index b0609f7e175ad1ca3d1158be515af294b655a318..23ac8c793a9bdd44e0d66e44526c17f562a459ac 100644 (file)
@@ -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 = {
index 8cfd1c8946a5ca96b43a14b854c4a57c055b78d2..5e0d44cffea379f5590104d3b51e6d06338e12ce 100644 (file)
@@ -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 = {
index 7e8e797fb4a3f5a213fbac3174e61060d3323cbf..b3a5667f62de019265256e79957ebc7cc86d5785 100644 (file)
@@ -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 = {
index d71c025123cc6446a3b1918a3dd55404a7a03922..930d008557f9101203446104fe35648e9f5d8861 100644 (file)
@@ -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 = {
index bde17d75201c2a281cd2c9361eaac6b7f8d6969d..14477496e12d546a1fd7ad40118461ed2429e6db 100644 (file)
@@ -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 = {
index 9892df0f055e16f8a8ad76e860398f6790ba4997..883f5b49be5ebbda3acb02f0b43757191ab44c48 100644 (file)
@@ -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 = {
index e12c5bc5acc6b4479f88cdb07e42f26c17b05b63..bb16a63dfcfe3525b567e78fc16f2ffe2378fbfe 100644 (file)
--- 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 {