X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=blobdiff_plain;f=source%2Fdrv-api.c;h=671149bd6fa4230d1d88de29632df177760540e6;hp=e9b046c271f3a75220a06b63bde72172dbea83d0;hb=f3f6a56101d98c180b0e62027da1969b16decc6a;hpb=a65d66c08881d65a6d6e37be8efc1a24e4f60592 diff --git a/source/drv-api.c b/source/drv-api.c index e9b046c..671149b 100644 --- a/source/drv-api.c +++ b/source/drv-api.c @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrok project. * * Copyright (C) ${year} ${author} <${email}> * @@ -20,14 +20,11 @@ #include #include "libsigrok.h" #include "libsigrok-internal.h" -#include "config.h" #include "protocol.h" - SR_PRIV struct sr_dev_driver driver_info; static struct sr_dev_driver *di = &${lib}_driver_info; - /* Properly close and free all devices. */ static int clear_instances(void) { @@ -59,7 +56,7 @@ static int hw_init(void) struct drv_context *drvc; if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) { - sr_err("${short}: driver context malloc failed."); + sr_err("Driver context malloc failed."); return SR_ERR; } @@ -76,6 +73,7 @@ static GSList *hw_scan(GSList *options) GSList *devices; (void)options; + devices = NULL; drvc = di->priv; drvc->instances = NULL; @@ -96,7 +94,6 @@ static GSList *hw_dev_list(void) static int hw_dev_open(struct sr_dev_inst *sdi) { - /* TODO */ return SR_OK; @@ -104,7 +101,6 @@ static int hw_dev_open(struct sr_dev_inst *sdi) static int hw_dev_close(struct sr_dev_inst *sdi) { - /* TODO */ return SR_OK; @@ -112,7 +108,6 @@ static int hw_dev_close(struct sr_dev_inst *sdi) static int hw_cleanup(void) { - clear_instances(); /* TODO */ @@ -121,13 +116,12 @@ static int hw_cleanup(void) } static int hw_info_get(int info_id, const void **data, - const struct sr_dev_inst *sdi) + const struct sr_dev_inst *sdi) { - - switch (info_id) { /* TODO */ default: + sr_err("Unknown info_id: %d.", info_id); return SR_ERR_ARG; } @@ -135,17 +129,20 @@ static int hw_info_get(int info_id, const void **data, } static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, - const void *value) + const void *value) { int ret; - if (sdi->status != SR_ST_ACTIVE) + if (sdi->status != SR_ST_ACTIVE) { + sr_err("Device inactive, can't set config options."); return SR_ERR; + } ret = SR_OK; switch (hwcap) { /* TODO */ default: + sr_err("Unknown hardware capability: %d.", hwcap); ret = SR_ERR_ARG; } @@ -153,22 +150,22 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, } static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) + void *cb_data) { - /* TODO */ return SR_OK; } static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, - void *cb_data) + void *cb_data) { - (void)cb_data; - if (sdi->status != SR_ST_ACTIVE) + if (sdi->status != SR_ST_ACTIVE) { + sr_err("Device inactive, can't stop acquisition."); return SR_ERR; + } /* TODO */