]> sigrok.org Git - libsigrok.git/blobdiff - hardware/victor-dmm/api.c
Factor out common hw_init() driver code.
[libsigrok.git] / hardware / victor-dmm / api.c
index d6bc5a34a671591efb27fb62de8d83d9b347043c..75c893d1779150fb34aa1e868b0bec7e78b79bf9 100644 (file)
@@ -74,17 +74,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)
@@ -100,10 +90,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();