X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=source%2Fdrv-api.c;h=1288a7fd58b53305ca5746c9fa208d51fde8c7b1;hb=81fbb7e14292c332ba7e2e617c2c50a132189820;hp=58a54a7053bbb080a731162fbd4c21065fd2b701;hpb=01636a052d1b2a294b4617f302dec75427551d50;p=sigrok-util.git diff --git a/source/drv-api.c b/source/drv-api.c index 58a54a7..1288a7f 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}> * @@ -22,7 +22,7 @@ #include "libsigrok-internal.h" #include "protocol.h" -SR_PRIV struct sr_dev_driver driver_info; +SR_PRIV struct sr_dev_driver ${lib}_driver_info; static struct sr_dev_driver *di = &${lib}_driver_info; /* Properly close and free all devices. */ @@ -33,7 +33,9 @@ static int clear_instances(void) struct dev_context *devc; GSList *l; - drvc = di->priv; + if (!(drvc = di->priv)) + return SR_OK; + for (l = drvc->instances; l; l = l->next) { if (!(sdi = l->data)) continue; @@ -56,8 +58,8 @@ 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."); - return SR_ERR; + sr_err("Driver context malloc failed."); + return SR_ERR_MALLOC; } /* TODO */ @@ -121,6 +123,7 @@ static int hw_info_get(int info_id, const void **data, switch (info_id) { /* TODO */ default: + sr_err("Unknown info_id: %d.", info_id); return SR_ERR_ARG; } @@ -132,13 +135,16 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, { 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; } @@ -158,8 +164,10 @@ static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, { (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 */