X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Flascar-el-usb%2Fapi.c;h=1ab2a68fdb3e7f6a0fc6f23401e1d417dc4c93a4;hb=7ec5b54955118d8c1ee003a02c3334f1a0046457;hp=25932ac74106df886bc9aa7ad791aa62dbd72fd8;hpb=a1c743fc51d7b49c769fb525fe4b89985a9468c9;p=libsigrok.git diff --git a/hardware/lascar-el-usb/api.c b/hardware/lascar-el-usb/api.c index 25932ac7..1ab2a68f 100644 --- a/hardware/lascar-el-usb/api.c +++ b/hardware/lascar-el-usb/api.c @@ -70,17 +70,7 @@ static int clear_instances(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("Driver context malloc failed."); - return SR_ERR_MALLOC; - } - - drvc->sr_ctx = sr_ctx; - di->priv = drvc; - - return SR_OK; + return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN); } static GSList *hw_scan(GSList *options) @@ -95,10 +85,7 @@ static GSList *hw_scan(GSList *options) (void)options; - if (!(drvc = di->priv)) { - sr_err("Driver was not initialized."); - return NULL; - } + drvc = di->priv; /* USB scan is always authoritative. */ clear_instances(); @@ -213,24 +200,6 @@ static int hw_cleanup(void) return SR_OK; } -static int config_get(int id, const void **data, const struct sr_dev_inst *sdi) -{ - (void)sdi; - - switch (id) { - case SR_DI_HWOPTS: - *data = hwopts; - break; - case SR_DI_HWCAPS: - *data = hwcaps; - break; - default: - return SR_ERR_ARG; - } - - return SR_OK; -} - static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) { struct dev_context *devc; @@ -267,6 +236,12 @@ static int config_list(int key, const void **data, const struct sr_dev_inst *sdi (void)sdi; switch (key) { + case SR_CONF_SCAN_OPTIONS: + *data = hwopts; + break; + case SR_CONF_DEVICE_OPTIONS: + *data = hwcaps; + break; default: return SR_ERR_ARG; } @@ -491,7 +466,6 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, - .config_get = config_get, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open,