]> sigrok.org Git - libsigrok.git/blobdiff - session_driver.c
sr/drivers: change driver dev_open/dev_close calls to use sdi
[libsigrok.git] / session_driver.c
index 64ec06d17b4dd779ad3d01088b0255a4b2b4b6a8..34f8c34e2a9ea773ef8c7cf1a57eb39be0e0b324 100644 (file)
@@ -171,14 +171,8 @@ static int hw_cleanup(void)
        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;
-
-       sdi = sr_dev_inst_new(dev_index, SR_ST_INITIALIZING,
-                             NULL, NULL, NULL);
-       if (!sdi)
-               return SR_ERR;
 
        if (!(sdi->priv = g_try_malloc0(sizeof(struct session_vdev)))) {
                sr_err("session driver: %s: sdi->priv malloc failed", __func__);
@@ -224,13 +218,13 @@ static int hw_dev_status_get(int dev_index)
                return SR_ERR;
 }
 
-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 session_vdev *vdev;
        const uint64_t *tmp_u64;
 
-       if (!(vdev = get_vdev_by_index(dev_index)))
-               return SR_ERR;
+       vdev = sdi->priv;
 
        switch (hwcap) {
        case SR_HWCAP_SAMPLERATE: