]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/uni-t-ut32x/api.c
Remove unnecessary driver context checks
[libsigrok.git] / src / hardware / uni-t-ut32x / api.c
index f19dabeff55015f0bad2d20de530650b8821aec5..7ed3f88ce8fa1f38d8b159584d92224b02357298 100644 (file)
@@ -101,15 +101,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 static int dev_open(struct sr_dev_inst *sdi)
 {
        struct sr_dev_driver *di = sdi->driver;
-       struct drv_context *drvc;
+       struct drv_context *drvc = di->context;
        struct sr_usb_dev_inst *usb;
        int ret;
 
-       if (!(drvc = di->context)) {
-               sr_err("Driver was not initialized.");
-               return SR_ERR;
-       }
-
        usb = sdi->conn;
 
        if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
@@ -145,14 +140,8 @@ static int dev_open(struct sr_dev_inst *sdi)
 
 static int dev_close(struct sr_dev_inst *sdi)
 {
-       struct sr_dev_driver *di = sdi->driver;
        struct sr_usb_dev_inst *usb;
 
-       if (!di->context) {
-               sr_err("Driver was not initialized.");
-               return SR_ERR;
-       }
-
        usb = sdi->conn;
        if (!usb->devhdl)
                /*  Nothing to do. */
@@ -194,7 +183,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       struct sr_dev_driver *di = sdi->driver;
        struct dev_context *devc;
        const char *tmp_str;
 
@@ -203,11 +191,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
 
-       if (!di->context) {
-               sr_err("Driver was not initialized.");
-               return SR_ERR;
-       }
-
        devc = sdi->priv;
 
        switch (key) {