- if (!(sdi = get_sigrok_device_instance(device_instances, device_index)))
- return SIGROK_ERR;
-
- if (capability == HWCAP_SAMPLERATE) {
- ret = set_samplerate(sdi, *(uint64_t*) value);
- } else if (capability == HWCAP_PROBECONFIG) {
- ret = configure_probes(value);
- } else if (capability == HWCAP_LIMIT_MSEC) {
- limit_msec = strtoull(value, NULL, 10);
- ret = SIGROK_OK;
- } else if (capability == HWCAP_CAPTURE_RATIO) {
- capture_ratio = strtoull(value, NULL, 10);
- ret = SIGROK_OK;
- } else if (capability == HWCAP_PROBECONFIG) {
- ret = configure_probes((GSList *) value);
+ if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
+ return SR_ERR;
+
+ ctx = sdi->priv;
+
+ if (hwcap == SR_HWCAP_SAMPLERATE) {
+ ret = set_samplerate(sdi, *(uint64_t *)value);
+ } else if (hwcap == SR_HWCAP_PROBECONFIG) {
+ ret = configure_probes(sdi, value);
+ } else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
+ ctx->limit_msec = *(uint64_t *)value;
+ if (ctx->limit_msec > 0)
+ ret = SR_OK;
+ else
+ ret = SR_ERR;
+ } else if (hwcap == SR_HWCAP_CAPTURE_RATIO) {
+ ctx->capture_ratio = *(uint64_t *)value;
+ if (ctx->capture_ratio < 0 || ctx->capture_ratio > 100)
+ ret = SR_ERR;
+ else
+ ret = SR_OK;