]> sigrok.org Git - libsigrok.git/blobdiff - hardware/demo/demo.c
sr: rename more functions to sr_thing_action format
[libsigrok.git] / hardware / demo / demo.c
index 9fe35ae8689b755a9732559f1a92f8399dd5d0e8..ae4736273d90476da456b593a490486f5285c842 100644 (file)
@@ -27,7 +27,6 @@
 #include <fcntl.h>
 #define pipe(fds) _pipe(fds, 4096, _O_BINARY)
 #endif
-#include "config.h"
 #include "sigrok.h"
 #include "sigrok-internal.h"
 
@@ -65,7 +64,7 @@ enum {
 };
 
 /* FIXME: Should not be global. */
-GIOChannel *channels[2];
+SR_PRIV GIOChannel *channels[2];
 
 struct databag {
        int pipe_fds[2];
@@ -135,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)
 {
@@ -144,7 +143,7 @@ static int hw_init(const char *deviceinfo)
        /* Avoid compiler warnings. */
        (void)deviceinfo;
 
-       sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
+       sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
        if (!sdi) {
                sr_err("demo: %s: sr_device_instance_new failed", __func__);
                return 0;
@@ -175,9 +174,10 @@ static int hw_closedev(int device_index)
        return SR_OK;
 }
 
-static void hw_cleanup(void)
+static int hw_cleanup(void)
 {
        /* Nothing needed so far. */
+       return SR_OK;
 }
 
 static void *hw_get_device_info(int device_index, int device_info_id)
@@ -185,7 +185,7 @@ static void *hw_get_device_info(int device_index, int device_info_id)
        struct sr_device_instance *sdi;
        void *info = NULL;
 
-       if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
+       if (!(sdi = sr_dev_inst_get(device_instances, device_index))) {
                sr_err("demo: %s: sdi was NULL", __func__);
                return NULL;
        }
@@ -470,7 +470,6 @@ static int hw_start_acquisition(int device_index, gpointer session_data)
        gettimeofday(&header->starttime, NULL);
        header->samplerate = cur_samplerate;
        header->num_logic_probes = NUM_PROBES;
-       header->num_analog_probes = 0;
        sr_session_bus(session_data, packet);
        g_free(header);
        g_free(packet);
@@ -478,7 +477,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;
@@ -486,9 +485,11 @@ static void hw_stop_acquisition(int device_index, gpointer session_data)
 
        /* Stop generate thread. */
        thread_running = 0;
+
+       return SR_OK;
 }
 
-struct sr_device_plugin demo_plugin_info = {
+SR_PRIV struct sr_device_plugin demo_plugin_info = {
        .name = "demo",
        .longname = "Demo driver and pattern generator",
        .api_version = 1,