]> sigrok.org Git - libsigrok.git/blobdiff - hardware/openbench-logic-sniffer/api.c
Factor out common hw_init() driver code.
[libsigrok.git] / hardware / openbench-logic-sniffer / api.c
index 52b9d975615ef746303093e3cb4a087bfa989da7..f69ca5113b91f883298d104483db68bd17942cd3 100644 (file)
@@ -57,16 +57,7 @@ static struct sr_dev_driver *di = &ols_driver_info;
 
 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)
@@ -84,7 +75,9 @@ static GSList *hw_scan(GSList *options)
        char buf[8];
 
        (void)options;
+
        drvc = di->priv;
+
        devices = NULL;
 
        conn = serialcomm = NULL;