From: Uwe Hermann Date: Tue, 23 Oct 2012 22:47:44 +0000 (+0200) Subject: new-driver: Cosmetics, whitespace, add comments. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=126eded091582d9b988d793141d6c428bc38457d;p=sigrok-util.git new-driver: Cosmetics, whitespace, add comments. --- diff --git a/source/drv-Makefile.am b/source/drv-Makefile.am index 7af869e..42c95d4 100644 --- a/source/drv-Makefile.am +++ b/source/drv-Makefile.am @@ -23,11 +23,11 @@ if HW_${upper} noinst_LTLIBRARIES = libsigrokhw${lib}.la libsigrokhw${lib}_la_SOURCES = \ - api.c \ - protocol.c \ - protocol.h + api.c \ + protocol.c \ + protocol.h libsigrokhw${lib}_la_CFLAGS = \ - -I$(top_srcdir) + -I$(top_srcdir) endif diff --git a/source/drv-api.c b/source/drv-api.c index e9b046c..f9e990b 100644 --- a/source/drv-api.c +++ b/source/drv-api.c @@ -23,11 +23,9 @@ #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 +57,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("${short}: Driver context malloc failed."); return SR_ERR; } @@ -76,6 +74,7 @@ static GSList *hw_scan(GSList *options) GSList *devices; (void)options; + devices = NULL; drvc = di->priv; drvc->instances = NULL; @@ -96,7 +95,6 @@ static GSList *hw_dev_list(void) static int hw_dev_open(struct sr_dev_inst *sdi) { - /* TODO */ return SR_OK; @@ -104,7 +102,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 +109,6 @@ static int hw_dev_close(struct sr_dev_inst *sdi) static int hw_cleanup(void) { - clear_instances(); /* TODO */ @@ -121,10 +117,8 @@ 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: @@ -135,7 +129,7 @@ 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; @@ -153,18 +147,16 @@ 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) diff --git a/source/drv-protocol.c b/source/drv-protocol.c index f894744..b7b359d 100644 --- a/source/drv-protocol.c +++ b/source/drv-protocol.c @@ -17,13 +17,12 @@ * along with this program. If not, see . */ +#include #include #include "libsigrok.h" #include "libsigrok-internal.h" #include "config.h" #include "protocol.h" -#include - SR_PRIV int ${lib}_receive_data(int fd, int revents, void *cb_data) { @@ -37,7 +36,7 @@ SR_PRIV int ${lib}_receive_data(int fd, int revents, void *cb_data) return TRUE; if (revents == G_IO_IN) { - /* TODO */ + /* TODO */ } return TRUE; diff --git a/source/drv-protocol.h b/source/drv-protocol.h index c12e6ba..dae5ffe 100644 --- a/source/drv-protocol.h +++ b/source/drv-protocol.h @@ -17,19 +17,21 @@ * along with this program. If not, see . */ - #ifndef LIBSIGROK_${upper}_H #define LIBSIGROK_${upper}_H -/* Private, per-device-instance driver context. */ +/** Private, per-device-instance driver context. */ struct dev_context { + /** The current sampling limit (in number of samples). */ uint64_t limit_samples; + + /** The current sampling limit (in ms). */ uint64_t limit_msec; - /* Opaque pointer passed in by the frontend. */ + /** Opaque pointer passed in by the frontend. */ void *cb_data; - /* Runtime. */ + /** The current number of already received samples. */ uint64_t num_samples; };