config_list: Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL. Almost all drivers were relying on this already.
This commit is contained in:
parent
709468baf7
commit
4d399734b4
|
@ -399,8 +399,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
|
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
if (!sdi || !sdi->priv || !(devc = sdi->priv))
|
if (!sdi)
|
||||||
return SR_ERR_BUG;
|
return SR_ERR_BUG;
|
||||||
|
devc = sdi->priv;
|
||||||
cv_fill_samplerates_if_needed(sdi);
|
cv_fill_samplerates_if_needed(sdi);
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
|
||||||
|
|
|
@ -740,8 +740,6 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_builder_end(&gvb);
|
*data = g_variant_builder_end(&gvb);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
case SR_CONF_SAMPLERATE:
|
||||||
if (!sdi->priv)
|
|
||||||
return SR_ERR_ARG;
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
|
||||||
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
|
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
|
||||||
|
|
|
@ -487,7 +487,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
struct dev_context *devc = NULL;
|
struct dev_context *devc = NULL;
|
||||||
const struct scope_config *model = NULL;
|
const struct scope_config *model = NULL;
|
||||||
|
|
||||||
if (sdi && (devc = sdi->priv)) {
|
if (sdi) {
|
||||||
|
devc = sdi->priv;
|
||||||
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
|
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,6 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
static int config_list(uint32_t key, GVariant **data,
|
static int config_list(uint32_t key, GVariant **data,
|
||||||
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
GVariant *gvar;
|
GVariant *gvar;
|
||||||
GVariantBuilder gvb;
|
GVariantBuilder gvb;
|
||||||
|
|
|
@ -700,7 +700,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
|
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
if (sdi != NULL)
|
if (sdi)
|
||||||
break;
|
break;
|
||||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||||
drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
|
drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
|
||||||
|
|
|
@ -805,8 +805,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Every other option requires a valid device instance. */
|
/* Every other option requires a valid device instance. */
|
||||||
if (!sdi || !(devc = sdi->priv))
|
if (!sdi)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
devc = sdi->priv;
|
||||||
|
|
||||||
/* If a channel group is specified, it must be a valid one. */
|
/* If a channel group is specified, it must be a valid one. */
|
||||||
if (cg && !g_slist_find(sdi->channel_groups, cg)) {
|
if (cg && !g_slist_find(sdi->channel_groups, cg)) {
|
||||||
|
|
|
@ -710,8 +710,10 @@ SR_API int sr_config_get(const struct sr_dev_driver *driver,
|
||||||
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
|
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
if (sdi && !sdi->priv)
|
if (sdi && !sdi->priv) {
|
||||||
|
sr_err("Can't get config (sdi != NULL, sdi->priv == NULL).");
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
|
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
|
||||||
log_key(sdi, cg, key, SR_CONF_GET, *data);
|
log_key(sdi, cg, key, SR_CONF_GET, *data);
|
||||||
|
@ -793,9 +795,11 @@ SR_API int sr_config_commit(const struct sr_dev_inst *sdi)
|
||||||
/**
|
/**
|
||||||
* List all possible values for a configuration key.
|
* List all possible values for a configuration key.
|
||||||
*
|
*
|
||||||
* @param[in] driver The sr_dev_driver struct to query.
|
* @param[in] driver The sr_dev_driver struct to query. Must not be NULL.
|
||||||
* @param[in] sdi (optional) If the key is specific to a device, this must
|
* @param[in] sdi (optional) If the key is specific to a device, this must
|
||||||
* contain a pointer to the struct sr_dev_inst to be checked.
|
* contain a pointer to the struct sr_dev_inst to be checked.
|
||||||
|
* Otherwise it must be NULL. If sdi is != NULL, sdi->priv must
|
||||||
|
* also be != NULL.
|
||||||
* @param[in] cg The channel group on the device for which to list the
|
* @param[in] cg The channel group on the device for which to list the
|
||||||
* values, or NULL.
|
* values, or NULL.
|
||||||
* @param[in] key The configuration key (SR_CONF_*).
|
* @param[in] key The configuration key (SR_CONF_*).
|
||||||
|
@ -828,6 +832,10 @@ SR_API int sr_config_list(const struct sr_dev_driver *driver,
|
||||||
if (check_key(driver, sdi, cg, key, SR_CONF_LIST, NULL) != SR_OK)
|
if (check_key(driver, sdi, cg, key, SR_CONF_LIST, NULL) != SR_OK)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
}
|
}
|
||||||
|
if (sdi && !sdi->priv) {
|
||||||
|
sr_err("Can't list config (sdi != NULL, sdi->priv == NULL).");
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
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);
|
log_key(sdi, cg, key, SR_CONF_LIST, *data);
|
||||||
g_variant_ref_sink(*data);
|
g_variant_ref_sink(*data);
|
||||||
|
|
|
@ -894,7 +894,6 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
|
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sr_spew("%s: Unsupported key %u", __func__, key);
|
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue