X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=blobdiff_plain;f=source%2Fdrv-api.c;h=3444fd6693b4a7b607340755f360c088a35fe5e4;hp=6566d629a8b7cec0e97741135a0127f0fc80db82;hb=7b5d29b694e64356ec5ece92f2048f846e3c83a2;hpb=bc02c2bf465c0ad26410596f0b8ac0a9be57ea0c diff --git a/source/drv-api.c b/source/drv-api.c index 6566d62..3444fd6 100644 --- a/source/drv-api.c +++ b/source/drv-api.c @@ -20,13 +20,6 @@ #include #include "protocol.h" -SR_PRIV struct sr_dev_driver {lib}_driver_info; - -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{{ - return std_init(sr_ctx, di, LOG_PREFIX); -}} - static GSList *scan(struct sr_dev_driver *di, GSList *options) {{ struct drv_context *drvc; @@ -44,24 +37,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return devices; }} -static GSList *dev_list(const struct sr_dev_driver *di) -{{ - return ((struct drv_context *)(di->context))->instances; -}} - -static int dev_clear(const struct sr_dev_driver *di) -{{ - return std_dev_clear(di, NULL); -}} - static int dev_open(struct sr_dev_inst *sdi) {{ (void)sdi; /* TODO: get handle from sdi->conn and open it. */ - sdi->status = SR_ST_ACTIVE; - return SR_OK; }} @@ -71,17 +52,6 @@ static int dev_close(struct sr_dev_inst *sdi) /* TODO: get handle from sdi->conn and close it. */ - sdi->status = SR_ST_INACTIVE; - - return SR_OK; -}} - -static int cleanup(const struct sr_dev_driver *di) -{{ - dev_clear(di); - - /* TODO: free other driver resources, if any. */ - return SR_OK; }} @@ -109,12 +79,10 @@ static int config_set(uint32_t key, GVariant *data, {{ int ret; + (void)sdi; (void)data; (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - ret = SR_OK; switch (key) {{ /* TODO */ @@ -144,29 +112,22 @@ static int config_list(uint32_t key, GVariant **data, return ret; }} -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) {{ - (void)sdi; - (void)cb_data; - - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* TODO: configure hardware, reset acquisition state, set up * callbacks and send header packet. */ + (void)sdi; + return SR_OK; }} -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) {{ - (void)cb_data; - - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* TODO: stop acquisition. */ + (void)sdi; + return SR_OK; }} @@ -174,11 +135,11 @@ SR_PRIV struct sr_dev_driver {lib}_driver_info = {{ .name = "{short}", .longname = "{name}", .api_version = 1, - .init = init, - .cleanup = cleanup, + .init = std_init, + .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, - .dev_clear = dev_clear, + .dev_list = std_dev_list, + .dev_clear = std_dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list,