]> sigrok.org Git - libsigrok.git/commitdiff
sr: convert sr_parse_triggerstring() to use sdi
authorBert Vermeulen <redacted>
Sun, 22 Jul 2012 12:28:40 +0000 (14:28 +0200)
committerBert Vermeulen <redacted>
Fri, 3 Aug 2012 09:27:31 +0000 (11:27 +0200)
proto.h
strutil.c

diff --git a/proto.h b/proto.h
index 3b69c3480b1e04739315f8049eef5bf2dccc8283..7aa876f903a2f351a0d08f49ddd0e6931587d5c7 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -127,8 +127,8 @@ SR_API struct sr_output_format **sr_output_list(void);
 SR_API char *sr_samplerate_string(uint64_t samplerate);
 SR_API char *sr_period_string(uint64_t frequency);
 SR_API char *sr_voltage_string(struct sr_rational *voltage);
-SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
-                                    const char *triggerstring);
+SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
+               const char *triggerstring);
 SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
 SR_API uint64_t sr_parse_timestring(const char *timestring);
 SR_API gboolean sr_parse_boolstring(const char *boolstring);
index 7c346a006c21606f9076154c0fe94643fc6750c9..0a03ca7545719f6db0e5a83c6fd521a045ccc119 100644 (file)
--- a/strutil.c
+++ b/strutil.c
@@ -170,7 +170,7 @@ SR_API char *sr_voltage_string(struct sr_rational *voltage)
  *         contain the respective trigger type which is requested for the
  *         respective probe (e.g. "r", "c", and so on).
  */
-SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
+SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
                                     const char *triggerstring)
 {
        GSList *l;
@@ -180,7 +180,7 @@ SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
        const char *trigger_types;
        gboolean error;
 
-       max_probes = g_slist_length(dev->probes);
+       max_probes = g_slist_length(sdi->probes);
        error = FALSE;
 
        if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) {
@@ -190,10 +190,9 @@ SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
 
        tokens = g_strsplit(triggerstring, ",", max_probes);
 
-       trigger_types = dev->driver->dev_info_get(0, SR_DI_TRIGGER_TYPES);
-       if (!trigger_types) {
-               sr_err("strutil: %s: Device doesn't support any triggers.",
-                      __func__);
+       if (sdi->driver->info_get(SR_DI_TRIGGER_TYPES,
+                       (const void **)&trigger_types, sdi) != SR_OK) {
+               sr_err("strutil: %s: Device doesn't support any triggers.", __func__);
                return NULL;
        }
 
@@ -201,7 +200,7 @@ SR_API char **sr_parse_triggerstring(struct sr_dev *dev,
                if (tokens[i][0] < '0' || tokens[i][0] > '9') {
                        /* Named probe */
                        probenum = 0;
-                       for (l = dev->probes; l; l = l->next) {
+                       for (l = sdi->probes; l; l = l->next) {
                                probe = (struct sr_probe *)l->data;
                                if (probe->enabled
                                    && !strncmp(probe->name, tokens[i],