]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/kecheng-kc-330b/api.c
Remove unnecessary driver context checks
[libsigrok.git] / src / hardware / kecheng-kc-330b / api.c
index 15c43b1b95fa21c155165983e832754e67a2e727..86ac30b15a5dfd7f435129adf4cefde36b553441 100644 (file)
@@ -163,15 +163,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)
@@ -193,15 +188,9 @@ 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 dev_context *devc;
        struct sr_usb_dev_inst *usb;
 
-       if (!di->context) {
-               sr_err("Driver was not initialized.");
-               return SR_ERR;
-       }
-
        usb = sdi->conn;
 
        if (!usb->devhdl)
@@ -274,7 +263,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;
        uint64_t p, q;
        unsigned int i;
@@ -286,11 +274,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;
        ret = SR_OK;
        switch (key) {