]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
sr/drivers: use sr_dev_inst instead of device index for dev_config_set()
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index bdc6b42366f5e887ae006a1575a6061ee20e2924..2cf9c0f5d4883edb89eb1b23bb5d28efe9ad8400 100644 (file)
@@ -143,7 +143,8 @@ static libusb_context *usb_context = NULL;
 
 SR_PRIV struct sr_dev_driver fx2lafw_driver_info;
 static struct sr_dev_driver *fdi = &fx2lafw_driver_info;
-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);
 static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
 
 /**
@@ -575,7 +576,7 @@ static int hw_dev_open(int dev_index)
 
        if (ctx->cur_samplerate == 0) {
                /* Samplerate hasn't been set; default to the slowest one. */
-               if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
+               if (hw_dev_config_set(sdi, SR_HWCAP_SAMPLERATE,
                    &supported_samplerates[0]) == SR_ERR)
                        return SR_ERR;
        }
@@ -611,14 +612,18 @@ static int hw_cleanup(void)
        return ret;
 }
 
-static int hw_info_get(int dev_info_id, const void **data,
+static int hw_info_get(int info_id, const void **data,
                const struct sr_dev_inst *sdi)
 {
        struct context *ctx;
 
-       switch (dev_info_id) {
+       switch (info_id) {
        case SR_DI_INST:
-               return sdi;
+               *data = sdi;
+               break;
+       case SR_DI_HWCAPS:
+               *data = hwcaps;
+               break;
        case SR_DI_NUM_PROBES:
                if (sdi) {
                        ctx = sdi->priv;
@@ -662,19 +667,12 @@ static int hw_dev_status_get(int dev_index)
        return sdi->status;
 }
 
-static const int *hw_hwcap_get_all(void)
-{
-       return hwcaps;
-}
-
-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(fdi->instances, dev_index)))
-               return SR_ERR;
        ctx = sdi->priv;
 
        if (hwcap == SR_HWCAP_SAMPLERATE) {
@@ -1057,7 +1055,6 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
        .dev_close = hw_dev_close,
        .info_get = hw_info_get,
        .dev_status_get = hw_dev_status_get,
-       .hwcap_get_all = hw_hwcap_get_all,
        .dev_config_set = hw_dev_config_set,
        .dev_acquisition_start = hw_dev_acquisition_start,
        .dev_acquisition_stop = hw_dev_acquisition_stop,