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:
Tilman Sauerbeck 2015-10-15 22:38:12 +02:00 committed by Uwe Hermann
parent 087c4d59c0
commit a5c38703ee
5 changed files with 7 additions and 19 deletions

View File

@ -284,10 +284,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
return beaglelogic_set_triggerflags(devc);
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio > 100) {
devc->capture_ratio = 0;
if (devc->capture_ratio > 100)
return SR_ERR;
}
return SR_OK;
default:
return SR_ERR_NA;

View File

@ -567,11 +567,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio > 100) {
devc->capture_ratio = 0;
ret = SR_ERR;
} else
ret = SR_OK;
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
break;
default:
ret = SR_ERR_NA;

View File

@ -291,10 +291,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
devc->capture_ratio = 0;
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
ret = SR_ERR;
} else
else
ret = SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:

View File

@ -299,10 +299,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
devc->capture_ratio = 0;
if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
ret = SR_ERR;
} else
else
ret = SR_OK;
break;
case SR_CONF_EXTERNAL_CLOCK:

View File

@ -502,11 +502,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
break;
case SR_CONF_CAPTURE_RATIO:
devc->capture_ratio = g_variant_get_uint64(data);
if (devc->capture_ratio > 100) {
devc->capture_ratio = 0;
ret = SR_ERR;
} else
ret = SR_OK;
ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
break;
case SR_CONF_VOLTAGE_THRESHOLD:
g_variant_get(data, "(dd)", &low, &high);