From: Gerhard Sittig <redacted>
Date: Mon, 31 Jan 2022 18:05:02 +0000 (+0100)
Subject: kingst-la2016: reduce a little if-deffery in logic threshold support
X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7de0f6c1ffc52f6f96e2733d66d8d85cf3526000;p=libsigrok.git

kingst-la2016: reduce a little if-deffery in logic threshold support

Move a logic threshold related switch case to the location where its
sibling config keys reside. Which eliminates a separate distant chunk
under an ifdef which should not have been there in the first place.

Make the presence of a device context member depend on the choice of
simple or complex threshold support. The simple approach exclusively
requires one index into the discrete set of a few voltages.
---

diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c
index 0e8f9fe0..044b728f 100644
--- a/src/hardware/kingst-la2016/api.c
+++ b/src/hardware/kingst-la2016/api.c
@@ -1093,16 +1093,14 @@ static int config_list(uint32_t key, GVariant **data,
 			LA2016_THR_VOLTAGE_MIN,
 			LA2016_THR_VOLTAGE_MAX, 0.1);
 		break;
+	case SR_CONF_LOGIC_THRESHOLD:
+		*data = g_variant_new_strv(ARRAY_AND_SIZE(logic_threshold));
+		break;
 #endif /* WITH_THRESHOLD_SIMPLE */
 #endif /* WITH_THRESHOLD_DEVCFG */
 	case SR_CONF_TRIGGER_MATCH:
 		*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
 		break;
-#if WITH_THRESHOLD_DEVCFG && !WITH_THRESHOLD_SIMPLE
-	case SR_CONF_LOGIC_THRESHOLD:
-		*data = g_variant_new_strv(ARRAY_AND_SIZE(logic_threshold));
-		break;
-#endif
 	default:
 		return SR_ERR_NA;
 	}
diff --git a/src/hardware/kingst-la2016/protocol.h b/src/hardware/kingst-la2016/protocol.h
index 4e16b372..30bf0578 100644
--- a/src/hardware/kingst-la2016/protocol.h
+++ b/src/hardware/kingst-la2016/protocol.h
@@ -123,7 +123,9 @@ struct dev_context {
 		float duty;
 	} pwm_setting[LA2016_NUM_PWMCH_MAX];
 	size_t threshold_voltage_idx;
+#if !WITH_THRESHOLD_SIMPLE
 	float threshold_voltage;
+#endif
 	uint64_t cur_samplerate;
 	struct sr_sw_limits sw_limits;
 	uint64_t capture_ratio;