]> sigrok.org Git - libsigrok.git/commitdiff
Simplify a few config_set() callbacks.
authorUwe Hermann <redacted>
Sat, 7 Mar 2015 23:28:17 +0000 (00:28 +0100)
committerUwe Hermann <redacted>
Sun, 22 Mar 2015 01:15:30 +0000 (02:15 +0100)
Also, extended logging and random whitespace fixes.

31 files changed:
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/asix-sigma/asix-sigma.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/colead-slm/api.c
src/hardware/demo/demo.c
src/hardware/fluke-dmm/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/lascar-el-usb/api.c
src/hardware/link-mso19/api.c
src/hardware/mic-985xx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/norma-dmm/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/serial-dmm/api.c
src/hardware/teleinfo/api.c
src/hardware/testo/api.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/hwdriver.c

index 6c41023de91aa31f258807a34c8a250c210b79e8..19a4144cca2aed4ea75df880087be1767ae7ace6 100644 (file)
@@ -192,18 +192,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
                /* TODO: not yet implemented */
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("LIMIT_MSEC can't be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 27c29e92bcb5ade67184665238394d4a4f834ed2..18fc2142171bb5ee6518b01222cc443daf7b52c0 100644 (file)
@@ -174,11 +174,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".", devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.", devc->limit_msec);
                break;
        case SR_CONF_DATA_SOURCE: {
                tmp_str = g_variant_get_string(data, NULL);
@@ -201,7 +199,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       (void)sdi;
        (void)cg;
 
        switch (key) {
index 6268747aedc740c11ad21d70dff8f1314df6bc01..0482daeb6fd830f54d482ece31f0d89054188959 100644 (file)
@@ -884,7 +884,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariant *gvar;
        GVariantBuilder gvb;
 
-       (void)sdi;
        (void)cg;
 
        switch (key) {
index 8cce84019aeeebcd0d161c24553d17bb4b966bf0..e0168b4ebc62fa6099965cf403380e1eb897540d 100644 (file)
@@ -358,7 +358,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                }
        }
 
-
        return ret;
 }
 
index f1da9b507668a7bdad5c8eaa63ef58c9ef389b60..4bcf772dd3c110b9ad9d7dacf60616d128eb0a07 100644 (file)
@@ -228,12 +228,10 @@ static int config_set(uint32_t key, GVariant *data,
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
                devc->limit_msec = 0;
-               sr_dbg("Setting sample limit to %" PRIu64, devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data) * 1000;
                devc->limit_samples = 0;
-               sr_dbg("Setting time limit to %" PRIu64"ms", devc->limit_msec);
                break;
        case SR_CONF_SAMPLERATE:
                samplerate = g_variant_get_uint64(data);
@@ -243,7 +241,6 @@ static int config_set(uint32_t key, GVariant *data,
                        break;
                }
                devc->samplerate = samplerate;
-               sr_dbg("Setting samplerate to %" PRIu64, devc->samplerate);
                break;
        case SR_CONF_PROBE_FACTOR:
                if (!cg)
index 6bfb6df1080a2059db7936a813061ffb037834f0..74795caf42dee540e2be1d7606f3bbd1fa58861d 100644 (file)
@@ -226,25 +226,22 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                const struct sr_channel_group *cg)
 {
        struct dev_context *devc = sdi->priv;
+
        (void)cg;
 
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                *data = g_variant_new_uint64(devc->limit_samples);
                break;
-
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->cur_samplerate);
                break;
-
        case SR_CONF_CAPTURE_RATIO:
                *data = g_variant_new_uint64(devc->capture_ratio);
                break;
-
        case SR_CONF_NUM_LOGIC_CHANNELS:
                *data = g_variant_new_uint32(g_slist_length(sdi->channels));
                break;
-
        default:
                return SR_ERR_NA;
        }
@@ -257,6 +254,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 {
        struct dev_context *devc = sdi->priv;
        uint64_t tmp_u64;
+
        (void)cg;
 
        if (sdi->status != SR_ST_ACTIVE)
@@ -266,7 +264,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        case SR_CONF_SAMPLERATE:
                devc->cur_samplerate = g_variant_get_uint64(data);
                return beaglelogic_set_samplerate(devc);
-
        case SR_CONF_LIMIT_SAMPLES:
                tmp_u64 = g_variant_get_uint64(data);
                devc->limit_samples = tmp_u64;
@@ -284,7 +281,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                (SAMPLEUNIT_TO_BYTES(devc->sampleunit) * 1000000));
                }
                return beaglelogic_set_triggerflags(devc);
-
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
                if (devc->capture_ratio > 100) {
@@ -292,7 +288,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        return SR_ERR;
                }
                return SR_OK;
-
        default:
                return SR_ERR_NA;
        }
@@ -308,7 +303,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariantBuilder gvb;
 
        (void)sdi;
-       (void)data;
        (void)cg;
 
        ret = SR_OK;
index 79e658f534a23841988e19a82c5c0e07beb059d5..d7dccc0502470826cfa685a861814de6060d2a0d 100644 (file)
@@ -210,11 +210,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".", devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.", devc->limit_msec);
                break;
        default:
                return SR_ERR_NA;
index eedffbfbf56097c157ead4fbc5a19f5c88ec352e..62f4dc0e2c6f748ce59d3c328a4de28b23985f1c 100644 (file)
@@ -137,18 +137,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
                /* TODO: not yet implemented */
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("LIMIT_MSEC can't be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);;
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 284396a3aeee9db173be88829fd9d73b05088dac..a3deecc3b68029d81cb0577d80e2cadc4cd57d21 100644 (file)
@@ -487,17 +487,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_SAMPLERATE:
                devc->cur_samplerate = g_variant_get_uint64(data);
-               sr_dbg("Setting samplerate to %" PRIu64, devc->cur_samplerate);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_msec = 0;
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64, devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
                devc->limit_samples = 0;
-               sr_dbg("Setting time limit to %" PRIu64"ms", devc->limit_msec);
                break;
        case SR_CONF_AVERAGING:
                devc->avg = g_variant_get_boolean(data);
@@ -575,8 +572,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariant *gvar;
        GVariantBuilder gvb;
 
-       (void)sdi;
-
        if (key == SR_CONF_SCAN_OPTIONS) {
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
index 216c6359c83c721e0eab3805cd2985b0885cca08..36142fd5587cd3614259a160dff1642bf94b4472 100644 (file)
@@ -216,18 +216,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
                /* TODO: not yet implemented */
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("LIMIT_MSEC can't be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 69b26794156f4988fd279bc8adc81173ebefa4b0..302e6593c5d39d75efb65e73701cb2760509f17b 100644 (file)
@@ -389,8 +389,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 
        (void)cg;
 
-       ret = SR_OK;
-
        if (!sdi || !(devc = sdi->priv))
                return SR_ERR_ARG;
 
index ad7ae5677a4f045ecbaf0e1aa5f0a5dbdda51e70..4f6c1e562f853c1d47edbc38795bc7ba0897ffd9 100644 (file)
@@ -1496,8 +1496,7 @@ SR_PRIV const char *gmc_model_str(enum model mcode)
        }
 }
 
-/** @copydoc sr_dev_driver.config_set
- */
+/** @copydoc sr_dev_driver.config_set */
 SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
@@ -1533,18 +1532,10 @@ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *s
                        g_usleep(2000000); /* Wait to ensure transfer before interface switched off. */
                break;
        case SR_CONF_LIMIT_MSEC:
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("LIMIT_MSEC can't be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                       devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                       devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 253d37cdbe54bdb63d47ea7001a5928363dc8625..d2eebfbe55754c74571d7f46313ee41d4846d9cd 100644 (file)
@@ -169,7 +169,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        struct sr_channel_group *cg;
        struct drv_context *drvc;
        struct dev_context *devc;
-       int i;
+       unsigned int i;
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INITIALIZING;
@@ -434,8 +434,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        const uint64_t *vdiv;
        int ch_idx;
 
-       (void)cg;
-
        switch (key) {
        case SR_CONF_NUM_HDIV:
                *data = g_variant_new_int32(NUM_TIMEBASE);
index 78b406ea60e3dba18aac3e5b77c361abc97d0178..abdbfd7228c562f8570f134c35fc4a54fb1626b3 100644 (file)
@@ -67,7 +67,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
        struct device_info dev_info;
-       int ret, i;
+       unsigned int i;
+       int ret;
 
        (void)options;
 
@@ -354,7 +355,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        (void)cg;
 
        ret = SR_OK;
-
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
index 3213a684a95ffbc275d601467111398b32f53700..67efcf1a2489376982ffe6490040dcfa65aadc68 100644 (file)
@@ -215,18 +215,13 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        ret = SR_OK;
        switch (key) {
        case SR_CONF_DATALOG:
-               if (g_variant_get_boolean(data)) {
-                       /* Start logging. */
+               if (g_variant_get_boolean(data))
                        ret = lascar_start_logging(sdi);
-               } else {
-                       /* Stop logging. */
+               else
                        ret = lascar_stop_logging(sdi);
-               }
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                ret = SR_ERR_NA;
index 634d3f97859a962138a05faef7bb1bb17a104110..98e253fee3e77593d7b6f44e447960d546f799c5 100644 (file)
@@ -320,8 +320,6 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                        ret = SR_ERR_ARG;
                } else {
                        devc->limit_samples = num_samples;
-                       sr_dbg("setting limit_samples to %i\n",
-                              num_samples);
                        ret = SR_OK;
                }
                break;
index df9cc22e027b55eaab291845107b09e9938ff848..6abc09ce073b778613c9f1348e8232f2b8cd33e6 100644 (file)
@@ -169,13 +169,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        default:
                return SR_ERR_NA;
index 0ed6b09b458f56a00a396afaac19e13863a9c077..5c979edefcd8b6049505f010f702dc0d42c90fae 100644 (file)
@@ -623,24 +623,15 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                /* No channel group: global options. */
                switch (key) {
                case SR_CONF_LIMIT_MSEC:
-                       if (g_variant_get_uint64(data) == 0) {
-                               sr_err("LIMIT_MSEC can't be 0.");
-                               return SR_ERR;
-                       }
                        devc->limit_msec = g_variant_get_uint64(data);
-                       sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                               devc->limit_msec);
                        break;
                case SR_CONF_LIMIT_SAMPLES:
                        devc->limit_samples = g_variant_get_uint64(data);
-                       sr_dbg("Setting sample limit to %" PRIu64 ".",
-                               devc->limit_samples);
                        break;
                case SR_CONF_OUTPUT_CHANNEL_CONFIG:
                        sval = g_variant_get_string(data, NULL);
                        found = FALSE;
-                       for (idx = 0; idx < (int)ARRAY_SIZE(channel_modes); idx++)
-                       {
+                       for (idx = 0; idx < (int)ARRAY_SIZE(channel_modes); idx++) {
                                if (!strcmp(sval, channel_modes[idx])) {
                                        found = TRUE;
                                        if (devc->tracking_mode == idx)
@@ -652,9 +643,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                if (devc->model->modelid <= LPS_303) /* Only first setting possible for smaller models. */
                                        break;
                        }
-                       if (!found) {
+                       if (!found)
                                return SR_ERR_ARG;
-                       }
                        break;
                default:
                        return SR_ERR_NA;
@@ -728,25 +718,23 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariant *gvar;
        GVariantBuilder gvb;
 
-       (void)data;
-
        /* Driver options, no device instance necessary. */
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                                                 scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
+                       scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
                return SR_OK;
        case SR_CONF_DEVICE_OPTIONS:
                if (sdi != NULL)
                        break;
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
-                               drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+                       drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
                return SR_OK;
        default:
-               if (sdi == NULL)
+               if (!sdi)
                        return SR_ERR_ARG;
-
                devc = sdi->priv;
+               break;
        }
 
        /* Device options, independent from channel groups. */
@@ -765,7 +753,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                                *data = g_variant_new_strv(channel_modes, ARRAY_SIZE(channel_modes));
                        }
                        return SR_OK;
-                       break;
                default:
                        return SR_ERR_NA;
                }
index 9df1546f4bfa9aa1b3377c7020b3cc623fe004c1..bf44df2756da534b9e00349e49c31c9d105936f9 100644 (file)
@@ -219,18 +219,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("LIMIT_MSEC can't be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 31fd9ac2568379fc1efbc67d09b509c621b030a2..3e02bc2868ed3e0636dbcafe97cc8e66da1d3e0f 100644 (file)
@@ -443,7 +443,7 @@ static int dev_open(struct sr_dev_inst *sdi)
        if (p_ols_open(devc) != SR_OK) {
                return SR_ERR;
        } else {
-         sdi->status = SR_ST_ACTIVE;
+               sdi->status = SR_ST_ACTIVE;
                return SR_OK;
        }
 }
index 5aa0b415c079c637fe8ce5715549eabe394bfa94..27705f7ccdc86995e8102e212d38491213c1356d 100644 (file)
@@ -630,7 +630,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                *data = g_variant_new_string(devc->coupling[analog_channel]);
                break;
        default:
-               sr_dbg("Tried to get unknown config key: %d.", key);
                return SR_ERR_NA;
        }
 
@@ -795,9 +794,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                }
                break;
        default:
-               sr_dbg("Tried to set unknown config key: %d.", key);
-               ret = SR_ERR_NA;
-               break;
+               return SR_ERR_NA;
        }
 
        return ret;
@@ -921,7 +918,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
                break;
        default:
-               sr_dbg("Tried to list unknown config key: %d.", key);
                return SR_ERR_NA;
        }
 
index 7a4a331f93754a01ccd3081eb6d6117a6dd0cec1..ae77bd8671952f15186ac6dc386283e7b91404f6 100644 (file)
@@ -148,7 +148,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        GSList *l, *devices, *conn_devices;
        struct libusb_device_descriptor des;
        libusb_device **devlist;
-       int ret, i, j;
+       int ret, j;
+       unsigned int i;
        const char *conn;
        char connection_id[64];
 
index ecaba493788e042e16dd8ce5571d46cc79733fd9..d76d8842da48d72af8d3eec7129aabc7bc5f3753 100644 (file)
@@ -178,13 +178,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        default:
                return SR_ERR_NA;
index a23ff68ff7bd6df4883c6b97af51b5c1f0fa1dfc..13465f5612f85e72add8093a8e04d5f1f9cca053 100644 (file)
@@ -160,11 +160,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".", devc->limit_samples);
                break;
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.", devc->limit_msec);
                break;
        default:
                return SR_ERR_NA;
index 103f44ce49d8c428b85fafc4d0ee92927607ec80..64d292dd3488b2a0d928a834bfb65976b1c80130 100644 (file)
@@ -295,13 +295,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                devc->limit_msec = g_variant_get_uint64(data);
                now = g_get_monotonic_time() / 1000;
                devc->end_time = now + devc->limit_msec;
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                ret = SR_ERR_NA;
index b41ef9a819adc24a433da3869765d91738d48ce6..01c336408c06179b39532062b05de2edb0a17bc0 100644 (file)
@@ -130,8 +130,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 0f872735b95534354c84a20f10eaddf6a933655a..0e431b54bcf97ccc6d2dd6c06667ebf6691e04ab 100644 (file)
@@ -328,22 +328,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("Time limit cannot be 0.");
-                       return SR_ERR;
-               }
                devc->limit_msec = g_variant_get_uint64(data);
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
-               if (g_variant_get_uint64(data) == 0) {
-                       sr_err("Sample limit cannot be 0.");
-                       return SR_ERR;
-               }
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
                return SR_ERR_NA;
index 3b33df9a6035dc14eac311b6f0867c7a9d9dcc20..bd792ea1e2354190b7b2ca77670c669b031e7ccc 100644 (file)
@@ -217,7 +217,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 {
        struct sr_dev_driver *di = sdi->driver;
        struct dev_context *devc;
-       int ret;
        const char *tmp_str;
 
        (void)cg;
@@ -231,12 +230,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        }
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        case SR_CONF_DATA_SOURCE:
                tmp_str = g_variant_get_string(data, NULL);
@@ -248,16 +245,15 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        return SR_ERR;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-
        (void)sdi;
        (void)cg;
 
index 9aa0019e951e2a580b200a07f68e807b2ccf4659..3b77407fc3236eee56cbec35cb9723fd70a49807 100644 (file)
@@ -231,7 +231,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        struct sr_dev_driver *di = sdi->driver;
        struct dev_context *devc;
        gint64 now;
-       int ret;
 
        (void)cg;
 
@@ -244,25 +243,21 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        }
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
                now = g_get_monotonic_time() / 1000;
                devc->end_time = now + devc->limit_msec;
-               sr_dbg("Setting time limit to %" PRIu64 "ms.",
-                      devc->limit_msec);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
-               sr_dbg("Setting sample limit to %" PRIu64 ".",
-                      devc->limit_samples);
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 5d8c534f27eb56c7f8c86b3462649886f84ef848..cb5df66e1a3f557aa1c15756cba1ebca3dfcd06b 100644 (file)
@@ -391,35 +391,26 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
+       GVariant *range[2];
 
        (void)cg;
 
+       if (!sdi)
+               return SR_ERR_ARG;
+
+       devc = sdi->priv;
+
        switch (key) {
        case SR_CONF_SAMPLERATE:
-               if (sdi) {
-                       devc = sdi->priv;
-                       *data = g_variant_new_uint64(devc->cur_samplerate);
-                       sr_spew("Returning samplerate: %" PRIu64 "Hz.",
-                               devc->cur_samplerate);
-               } else
-                       return SR_ERR_ARG;
+               *data = g_variant_new_uint64(devc->cur_samplerate);
                break;
        case SR_CONF_CAPTURE_RATIO:
-               if (sdi) {
-                       devc = sdi->priv;
-                       *data = g_variant_new_uint64(devc->capture_ratio);
-               } else
-                       return SR_ERR_ARG;
+               *data = g_variant_new_uint64(devc->capture_ratio);
                break;
        case SR_CONF_VOLTAGE_THRESHOLD:
-               if (sdi) {
-                       GVariant *range[2];
-                       devc = sdi->priv;
-                       range[0] = g_variant_new_double(devc->cur_threshold);
-                       range[1] = g_variant_new_double(devc->cur_threshold);
-                       *data = g_variant_new_tuple(range, 2);
-               } else
-                       return SR_ERR_ARG;
+               range[0] = g_variant_new_double(devc->cur_threshold);
+               range[1] = g_variant_new_double(devc->cur_threshold);
+               *data = g_variant_new_tuple(range, 2);
                break;
        default:
                return SR_ERR_NA;
index d11bcccc44712c0b02bc820a7d4d7c1f11db0162..148ea8a230470eeafbc757bb2679a464f556c80b 100644 (file)
@@ -464,9 +464,27 @@ SR_PRIV void sr_config_free(struct sr_config *src)
 
 }
 
+static void log_key(const struct sr_dev_inst *sdi,
+       const struct sr_channel_group *cg, uint32_t key, int op, GVariant *data)
+{
+       const char *opstr;
+       const struct sr_config_info *srci;
+
+       /* Don't log SR_CONF_DEVICE_OPTIONS, it's verbose and not too useful. */
+       if (key == SR_CONF_DEVICE_OPTIONS)
+               return;
+
+       opstr = op == SR_CONF_GET ? "get" : op == SR_CONF_SET ? "set" : "list";
+       srci = sr_config_info_get(key);
+
+       sr_spew("sr_config_%s(): key %d (%s) sdi %p cg %s -> %s", opstr, key,
+               srci ? srci->id : "NULL", sdi, cg ? cg->name : "NULL",
+               data ? g_variant_print(data, TRUE) : "NULL");
+}
+
 static int check_key(const struct sr_dev_driver *driver,
                const struct sr_dev_inst *sdi, const struct sr_channel_group *cg,
-               uint32_t key, int op)
+               uint32_t key, int op, GVariant *data)
 {
        const struct sr_config_info *srci;
        gsize num_opts, i;
@@ -487,8 +505,20 @@ static int check_key(const struct sr_dev_driver *driver,
                return SR_ERR_ARG;
        }
        opstr = op == SR_CONF_GET ? "get" : op == SR_CONF_SET ? "set" : "list";
-       sr_spew("sr_config_%s(): key %d (%s) sdi %p cg %s", opstr, key,
-                       srci->id, sdi, cg ? cg->name : "NULL");
+
+       switch (key) {
+       case SR_CONF_LIMIT_MSEC:
+       case SR_CONF_LIMIT_SAMPLES:
+       case SR_CONF_SAMPLERATE:
+               /* Setting any of these to 0 is not useful. */
+               if (op != SR_CONF_SET || !data)
+                       break;
+               if (g_variant_get_uint64(data) == 0) {
+                       sr_err("Cannot set '%s' to 0.", srci->id);
+                       return SR_ERR_ARG;
+               }
+               break;
+       }
 
        if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK) {
                /* Driver publishes no options. */
@@ -554,10 +584,11 @@ SR_API int sr_config_get(const struct sr_dev_driver *driver,
        if (!driver->config_get)
                return SR_ERR_ARG;
 
-       if (check_key(driver, sdi, cg, key, SR_CONF_GET) != SR_OK)
+       if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
                return SR_ERR_ARG;
 
        if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
+               log_key(sdi, cg, key, SR_CONF_GET, *data);
                /* Got a floating reference from the driver. Sink it here,
                 * caller will need to unref when done with it. */
                g_variant_ref_sink(*data);
@@ -597,10 +628,12 @@ SR_API int sr_config_set(const struct sr_dev_inst *sdi,
                ret = SR_ERR;
        else if (!sdi->driver->config_set)
                ret = SR_ERR_ARG;
-       else if (check_key(sdi->driver, sdi, cg, key, SR_CONF_SET) != SR_OK)
+       else if (check_key(sdi->driver, sdi, cg, key, SR_CONF_SET, data) != SR_OK)
                return SR_ERR_ARG;
-       else if ((ret = sr_variant_type_check(key, data)) == SR_OK)
+       else if ((ret = sr_variant_type_check(key, data)) == SR_OK) {
+               log_key(sdi, cg, key, SR_CONF_SET, data);
                ret = sdi->driver->config_set(key, data, sdi, cg);
+       }
 
        g_variant_unref(data);
 
@@ -665,11 +698,13 @@ SR_API int sr_config_list(const struct sr_dev_driver *driver,
        else if (!driver->config_list)
                return SR_ERR_ARG;
        else if (key != SR_CONF_SCAN_OPTIONS && key != SR_CONF_DEVICE_OPTIONS) {
-               if (check_key(driver, sdi, cg, key, SR_CONF_LIST) != SR_OK)
+               if (check_key(driver, sdi, cg, key, SR_CONF_LIST, NULL) != SR_OK)
                        return SR_ERR_ARG;
        }
-       if ((ret = driver->config_list(key, data, sdi, cg)) == SR_OK)
+       if ((ret = driver->config_list(key, data, sdi, cg)) == SR_OK) {
+               log_key(sdi, cg, key, SR_CONF_LIST, *data);
                g_variant_ref_sink(*data);
+       }
 
        return ret;
 }