drivers: Fix behaviour when trying to set an invalid capture ratio.
Trying to configure an invalid capture ratio would reset the previously configured value. Instead, we should just reject the new value and keep the original one.
This commit is contained in:
parent
087c4d59c0
commit
a5c38703ee
|
@ -284,10 +284,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
return beaglelogic_set_triggerflags(devc);
|
return beaglelogic_set_triggerflags(devc);
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
if (devc->capture_ratio > 100) {
|
if (devc->capture_ratio > 100)
|
||||||
devc->capture_ratio = 0;
|
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
}
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
default:
|
default:
|
||||||
return SR_ERR_NA;
|
return SR_ERR_NA;
|
||||||
|
|
|
@ -567,11 +567,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
if (devc->capture_ratio > 100) {
|
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||||
devc->capture_ratio = 0;
|
|
||||||
ret = SR_ERR;
|
|
||||||
} else
|
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = SR_ERR_NA;
|
ret = SR_ERR_NA;
|
||||||
|
|
|
@ -291,10 +291,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
|
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
|
||||||
devc->capture_ratio = 0;
|
|
||||||
ret = SR_ERR;
|
ret = SR_ERR;
|
||||||
} else
|
else
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_EXTERNAL_CLOCK:
|
case SR_CONF_EXTERNAL_CLOCK:
|
||||||
|
|
|
@ -299,10 +299,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
|
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
|
||||||
devc->capture_ratio = 0;
|
|
||||||
ret = SR_ERR;
|
ret = SR_ERR;
|
||||||
} else
|
else
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_EXTERNAL_CLOCK:
|
case SR_CONF_EXTERNAL_CLOCK:
|
||||||
|
|
|
@ -502,11 +502,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
break;
|
break;
|
||||||
case SR_CONF_CAPTURE_RATIO:
|
case SR_CONF_CAPTURE_RATIO:
|
||||||
devc->capture_ratio = g_variant_get_uint64(data);
|
devc->capture_ratio = g_variant_get_uint64(data);
|
||||||
if (devc->capture_ratio > 100) {
|
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
|
||||||
devc->capture_ratio = 0;
|
|
||||||
ret = SR_ERR;
|
|
||||||
} else
|
|
||||||
ret = SR_OK;
|
|
||||||
break;
|
break;
|
||||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||||
g_variant_get(data, "(dd)", &low, &high);
|
g_variant_get(data, "(dd)", &low, &high);
|
||||||
|
|
Loading…
Reference in New Issue