-
- tmp = g_variant_get_string(data, NULL);
-
- for (i = 0; (*model->coupling_options)[i]; i++) {
- if (strcmp(tmp, (*model->coupling_options)[i]) != 0)
- continue;
- for (j = 1; j <= model->analog_channels; j++) {
- if (cg != devc->analog_groups[j - 1])
- continue;
- state->analog_states[j-1].coupling = i;
-
- if (dlm_analog_chan_coupl_set(sdi->conn, j, tmp) != SR_OK ||
- sr_scpi_get_opc(sdi->conn) != SR_OK)
- return SR_ERR;
- break;
- }
-
- ret = SR_OK;
- break;
- }
+ if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0)
+ return SR_ERR_ARG;
+ if ((j = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
+ return SR_ERR_ARG;
+ state->analog_states[j].coupling = idx;
+ if (dlm_analog_chan_coupl_set(sdi->conn, j + 1, (*model->coupling_options)[idx]) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ ret = SR_OK;