]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/pipistrello-ols/api.c
Remove unneeded explicit array size specification.
[libsigrok.git] / src / hardware / pipistrello-ols / api.c
index 2db23fd042eaea1ea39a1de1c194576b5d1d0d78..31fd9ac2568379fc1efbc67d09b509c621b030a2 100644 (file)
@@ -61,7 +61,7 @@ static const char *patterns[] = {
 };
 
 /* Channels are numbered 0-31 (on the PCB silkscreen). */
-SR_PRIV const char *p_ols_channel_names[NUM_CHANNELS + 1] = {
+SR_PRIV const char *p_ols_channel_names[] = {
        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
        "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
        "24", "25", "26", "27", "28", "29", "30", "31",
@@ -76,14 +76,13 @@ static const uint64_t samplerates[] = {
 };
 
 SR_PRIV struct sr_dev_driver p_ols_driver_info;
-static struct sr_dev_driver *di = &p_ols_driver_info;
 
-static int init(struct sr_context *sr_ctx)
+static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
 {
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
@@ -100,10 +99,7 @@ static GSList *scan(GSList *options)
        devices = NULL;
 
        /* Allocate memory for our private device context. */
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto err_free_nothing;
-       }
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Device-specific settings */
        devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
@@ -204,12 +200,11 @@ err_free_ftdi_buf:
        g_free(devc->ftdi_buf);
 err_free_devc:
        g_free(devc);
-err_free_nothing:
 
        return NULL;
 }
 
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
 {
        return ((struct drv_context *)(di->priv))->instances;
 }
@@ -224,17 +219,16 @@ static void clear_helper(void *priv)
        g_free(devc->ftdi_buf);
 }
 
-static int dev_clear(void)
+static int dev_clear(const struct sr_dev_driver *di)
 {
        return std_dev_clear(di, clear_helper);
 }
 
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
 {
-       return dev_clear();
+       return dev_clear(di);
 }
 
-
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -474,7 +468,6 @@ static int dev_close(struct sr_dev_inst *sdi)
        return ret;
 }
 
-
 static int set_trigger(const struct sr_dev_inst *sdi, int stage)
 {
        struct dev_context *devc;
@@ -711,8 +704,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        return SR_OK;
 }
 
-
-
 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct dev_context *devc;