]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fluke-dmm/api.c
Factor out common hw_init() driver code.
[libsigrok.git] / hardware / fluke-dmm / api.c
index bf00b7352326c6ae281f9cfb9ea5d0f834069b76..0d73fb63780535388682e5a047b90d23aa530fec 100644 (file)
@@ -89,17 +89,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 *fluke_scan(const char *conn, const char *serialcomm)
@@ -281,24 +271,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;
@@ -342,6 +314,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;
        }
@@ -421,7 +399,6 @@ SR_PRIV struct sr_dev_driver flukedmm_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,