X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=source%2Fdrv-api.c;h=64f5ee18601abe1d922a00a4a6319b0d9beed092;hb=ad1407b5c526254d604c2d22d48cf6190a47a7b0;hp=66b24e8ff7133b040cb8d4ba5bbf60f802b5111a;hpb=3016358e290c0d980b3914f1155e6a3be7e8ff36;p=sigrok-util.git diff --git a/source/drv-api.c b/source/drv-api.c index 66b24e8..64f5ee1 100644 --- a/source/drv-api.c +++ b/source/drv-api.c @@ -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; @@ -51,17 +53,18 @@ static int clear_instances(void) return SR_OK; } -static int hw_init(void) +static int hw_init(struct sr_context *sr_ctx) { 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 */ + drvc->sr_ctx = sr_ctx; di->priv = drvc; return SR_OK; @@ -121,7 +124,6 @@ static int hw_info_get(int info_id, const void **data, switch (info_id) { /* TODO */ default: - sr_err("${short}: Unknown info_id: %d.", info_id); return SR_ERR_ARG; } @@ -134,7 +136,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, int ret; if (sdi->status != SR_ST_ACTIVE) { - sr_err("${short}: Device inactive, can't set config options."); + sr_err("Device inactive, can't set config options."); return SR_ERR; } @@ -142,7 +144,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, switch (hwcap) { /* TODO */ default: - sr_err("${short}: Unknown hardware capability: %d.", hwcap); + sr_err("Unknown hardware capability: %d.", hwcap); ret = SR_ERR_ARG; } @@ -157,13 +159,12 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_OK; } -static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, - void *cb_data) +static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) { (void)cb_data; if (sdi->status != SR_ST_ACTIVE) { - sr_err("${short}: Device inactive, can't stop acquisition."); + sr_err("Device inactive, can't stop acquisition."); return SR_ERR; }