drivers: return SR_ERR_NA on unsupported config key

Fixes bug 89.
This commit is contained in:
Bert Vermeulen 2013-04-16 02:33:03 +02:00
parent f02121f8d2
commit bd6fbf628a
22 changed files with 54 additions and 75 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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. */