]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
sr/drivers: change driver dev_open/dev_close calls to use sdi
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index 42526214b3d05439582aae6a9e50755a01cc8ebf..088095acb96d9177d2d24ff0d3996ed6c93df382 100644 (file)
@@ -607,15 +607,11 @@ static int upload_firmware(int firmware_idx, struct context *ctx)
        return SR_OK;
 }
 
-static int hw_dev_open(int dev_index)
+static int hw_dev_open(struct sr_dev_inst *sdi)
 {
-       struct sr_dev_inst *sdi;
        struct context *ctx;
        int ret;
 
-       if (!(sdi = sr_dev_inst_get(adi->instances, dev_index)))
-               return SR_ERR;
-
        ctx = sdi->priv;
 
        /* Make sure it's an ASIX SIGMA. */
@@ -633,7 +629,7 @@ static int hw_dev_open(int dev_index)
        return SR_OK;
 }
 
-static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
+static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
 {
        int i, ret;
        struct context *ctx = sdi->priv;
@@ -674,7 +670,7 @@ static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
  * The Sigma supports complex triggers using boolean expressions, but this
  * has not been implemented yet.
  */
-static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes)
+static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes)
 {
        struct context *ctx = sdi->priv;
        const struct sr_probe *probe;
@@ -748,16 +744,10 @@ static int configure_probes(struct sr_dev_inst *sdi, const GSList *probes)
        return SR_OK;
 }
 
-static int hw_dev_close(int dev_index)
+static int hw_dev_close(struct sr_dev_inst *sdi)
 {
-       struct sr_dev_inst *sdi;
        struct context *ctx;
 
-       if (!(sdi = sr_dev_inst_get(adi->instances, dev_index))) {
-               sr_err("sigma: %s: sdi was NULL", __func__);
-               return SR_ERR_BUG;
-       }
-
        if (!(ctx = sdi->priv)) {
                sr_err("sigma: %s: sdi->priv was NULL", __func__);
                return SR_ERR_BUG;
@@ -829,15 +819,12 @@ static int hw_dev_status_get(int dev_index)
                return SR_ST_NOT_FOUND;
 }
 
-static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
+static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
+               const void *value)
 {
-       struct sr_dev_inst *sdi;
        struct context *ctx;
        int ret;
 
-       if (!(sdi = sr_dev_inst_get(adi->instances, dev_index)))
-               return SR_ERR;
-
        ctx = sdi->priv;
 
        if (hwcap == SR_HWCAP_SAMPLERATE) {