]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
Factor out common hw_init() driver code.
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 4b442530fb28f733c31ce385af90ddc6d1403941..a0955371a21e105fd129208a03e7c6d4ef264691 100644 (file)
@@ -384,17 +384,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)
@@ -607,12 +597,6 @@ static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
        struct dev_context *devc;
 
        switch (id) {
-       case SR_DI_HWCAPS:
-               *data = hwcaps;
-               break;
-       case SR_DI_TRIGGER_TYPES:
-               *data = TRIGGER_TYPES;
-               break;
        case SR_CONF_SAMPLERATE:
                if (sdi) {
                        devc = sdi->priv;
@@ -653,9 +637,15 @@ static int config_list(int key, const void **data, const struct sr_dev_inst *sdi
        (void)sdi;
 
        switch (key) {
+       case SR_CONF_DEVICE_OPTIONS:
+               *data = hwcaps;
+               break;
        case SR_CONF_SAMPLERATE:
                *data = &samplerates;
                break;
+       case SR_CONF_TRIGGER_TYPE:
+               *data = TRIGGER_TYPE;
+               break;
        default:
                return SR_ERR_ARG;
        }