]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hantek-dso/api.c
Shorten/simplify hw_dev_list() implementations.
[libsigrok.git] / hardware / hantek-dso / api.c
index 7c2eaa954f00471e223dfac021be341f22468d90..4b0dfe37708819b3e061c3111bc588d0331c8c8b 100644 (file)
@@ -259,17 +259,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)
@@ -285,11 +275,12 @@ static GSList *hw_scan(GSList *options)
 
        (void)options;
 
-       devcnt = 0;
-       devices = 0;
        drvc = di->priv;
        drvc->instances = NULL;
 
+       devcnt = 0;
+       devices = 0;
+
        clear_instances();
 
        /* Find all Hantek DSO devices and upload firmware to all of them. */
@@ -350,11 +341,7 @@ static GSList *hw_scan(GSList *options)
 
 static GSList *hw_dev_list(void)
 {
-       struct drv_context *drvc;
-
-       drvc = di->priv;
-
-       return drvc->instances;
+       return ((struct drv_context *)(di->priv))->instances;
 }
 
 static int hw_dev_open(struct sr_dev_inst *sdi)