From: Bert Vermeulen Date: Tue, 16 Apr 2013 00:33:03 +0000 (+0200) Subject: drivers: return SR_ERR_NA on unsupported config key X-Git-Tag: dsupstream~138 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bd6fbf628abef9fab5293e016ad11e1a1ac4a0a9;p=libsigrok.git drivers: return SR_ERR_NA on unsupported config key Fixes bug 89. --- diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c index 87b2dd81..89e59bbe 100644 --- a/hardware/agilent-dmm/api.c +++ b/hardware/agilent-dmm/api.c @@ -257,9 +257,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -280,7 +278,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/alsa/api.c b/hardware/alsa/api.c index 39ab74d1..2e674fff 100644 --- a/hardware/alsa/api.c +++ b/hardware/alsa/api.c @@ -133,7 +133,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_uint64(devc->cur_samplerate); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -153,8 +153,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples = g_variant_get_uint64(data); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; + return SR_ERR_NA; } return SR_OK; @@ -191,7 +190,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_builder_end(&gvb); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index e6cb602b..8155f7da 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -778,7 +778,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_ERR; break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -806,7 +806,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) else ret = SR_OK; } else { - ret = SR_ERR; + ret = SR_ERR_NA; } return ret; @@ -835,7 +835,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/brymen-dmm/api.c b/hardware/brymen-dmm/api.c index 23a59dc9..59f5040e 100644 --- a/hardware/brymen-dmm/api.c +++ b/hardware/brymen-dmm/api.c @@ -235,8 +235,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_msec = g_variant_get_uint64(data); break; default: - sr_err("Unknown hardware capability: %d.", id); - ret = SR_ERR_ARG; + ret = SR_ERR_NA; } return ret; @@ -256,8 +255,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - sr_err("Unknown config key: %d.", key); - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/chronovu-la8/api.c b/hardware/chronovu-la8/api.c index b0dccfea..53acf0b8 100644 --- a/hardware/chronovu-la8/api.c +++ b/hardware/chronovu-la8/api.c @@ -297,7 +297,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_ERR; break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -337,10 +337,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) sr_dbg("LIMIT_SAMPLES = %" PRIu64, devc->limit_samples); break; default: - /* Unknown capability, return SR_ERR. */ - sr_err("%s: Unknown capability: %d.", __func__, id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -372,7 +369,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/colead-slm/api.c b/hardware/colead-slm/api.c index b976ef93..7ae2892b 100644 --- a/hardware/colead-slm/api.c +++ b/hardware/colead-slm/api.c @@ -202,9 +202,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -225,7 +223,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 0245e185..73fe0927 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -286,7 +286,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) } break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -335,7 +335,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) sr_dbg("%s: setting pattern to %d", __func__, devc->sample_generator); } else { - ret = SR_ERR; + ret = SR_ERR_NA; } return ret; @@ -364,7 +364,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_strv(pattern_strings, ARRAY_SIZE(pattern_strings)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/fluke-dmm/api.c b/hardware/fluke-dmm/api.c index cdb527d1..92092fab 100644 --- a/hardware/fluke-dmm/api.c +++ b/hardware/fluke-dmm/api.c @@ -291,9 +291,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -314,7 +312,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index f76fa57f..25d47d85 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -620,7 +620,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_ERR; break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -640,7 +640,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples = g_variant_get_uint64(data); ret = SR_OK; } else { - ret = SR_ERR; + ret = SR_ERR_NA; } return ret; @@ -669,7 +669,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index c5540b74..6a11998d 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -429,7 +429,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_int32(NUM_VDIV); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -555,7 +555,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) ret = SR_ERR_ARG; break; default: - ret = SR_ERR_ARG; + ret = SR_ERR_NA; break; } @@ -616,7 +616,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) ARRAY_SIZE(trigger_sources)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/lascar-el-usb/api.c b/hardware/lascar-el-usb/api.c index 84daf93e..aedd147d 100644 --- a/hardware/lascar-el-usb/api.c +++ b/hardware/lascar-el-usb/api.c @@ -209,7 +209,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_uint64(devc->limit_samples); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -247,8 +247,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown hardware capability: %d.", id); - ret = SR_ERR_ARG; + ret = SR_ERR_NA; } return ret; @@ -269,7 +268,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index 58ff415a..f3f4dcf7 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -298,7 +298,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_ERR; break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -363,7 +363,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) ret = SR_OK; break; default: - ret = SR_ERR; + ret = SR_ERR_NA; break; } @@ -393,7 +393,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/mic-985xx/api.c b/hardware/mic-985xx/api.c index f96d128f..8a18313f 100644 --- a/hardware/mic-985xx/api.c +++ b/hardware/mic-985xx/api.c @@ -235,8 +235,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_msec); break; default: - sr_err("Unknown config: %d.", id); - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -256,7 +255,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/nexus-osciprime/api.c b/hardware/nexus-osciprime/api.c index 3413b8ea..48b361a0 100644 --- a/hardware/nexus-osciprime/api.c +++ b/hardware/nexus-osciprime/api.c @@ -262,8 +262,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) switch (id) { default: - sr_err("Unknown hardware capability: %d.", id); - ret = SR_ERR_ARG; + ret = SR_ERR_NA; } return ret; @@ -276,7 +275,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) switch (key) { default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index dc046700..cab99896 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -267,7 +267,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -314,7 +314,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) ret = SR_OK; break; default: - ret = SR_ERR; + ret = SR_ERR_NA; } return ret; @@ -347,7 +347,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c index 595d73e6..3abe0046 100644 --- a/hardware/rigol-ds1xx2/api.c +++ b/hardware/rigol-ds1xx2/api.c @@ -379,7 +379,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_int32(NUM_VDIV); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -488,8 +488,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) ret = SR_ERR_ARG; break; default: - sr_err("Unknown hardware capability: %d.", id); - ret = SR_ERR_ARG; + ret = SR_ERR_NA; break; } @@ -540,7 +539,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) devc->has_digital ? ARRAY_SIZE(trigger_sources) : 4); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index cb741f93..e74cbccd 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -386,9 +386,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_msec); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -409,7 +407,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index ca57aaa5..3b4dc1fa 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -198,8 +198,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown hardware capability: %d.", id); - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -220,7 +219,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index f34da02b..e97355ef 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -197,9 +197,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown capability: %d.", id); - return SR_ERR; - break; + return SR_ERR_NA; } return SR_OK; @@ -220,7 +218,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/victor-dmm/api.c b/hardware/victor-dmm/api.c index 13777ceb..037b0b56 100644 --- a/hardware/victor-dmm/api.c +++ b/hardware/victor-dmm/api.c @@ -256,8 +256,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) devc->limit_samples); break; default: - sr_err("Unknown hardware capability: %d.", id); - ret = SR_ERR_ARG; + ret = SR_ERR_NA; } return ret; @@ -274,7 +273,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/hardware/zeroplus-logic-cube/api.c b/hardware/zeroplus-logic-cube/api.c index 5d0ba63b..78036892 100644 --- a/hardware/zeroplus-logic-cube/api.c +++ b/hardware/zeroplus-logic-cube/api.c @@ -511,7 +511,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_ERR; break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; @@ -539,7 +539,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) case SR_CONF_CAPTURE_RATIO: return set_capture_ratio(devc, g_variant_get_uint64(data)); default: - return SR_ERR; + return SR_ERR_NA; } return SR_OK; @@ -579,7 +579,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) *data = g_variant_new_string(TRIGGER_TYPE); break; default: - return SR_ERR_ARG; + return SR_ERR_NA; } return SR_OK; diff --git a/libsigrok.h b/libsigrok.h index 4212c59c..294bb15d 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -70,6 +70,7 @@ enum { SR_ERR_ARG = -3, /**< Function argument error. */ SR_ERR_BUG = -4, /**< Errors hinting at internal bugs. */ SR_ERR_SAMPLERATE = -5, /**< Incorrect samplerate. */ + SR_ERR_NA = -6, /**< Not applicable. */ }; #define SR_MAX_NUM_PROBES 64 /* Limited by uint64_t. */