]> sigrok.org Git - libsigrok.git/blobdiff - hardware/zeroplus-logic-cube/zeroplus.c
sr: add new driver API call: scan()
[libsigrok.git] / hardware / zeroplus-logic-cube / zeroplus.c
index 95033ccddb3ca9060b2d067cec69c75c960a89b3..ac396dede945615963a1aa917c068bae32c19cce 100644 (file)
@@ -25,8 +25,8 @@
 #include <glib.h>
 #include <libusb.h>
 #include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
 #include "analyzer.h"
 
 #define USB_VENDOR                     0x0c12
@@ -114,7 +114,7 @@ static libusb_context *usb_context = NULL;
  * TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
  * that high.
  */
-static uint64_t supported_samplerates[] = {
+static const uint64_t supported_samplerates[] = {
        SR_HZ(100),
        SR_HZ(500),
        SR_KHZ(1),
@@ -136,7 +136,7 @@ static uint64_t supported_samplerates[] = {
        0,
 };
 
-static struct sr_samplerates samplerates = {
+static const struct sr_samplerates samplerates = {
        0,
        0,
        0,
@@ -157,7 +157,7 @@ struct context {
        struct sr_usb_dev_inst *usb;
 };
 
-static int hw_dev_config_set(int dev_index, int hwcap, void *value);
+static int hw_dev_config_set(int dev_index, int hwcap, const void *value);
 
 static unsigned int get_memory_size(int type)
 {
@@ -282,11 +282,11 @@ static void close_dev(struct sr_dev_inst *sdi)
        sdi->status = SR_ST_INACTIVE;
 }
 
-static int configure_probes(struct sr_dev_inst *sdi, GSList *probes)
+static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes)
 {
        struct context *ctx;
-       struct sr_probe *probe;
-       GSList *l;
+       const struct sr_probe *probe;
+       const GSList *l;
        int probe_bit, stage, i;
        char *tc;
 
@@ -327,7 +327,15 @@ static int configure_probes(struct sr_dev_inst *sdi, GSList *probes)
  * API callbacks
  */
 
-static int hw_init(const char *devinfo)
+static int hw_init(void)
+{
+
+       /* Nothing to do. */
+
+       return SR_OK;
+}
+
+static int hw_scan(void)
 {
        struct sr_dev_inst *sdi;
        struct libusb_device_descriptor des;
@@ -335,9 +343,6 @@ static int hw_init(const char *devinfo)
        int ret, devcnt, i;
        struct context *ctx;
 
-       /* Avoid compiler warnings. */
-       (void)devinfo;
-
        /* Allocate memory for our private driver context. */
        if (!(ctx = g_try_malloc(sizeof(struct context)))) {
                sr_err("zp: %s: ctx malloc failed", __func__);
@@ -599,7 +604,7 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
        return SR_OK;
 }
 
-static int hw_dev_config_set(int dev_index, int hwcap, void *value)
+static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
 {
        struct sr_dev_inst *sdi;
        struct context *ctx;
@@ -616,11 +621,11 @@ static int hw_dev_config_set(int dev_index, int hwcap, void *value)
 
        switch (hwcap) {
        case SR_HWCAP_SAMPLERATE:
-               return set_samplerate(sdi, *(uint64_t *)value);
+               return set_samplerate(sdi, *(const uint64_t *)value);
        case SR_HWCAP_PROBECONFIG:
-               return configure_probes(sdi, (GSList *)value);
+               return configure_probes(sdi, (const GSList *)value);
        case SR_HWCAP_LIMIT_SAMPLES:
-               ctx->limit_samples = *(uint64_t *)value;
+               ctx->limit_samples = *(const uint64_t *)value;
                return SR_OK;
        default:
                return SR_ERR;
@@ -740,6 +745,7 @@ SR_PRIV struct sr_dev_driver zeroplus_logic_cube_driver_info = {
        .api_version = 1,
        .init = hw_init,
        .cleanup = hw_cleanup,
+       .scan = hw_scan,
        .dev_open = hw_dev_open,
        .dev_close = hw_dev_close,
        .dev_info_get = hw_dev_info_get,